paymentGatewayService configuration for a custom PaymentGatewayProvider

With the current configuration:

<configuration>
  <configSections>
    <sectionGroup name="system.web">
      <section name="paymentGatewayService" type="Asi.iBO.Commerce.PaymentGatewayServiceSection, Asi.iBO" allowDefinition="MachineToApplication" restartOnExternalChanges="true" />
    </sectionGroup>
  </configSections>

  <system.web>
    <paymentGatewayService defaultProvider="MockCustomPaymentGatewayProvider">
      <providers>
        <add name="MockCustomPaymentGatewayProvider" type="Crown.Imis.IntegrationTests.MockCustomPaymentGatewayProvider, Crown.Imis.IntegrationTests" authorizationAccounts="AUTHORIZE" />
      </providers>
    </paymentGatewayService>
  </system.web>
...
</configuration>

Calling myCPayment.ProcessPayment(myBillingAddress) should _always_ call ProcessPayment on a MockCustomPaymentGatewayProvider or throw an exception, correct?

What it does on my machine is call MockCustomPaymentGatewayProvider's constructor and Initialize method the first time I call CPayment's ProcessPayment method, but it does _not_ call MockCustomPaymentGatewayProvider's ProcessPayment method.  It _does_ return a successful PaymentGatewayResponse, which is scary because I don't know what gateway it could possibly be using.

Is there something I'm missing?

EDIT: Per Balaji's suggestion, I configured MockCustomPaymentGatewayProvider to be used specifically with the AUTHORIZE authorization account (probably need a new name for that, huh?); the change made is in bold. 

I also added this test:

[Test]
public void Test_ConfiguredCreditCardCashAccount_isAssociatedWith_AuthorizeDotNet_PaymentAuthorizationAccount()
{           
    var code = ConfigurationManager.AppSettings["CreditCardCashAccountCode"];
    var cashAccount = iboAdmin.ReferenceData.GetCashAccount(code);

    var authAccountCode = cashAccount.AuthorizationAccountCode;

    Assert.AreEqual("AUTHORIZE", authAccountCode);
}

which passes, showing that the configured CreditCardCashAccountCode is associated with the AUTHORIZE auth account.

The test that fails is a little much to show here, but it creates a valid credit card CPayment associated with the configured CreditCardCashAccountCode then calls ProcessPayment.  It then asserts that a MockPaymentGatewayProvider is contstructed, and that ProcessPayment is called on it.  The latter assertion fails.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Process payment

Hi

Process payment method invoked  based on your selected cash account from  CPayment object

- Make sure selected  Cash account set as credit/debit card type

- Cash account must have Custom CCAuth account code defiend,

Thanks

Thanks for your reply; it

Thanks for your reply; it prompted me to look into CC Auth Accounts (a.k.a. payment authorization account).  This is certainly something that I'll need to understand before I'm done!  :)

My (mis)understanding was that using one payment gateway provider and making it the default would make all payments use that provider; the authorizationAccounts property in the configuration is not necessary.

To be sure, I tried associating the cash account with a new payment authorization account, to no avail.

The cash account is credit card type.

I'll update the original post with details; maybe I made a mistake that you or someone else can see.

Answer

Evidently, iMIS will only process a payment with an Auth account in Immediate AuthorizationMode, as we can see in Asi.iBO.Commerce.PaymentGatewayService.ProcessPayment:

  if ((payment.PaymentAuthorizationAccount.AuthorizationMode != PaymentAuthorizationMode.Immediate) && (payment.PaymentAuthorizationAccount.GatewayName != "Other"))
  {
    return new PaymentGatewayResponse();
  }
  // else, identify the correct PaymentGatewayProvider to use.

Setting the auth account that you want to use on Immediate auth mode in iMIS Desktop cleared the error.