Don't know how to edit my post. So...
>Also i tried to change Payment Class with the same class.
I mean:
Also i tried to change Payment Class with the same result.
If you add breakpoint to your ProcessPayment method, or even better add Debugger.Break(); does it got hit? Is your payment provider even called?
I would try to get into method call in Debugger context and then step out back to workflow context and see what's there.
Hi, Valdis, thanks for your reply.
I have breakpoints working on both front-end and back-end site.
I used Enoteca sample site as front-end site. I have problem here:
if (_cartHelper.OrderForm.AuthorizedPaymentTotal + _cartHelper.OrderForm.CapturedPaymentTotal < _cartHelper.Cart.Total)
{
throw new PaymentException(PaymentException.ErrorType.ProviderError, "", "Failed to process payment.");
}
AuthorizedPaymentTotal is 0 and _cartHelper.OrderForm.CapturedPaymentTotal is also 0, so exception is raised.
If i use preinstalled gateways CapturedPaymentTotal is not 0, i looked also in samples and didn't found any place where this value is initialized, also i tryed to set this value in my Gateway but with no luck.
Thanks for any help.
There are 2 WF activities which may influence totals on order form:
Mediachase.Commerce.Workflow.Activities.Cart.ProcessPaymentActivity
This guy is responsible for calling your payment provider and
Mediachase.Commerce.Workflow.Activities.CalculateTotalsActivity
This one should calculate orde form totals. Something like this:
//Calculate payment total
var formPayments = form.Payments.ToArray();
var resultingAuthorizedPayments = PaymentTransactionTypeManager.GetResultingPaymentsByTransactionType(formPayments, TransactionType.Authorization);
var resultingCapturedPayments = PaymentTransactionTypeManager.GetResultingPaymentsByTransactionType(formPayments, TransactionType.Capture);
var resultingSalsePayments = PaymentTransactionTypeManager.GetResultingPaymentsByTransactionType(formPayments, TransactionType.Sale);
var resultingCreditPayments = PaymentTransactionTypeManager.GetResultingPaymentsByTransactionType(formPayments, TransactionType.Credit);
form.AuthorizedPaymentTotal = resultingAuthorizedPayments.Where(x => PaymentStatusManager.GetPaymentStatus(x) == PaymentStatus.Processed).Sum(y => y.Amount);
form.CapturedPaymentTotal = resultingSalsePayments.Where(x => PaymentStatusManager.GetPaymentStatus(x) == PaymentStatus.Processed).Sum(y => y.Amount);
form.CapturedPaymentTotal += resultingCapturedPayments.Where(x => PaymentStatusManager.GetPaymentStatus(x) == PaymentStatus.Processed).Sum(y => y.Amount);
form.CapturedPaymentTotal -= resultingCreditPayments.Where(x => PaymentStatusManager.GetPaymentStatus(x) == PaymentStatus.Processed).Sum(y => y.Amount);
I would try to dig into both of them (within CartCheckoutWorkflow context) and see why totals get 0.
One more quick Q: what is transaction type of incoming payment object in your gateway?
Hi Valdis, thanks for the reply.
>what is transaction type of incoming payment object in your gateway?
independently of which Payment Class i selected in commerce admin i have "OtherPayment" incoming to my payment method. And this is a bit confusing for me.
TransactionType is empty string. How can i change this? Or what i'm doing wrong?
That could be a problem. It depends on your payment provider and overall site logic. Either you can set SALE transaction type already on 1st process payment execution. Or sometimes you are able to authorize (AUTH) and then do capture (CAPTURE) payments. Usually AUTH/CAPTURE payments are required for internet shops where CAPTURE is executed only when order has been shipped. But it depends of course.
Before proceeding further with processing of the payment, set its transaction type.
if (string.IsNullOrEmpty(payment.TransactionType))
{
payment.TransactionType = TransactionType.Sale.ToString();
}
Valdis, thanks for your responses, i'm really appreciate that.
So should i set transaction type on web site before gateway processing?
It can be a problem with deployment custom gateway to target web sites, becose as i understand to support my custom gateway thay need to be edited to set correct transaction type. Sound not really good.
Or i missed somethig?
Thanks, Igor.
No, this is done in payment provider gateway itself. You can check some built-in (Giftcard for instance) gateways.
Thask you Valdis, it seems more or less clear now for me. Have one more question, i need to process payment on custom payment terminal so i i have PaymentMethod control and trying to redirect to Url, but unfortunately it does not work (after redirecting i see infinite progress bar).
Thanks for your help.
Igor.
If this is Enoteca Commerce R3 site - I think that checkout steps were made ajax style (not sure). So I be that without refactoring client-side -> redirects may not work.
I'll add this here too about the Enoteca sample site redirect, there needs to be a special redirect page that does the real redirect with JavaScript (page that renders JavaScript to change the top window location): http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=70240&epslanguage=en
Hi,
i've been created custom gateway, implemented ProcessPayment interface and deployed to the both back-end and front-end sites.
On the back-end i select my Class Name and select Payment Class - other payment.
The problem is when i try to check out i got error message "Failed to process payment." even i commented out all functional code and leave only returning true.
Also i tried to change Payment Class with the same class.
i will appreciate any help.
Thanks.