EpiServer Commerce custom gateway



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.


Aug 20, 2013 14:15

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.

Aug 20, 2013 14:18

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.

Aug 20, 2013 18:54

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.


Edited, Aug 21, 2013 22:14

There are 2 WF activities which may influence totals on order form:



This guy is responsible for calling your payment provider and



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?

Edited, Aug 22, 2013 7:45

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. 

Aug 22, 2013 10:15

I mean paymentClass.TransactionType. Should be "Authorization".

Aug 22, 2013 10:19

TransactionType is empty string. How can i change this? Or what i'm doing wrong?

Aug 22, 2013 10:36

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();


Aug 22, 2013 13:10

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.

Aug 22, 2013 13:18

No, this is done in payment provider gateway itself. You can check some built-in (Giftcard for instance) gateways.

Aug 22, 2013 15:49

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.


Aug 22, 2013 16:25

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.

Aug 22, 2013 17:36

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

Oct 11, 2013 21:35
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.