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.”
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.
Doug,
Have you made any customization to the existing code?
Thanks
Deepu
I only added my credentials for my demo account
Can you debug PaymentService class see what you are getting exception?
https://github.com/deepumi/FirstDataPaymentGateway-CSharp.Net/blob/master/FirstDataPaymentSample/Api/PaymentService.cs
Check either you should get a RESPONSE Xml string (line no : 106 in the above file) or put a debugger in exception block (line no : 117 in the above file).
Let me know if that helps
Thank you for the response 🙂
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:
>
Deepu,
Thanks again for your help,
Now I am getting Invalid signature received ‘WeXXO4############’.
The signature changes on refresh.
You are welcome,
Glad that you have found the issue.
Hi Deepu,
Everything working great but I was wondering if the status returned was not OK how would you pass the detail of the failure to the view?
Thanks,
Doug
Dough,
Firstdata will return the httpstatus code as CREATED. We can check only the same. Can’t help.
Deepu,
I am new to treading and wonder if you could tell me how to post my form data to this task. Please refer to this to see what I have tried.
http://stackoverflow.com/questions/23257771/passing-input-text-from-view-to-contoller-with-facebookcontext-using-facebook-ap
Thanks,
Doug
Deepu,
I figured it out.
Thanks for the code,
Doug
Thank you.
Hi folks,
I would recommend checking out my project on GitHub, it’s much further along:
https://github.com/clifton-io/Clifton.Payment
Pull requests and feedback extremely welcome
Thanks
Brian
hi,
How do i get the keys what you mentioned in the web.config.
Below you can find support links.
https://support.payeezy.com/hc/en-us
https://demo.globalgatewaye4.firstdata.com/?lang=en
https://www.firstdata.com/en_us/home.html
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.
and what i have to give value for tansaction type
thanks
Vanaja
transaction type is default value in the config (Zero)
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
Hi, I am new to Payeezy. Can you please tell me the steps to use and implement it in .NET
You should check here to get a better understanding how the API works. https://support.payeezy.com/hc/en-us