First Data Global Gateway Integration in Asp.Net MVC C#


I have added a new Github repository for First Data Global Gateway Integration in Asp.Net MVC.  The sample provides a rest api implementation for credit card based payment processing. Since, I have choosen Asp.Net MVC empty project template you might need to install System.Net.HttpClient library from nuget.org or install directly from visual studio.

Command – Install-Package Microsoft.Net.Http

Download Location or copy paste the url

https://github.com/deepumi/FirstDataPaymentGateway-CSharp.Net

This code was taken from the original source https://support.payeezy.com/hc/en-us/articles/204699865-C-REST-Sample-Code-For-Use-with-v12-v13

Example Usage:

 var paymentService = new PaymentService("1.50", "0515","Card holder name","4111111111111111", "23".ToString()); //customer Id for Internal purpose to track which customer made the transaction...
 var transactionResult = await paymenetService.PostAsync();
 if (transactionResult == null) return;
 if (transactionResult.TransactionApproved && !transactionResult.TransactionError && transactionResult.CustomerRef == customerId.ToString())
 {
 //transaction success....
 }
 else
 {
 //transaction failed
 var message = transactionResult.Message;
 }

Configuration Settings:
Following values needs to be changed in the web.config file.

<add key="GATEWAY_ID" value="Exact ID" />
<add key="GATEWAY_PWD" value="Password" />
<add key="TRANS_TYPE" value="00" />
<add key="HMAC_KEY" value="HMAC Key" />
<add key="KEY_ID" value="Key Id" />
<add key="GATEWAY_URL" value="https://api.demo.globalgatewaye4.firstdata.com" />

Transaction Summary file(transaction_summary.xml) from payment gateway is included in the App_Data folder.

Also, refer : https://support.payeezy.com/hc/en-us/articles/203731109-First-Data-Global-Gateway-e4-Web-Service-API-Reference-Guide

As per First Data knowledge base Note: “Code samples are provided “as is” and are not designed to be used in production.”

 

24 thoughts on “First Data Global Gateway Integration in Asp.Net MVC C#

  1. I am trying to integrate your code but I am getting a null transaction result and no other error messages to go on. Please let me know if you can help.

      • Deepu,

        I attempted to log the exception with:

        catch (Exception ex)
        {
        string filePath = @”E:\Errors\Error.txt”;

        using (StreamWriter writer = new StreamWriter(filePath, true))
        {
        writer.WriteLine(“Message :” + ex.Message + “” + Environment.NewLine + “StackTrace :” + ex.StackTrace +
        “” + Environment.NewLine + “Date :” + DateTime.Now.ToString());
        writer.WriteLine(Environment.NewLine + “—————————————————————————–” + Environment.NewLine);
        }

        }

        This does not create a file but i did put the following in the Homecontroller

        if (transactionResult == null)
        {
        ViewBag.Message = “Null Result”;
        return View();
        }
        And Null Result displays in the view.

        Thanks,
        Doug

      • Doug,

        Can you see what is the value return in the out put variable *responseXml line no L 103 * ( https://github.com/deepumi/FirstDataPaymentGateway-CSharp.Net/blob/master/FirstDataPaymentSample/Api/PaymentService.cs )

        *Also, Change the below line and see what you are getting in **responseXml variable*

        * From *

        using (var response = await client.SendAsync(request).ConfigureAwait(false)) { if (response.StatusCode == System.Net.HttpStatusCode.Created || response.StatusCode == System.Net.HttpStatusCode.OK) responseXml = await response.Content.ReadAsStringAsync().ConfigureAwait(false); else

        LogStatusCode(response.StatusCode.ToString()); }

        To

        using (var response = await client.SendAsync(request).ConfigureAwait(false)) {

        *responseXml *= await response.Content.ReadAsStringAsync().ConfigureAwait(false);

        }

        HTH Deepu

        On Tue, Jul 14, 2015 at 3:35 PM, Deepu MI's Blog wrote:

        >

  2. Deepu,

    Thanks again for your help,

    Now I am getting Invalid signature received ‘WeXXO4############’.

    The signature changes on refresh.

  3. Hi,

    Thanks for your reply. I got the keys from Payeezy, but when i am running the app with test account always getting “transactionresult” as null. Do i need to change anything in the code.
    And one more thing, is customerId gave by user is mandatory.

    Thanks
    Vanaja

    • If you are getting transaction result is null, you should debug and see what error you are getting. I have already mentioned in comment section for some one asking the same issue.

  4. Hi Deepu,

    I found the error as “StatusCode: 401, ReasonPhrase: ‘Unauthorized'”, i understand the reason is certificate has to be installed.Can you please provide me the guiding link for certificate installastion for Firstdata api.

    Thanks&Regards,
    Vanaja.M

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s