Error in Custom DibsPaymentMethodService Overriding ProcessCallback
Fellow Umbracians.
I'm trying to customize the dialogue between uCommerce and DIBS to allow ticket registrations.
So far, I've succeeded in copying the DibsPageBuilder and adding the maketicket parameter. However, I need to customize the callback made to the function ProcessCallcack in the DibsPaymentMethodService class.
I copied the ProcessCallback and its content carefully and added it to my custom class, but when I run the checkout pipeline I keep getting the following error:
[code]UCommerce.Pipelines.PipelineException: Exception occoured while processing pipeline 'UCommerce.Pipelines.Checkout.CheckoutPipeline'. See inner exception for details. ---> System.Security.SecurityException: Payment insufficient to cover order total for OrderGuid xxx. Please ensure that payments cover the entire value of the order before checking out. at UCommerce.Pipelines.Checkout.ValidatePaymentsMadeAgainstOrderTotalTask.Execute(PurchaseOrder subject) at UCommerce.Pipelines.Pipeline`1.Execute(T subject) --- End of inner exception stack trace ---...[/code]
The complete code I've copied is:
[code]public override void ProcessCallback(Payment payment)
{
if (payment.PaymentStatusId != 10000001)
return;
DibsPaymentMethodServiceConfigurationSection instance = DibsPaymentMethodServiceConfigurationSection.Instance;
string s = HttpContext.Current.Request["transact"];
if (string.IsNullOrEmpty(s))
throw new ArgumentException("transact must be present in query string.");
int result;
if (!int.TryParse(s, out result))
throw new FormatException("transact must be a valid int32");
PaymentStatusCode paymentStatusCode = PaymentStatusCode.Authorized;
if (instance.UseMd5)
{
string parameter1 = this.GetParameter("authkey", "When using md5 \"{0}\" cannot be null or empty", new string[1]
{
"authkey"
});
string parameter2 = this.GetParameter("currency", "When using md5 \"{0}\" cannot be null or empty", new string[1]
{
"currency"
});
string parameter3 = this.GetParameter("amount", "When using md5 \"{0}\" cannot be null or empty", new string[1]
{
"amount"
});
int currencyNumber = new CurrencyCodeTranslater().FromIsoCode(parameter2);
string postMd5Key = new DibsMd5Computer().GetPostMd5Key(result.ToString(), parameter3, currencyNumber);
if (!parameter1.Equals(postMd5Key))
paymentStatusCode = PaymentStatusCode.Declined;
}
payment.PaymentStatus = PaymentStatus.Get((object) paymentStatusCode);
payment.TransactionId = result.ToString();
this.ProcessPaymentRequest(new PaymentRequest(payment.PurchaseOrder, payment));
}
[/code]
Why would the checkout pipeline fail to succeed when I manually override the ProcessCallback with same code, which the function usually is made of? My current uCommerce platform runs version 2.6.1.
Hi there. I succeeded in customizing the provider, by calling base.ProcessCallback(payment). Then I would like to know how to store the information received on the callback.
How would I save the ticket id, so that I can get it on the confirmation page? This is the code I have whenever DIBS calls back on the site with the ticket id.
if (!string.IsNullOrEmpty(HttpContext.Current.Request["preauth"]))
{
string id = HttpContext.Current.Request["transact"];
if (string.IsNullOrEmpty(id))
throw new ArgumentException("ticketid must be present in query string.");
MailControls.SendEmail("[email protected]", "[email protected]", "Preauth", "here goes the preauth: " + HttpContext.Current.Request["preauth"].ToString() + " and the transaction " + id);
OrderProperty op = new OrderProperty();
op.Key = "ticketid";
op.Value=id;
payment.PurchaseOrder.OrderProperties.Add(op);
payment.PurchaseOrder.Save();
payment.Save();
}
I get an email with the right id, however, I don't know how to access that information on the confirmation page. One of many attempts looks like:
var b = SiteContext.Current.OrderContext.GetBasket(true);
You can access the purchase order through the payment. That should be no problem i think.
You can try using something like that:
var orderGuid =newGuid(umbraco.library.RequestQueryString("orderGuid")); var purchaseOrder =PurchaseOrder.All().Single(x => x.OrderGuid== orderGuid);
But you have to be sure if DIBS will send the guid back in the query string for this to work. So you can get the PurchaseOrder directly and add the property then.
Error in Custom DibsPaymentMethodService Overriding ProcessCallback
Fellow Umbracians.
I'm trying to customize the dialogue between uCommerce and DIBS to allow ticket registrations.
So far, I've succeeded in copying the DibsPageBuilder and adding the maketicket parameter. However, I need to customize the callback made to the function ProcessCallcack in the DibsPaymentMethodService class.
I copied the ProcessCallback and its content carefully and added it to my custom class, but when I run the checkout pipeline I keep getting the following error:
[code]UCommerce.Pipelines.PipelineException: Exception occoured while processing pipeline 'UCommerce.Pipelines.Checkout.CheckoutPipeline'. See inner exception for details. ---> System.Security.SecurityException: Payment insufficient to cover order total for OrderGuid xxx. Please ensure that payments cover the entire value of the order before checking out. at UCommerce.Pipelines.Checkout.ValidatePaymentsMadeAgainstOrderTotalTask.Execute(PurchaseOrder subject) at UCommerce.Pipelines.Pipeline`1.Execute(T subject) --- End of inner exception stack trace ---...[/code]
The complete code I've copied is:
[code]public override void ProcessCallback(Payment payment) { if (payment.PaymentStatusId != 10000001) return; DibsPaymentMethodServiceConfigurationSection instance = DibsPaymentMethodServiceConfigurationSection.Instance; string s = HttpContext.Current.Request["transact"]; if (string.IsNullOrEmpty(s)) throw new ArgumentException("transact must be present in query string."); int result; if (!int.TryParse(s, out result)) throw new FormatException("transact must be a valid int32"); PaymentStatusCode paymentStatusCode = PaymentStatusCode.Authorized; if (instance.UseMd5) { string parameter1 = this.GetParameter("authkey", "When using md5 \"{0}\" cannot be null or empty", new string[1] { "authkey" }); string parameter2 = this.GetParameter("currency", "When using md5 \"{0}\" cannot be null or empty", new string[1] { "currency" }); string parameter3 = this.GetParameter("amount", "When using md5 \"{0}\" cannot be null or empty", new string[1] { "amount" }); int currencyNumber = new CurrencyCodeTranslater().FromIsoCode(parameter2); string postMd5Key = new DibsMd5Computer().GetPostMd5Key(result.ToString(), parameter3, currencyNumber); if (!parameter1.Equals(postMd5Key)) paymentStatusCode = PaymentStatusCode.Declined; } payment.PaymentStatus = PaymentStatus.Get((object) paymentStatusCode); payment.TransactionId = result.ToString(); this.ProcessPaymentRequest(new PaymentRequest(payment.PurchaseOrder, payment)); } [/code]
Why would the checkout pipeline fail to succeed when I manually override the ProcessCallback with same code, which the function usually is made of? My current uCommerce platform runs version 2.6.1.
Many thanks in advance,
Brinck10
Hi there. I succeeded in customizing the provider, by calling base.ProcessCallback(payment). Then I would like to know how to store the information received on the callback.
How would I save the ticket id, so that I can get it on the confirmation page? This is the code I have whenever DIBS calls back on the site with the ticket id.
if (!string.IsNullOrEmpty(HttpContext.Current.Request["preauth"]))
{
string id = HttpContext.Current.Request["transact"];
if (string.IsNullOrEmpty(id))
throw new ArgumentException("ticketid must be present in query string.");
MailControls.SendEmail("[email protected]", "[email protected]", "Preauth", "here goes the preauth: " + HttpContext.Current.Request["preauth"].ToString() + " and the transaction " + id);
OrderProperty op = new OrderProperty();
op.Key = "ticketid";
op.Value=id;
payment.PurchaseOrder.OrderProperties.Add(op);
payment.PurchaseOrder.Save();
payment.Save();
}
I get an email with the right id, however, I don't know how to access that information on the confirmation page. One of many attempts looks like:
var b = SiteContext.Current.OrderContext.GetBasket(true);
var po = b.PurchaseOrder;
List<OrderProperty> oplist = po.OrderProperties.ToList();
foreach(OrderProperty p in oplist){
InformationMessage.Text += p.Value;
}
But with no luck. Would anybody be able to help me out? (running uCommerce 2.6.1)
/Brinck10
Have you looked in uCommerce admin if the property is visible in the order?
You can get a custom property by calling po["customproperty"] if it's added to the purchaseorder directly
Yes, I've tried that, but it does not show up.
I believe the problem derives from the fact that I only have access to the payment, and thereby try to access the purchase order so:
PurchaseOrder po = payment.PurchaseOrder;
po["ticketid"]=id;
po.Save();
But it didn't have any effect.
Is it the right way to do access the purchase order through the payment?
Best regards,
Brinck10
Im not sure about the way you set the property.
Do you have the .AddOrderProperty(); on the PurchaseOrder object? (I can't remeber if it's a new thing in uCommerce 3)
You can access the purchase order through the payment. That should be no problem i think.
You can try using something like that:
But you have to be sure if DIBS will send the guid back in the query string for this to work. So you can get the PurchaseOrder directly and add the property then.
Haven't worked with DIBS so i'm not sure.
Thanks David, it worked like a charm!
is working on a reply...