March 5, 2010

Consorzio Triveneto payment gateway for ASPDotNetStorefront (ASPDNSF)

Filed under: Tips — Tags: , , , — Webopius @ 11:19 am

We’ve recently written a new payment gateway for ASPDotNetStorefront allowing stores to make payments using the Consorzio Triveneto payment system. Consorzio Triveneto is a ‘boomerang’ gateway that takes the customer off the store to a hosted payment page to enter their card details before returning them back. It operates in a similar way to other ASPDotNetStorefront boomerang gateways such as PayPal express and Worldpay.

Writing a new ASPDotNetStorefront payment gateway

In developing this new gateway, we spent a lot of time working in the payment processing system used in ASPDNSF and took advantage of the excellent, modular way in which you can easily extend the available number of payment methods. We thought it would be useful to share the method used.

If you are developing a new gateway, you will need to have purchased the ASPDotNetStorefront source code because it involves modifying the ASPDNSFGateways.dll library and making changes to the Checkout Payment pages.

The payment gateway process in ASPDotNetStorefront

An overview of the Consorzio Triveneto gateway process within ASPDNSF is shown to the right.

ASPDNSF Triveneto Payment gateway flow

It works in a slightly different way to a gateway like Worldpay, in that before you are taken to the Triveneto Payment screen, you need to send the gateway the payment details and you receive back the URL for making payment. The final step is also different in that you have to pass back a URL to Triveneto informing it which page to send the customer to (Error or Order Confirmation).

In addition to making changes to the gateway library and checkout payment pages, we created three new aspx pages specific to the Triveneto Gateway: trivenetoprocess, trivenetoerror and trivenetosuccess.

The basic approach in writing the gateway was:

Step 1 – Tell the ASPDotNetStorefront configuration wizard about your new gateway

The first step in creating a new gateway is to give it a unique identifier and update the ASPDotNetStorefront admin system’s configuration wizard so that it offers the new gateway as a configuration choice.

In our example, we used the identifier ‘TRIVENETO’ for our new gateway and edited the admin directory file wizard.aspx with a new line:

<asp:ListItem Value="TRIVENETO">Consorzio Triveneto</asp:ListItem>

Step 2 – Update the ASPDotNetStorefront Gateway library

Next, we modified the ASPSNDSF Gateway library to recognize ‘TRIVENETO’ as a valid gateway and added code in to receive information during a Make Payment request. If the order is successful, the gateway simply returns and the customer is sent to the order confirmation page. If unsuccessful, the gateway creates a record in the failed transactions table with the technical details of the failure and the customer is taken to the error page before returning to the shopping cart.

Step 3 – Update the Checkout payment page

The next stage is to update the checkout payment page so that it can send a payment request to the hosted payment page. This is a case of creating a form containing the payment elements (currency, language, amount, tracking id etc).

You will need to edit the source of checkoutpayment.aspx.cs and create a new if statement for your gateway. In our case, we created an ‘if {GW== Gateway.ro_GWTRIVENTO} …’ section.

Triveneto requires URLs to be passed for both error and standard response conditions. We created new AppConfig values for these and also added support for both Test and Live payment processing.

In our model, the checkout payment form sends the payment information to the new page called ‘trivenetoprocess.aspx’.

Step 4 – Capture the payment

trivenetoprocess.aspx takes the payment information received from checkoutpayment.aspx and creates a URL format specific to the Consorzio Triveneto gateway specification. This URL is then sent to the Live/Test payment URL which returns a unique Payment ID and Payment URL, or an Error message.

The Customer is then sent to the Payment URL to enter their credit card details.

Step 5 – Handle errors

If the Customer enters incorrect card details, Triveneto returns them to the error URL on your site, in our case, this is trivenetoerror.aspx. Trivenetoerror.aspx parses the error information and presents a description of the error to the Customer. The Customer then clicks on a link to be taken back to the shopping cart.

Step 6 – Handle payment processing

With correct card details, Triveneto will process the payment and return the Customer to the trivenetosuccess.aspx page. Despite the filename, the transaction may still have been rejected (such as due to an authorisation issue). This page checks the state of the payment and if successful, creates a new order record within ASPDotNetStorefront.

New payment gateways for ASPDotNetStorefront

If you would like to discuss development and installation of new or existing payment gateways for ASPDotNetStorefront, please contact us. Webopius have extensive experience in developing for ASPDotNetStorefront and always spend time understanding your business and requirements.

  • Tags