Add-ons and ModulesCustom Payment Module: Docdata

Custom Payment Module: Docdata

Sana Commerce 8.2
Your provider

Determining the Right Configuration

There are few things we can configure for each PSP implementation. They are almost all related to the way the user should be redirected to the PSP payment page. Docdata has two options to do this: GET or POST. Since POST is the safest we chose to use this method.  This means we need to create a hidden form and post this to the payment site. The payment library already supports this by default; we need to configure the payment module in the following way:
ResponseUseXml False
ResponseUsePost True
This will make the pre-process pipeline redirect the user the 'paymentframe.aspx' page. This page contains an iframe that points to 'payment.aspx'. It will create a hidden form with all configuration values that have the property 'isRequestParameter' set to true. This form will be posted to the external payment page.  In the configuration we also set the values we want to post, for example:
<add name="merchant_name" value="" isRequestParameter="true" />
<add name="merchant_password" value="" isRequestParameter="true" />
<add name="days_pay_period" value="14" isRequestParameter="true" />
These are all static values that Docdata needs. But it might also need to post the 'OrderId' and price to this page. In that case we will need to add the configuration values in the code. We can do this by overwriting the 'SetPaymentConfiguration' function. Passed to this function is a list of loaded configuration values called 'configurationToLoad'. Adding configuration values to this collection at this point will add them for the entire payment module. Let's take the example of 'OrderId' and price, we add them like this:
configurationToLoad.Add(new PaymentConfigurationSetting { Value = order.Id.ToString(), Name = "merchant_transaction_id", IsRequestParameter = false });

string price = Math.Round(order.TotalPrice, 2).ToString(CultureInfo.InvariantCulture);
  configurationToLoad.Add(new PaymentConfigurationSetting { Value = price, Name = "price", IsRequestParameter = false });
Now all the right values will be sent to the payment page. These settings will depend on what the PSP requires.
Add-ons and ModulesCustom Payment Module: Docdata