2015-06-11

Sage Pay is one of the leading payment gateways in the UK market. To offer more flexibility, it’s available in two integration forms, which are called “Form integration” and “Server Integration.” Both are PCI compliant.

This blog post will help Microsoft.NET developers to integrate the Sage Pay payment gateway (protocol v3.0) along with some of the integration problems and solutions that will be helpful in quickly integrating. Using the steps below, the developer can integrate iFrame solution of Server integration in their website though utilizing “SagePay.IntegrationKit.DotNet.dll” published by Sage Pay.

Sage Pay Server Integration talks directly to a client web server through an encrypted channel, exchanging digitally signed messages to register the transaction and notify about the authorisation result. No sensitive information is sent through the browser and the customer is redirected to Sage Pay to enter card details, etc. Therefore, the client website does not need to store these sensitive details.

Pre-requisites

The client website should be running on IIS with a fully qualified domain name or on a URL which is externally resolvable so that Sage Pay APIs will be able to send/receive requests to/from client. The client website will be either running on Port 80 in case of HTTP protocol or on 443 in case of HTTPS protocol.

It is recommended that the client website use the HTTPS protocol in LIVE environment.

You will need to have a Sage Pay test account to log in into the test website (https://test.sagepay.com/mysagepay/login.msp), and review the test transactions.

Steps to integrate Sage Pay using the ‘Dot Net Integration Kit’:

Download and add reference of “SagePayLib” class library project in your web project. To download the class library project click here

Add iFrame control on the .aspx page (as below), on which it is required to load Sage Pay iFrame

Copy and paste the following method in .aspx.vb page and call it to load Sage Pay iFrame content to render

Add new “SagePayNotification.aspx” page, then copy and paste the following code in code behind (replace Page_Load event code with following code)

Add new “SagePayResult.aspx” page, copy and paste the following code in code behind (replace Page_Load event code with following code)

Web.config changes

Add new “SagePayConfiguration” ConfigSection (register it through adding following line of code under ‘configuration -> configSections’ section)

Copy & paste below code within ‘Configuration’

Quick Implementation Points:

Update the value of “sagepay.api.env” key to “LIVE” if running on live environment, or to “TEST” if running in test environment

Assign valid vendor name to the value of “sagepay.kit.vendorName” key

In case of test environment, assign valid fully qualified domain name of your server to the value of “sagepay.kit.siteFqdn.TEST” key

In case of test environment assign valid fully qualified domain name of your server to the value of “sagepay.kit.siteFqdn.LIVE” key

Add the IP of the server on which the websites need to be hosted to the Valid IPs section in the Sage Pay vendor account so that Sage Pay will provide a response to the server properly

While posting the data, the details should contain the valid values and data should match the following format:

Name

Mandatory

Max Length

Description

First Names

Yes

20 Chars

Surname

Yes

20 Chars

Address 1

Yes

100 Chars

Address 2

No

100 Chars

City

Yes

40 Chars

Post Code

Yes

10 Chars

The Billing Post Code can be blank for countries that do not have postcodes (e. g. Ireland) but is required in all countries that do have them.The Post Code value can contain alphabets, numbers, hyphens, and spaces.

Country

Yes

2 Chars

State

No

2 Chars

The Billing State becomes mandatory when the Billing Country is set to US.

Phone

No

20 Chars

Email

No

255 Chars

Amount

Yes

Amount for the transaction should contain 2 decimal places where appropriate (e. g. 5.10 or 3.29. Values such as 3.235 will be rejected).Minimum for no minor unit currencies like JPY is 1.Amounts must be in the UK currency format. The period must be used to indicate the decimal place. The comma must only be used to separate groups of thousands.

The following screenshot shows the content of Sage Pay iFrame on successful transaction registration



References:

http://www.sagepay.co.uk/

The post Sage Pay Server Integration using Microsoft.NET appeared first on 3Pillar Global.

Show more