I am trying to create a custom payment provider for PaymentSense. It is proving a little tricky. I have done a (very rough) sequence diagram of how the transaction process is working, you can see it below.
The Payment Provider is able to send the correct information to the PaymentSense server, but when the details are filled in the callback fails and I get the email below (see variables from the various steps of the post as well).
*** PLEASE READ THIS EMAIL *CAREFULLY* AND *COMPLETELY* - IT CONTAINS IMPORTANT INFORMATION FOR BOTH THE MERCHANT AND THE DEVELOPER ***
Hello,
You are receiving this email as an error occurred whilst processing a payment using our hosted payment form solution. We were unable to successfully deliver the transaction result to your system. This could have been caused by a network problem (e.g. a connection timeout), or an error occurring on your ServerResultURL page. Please see the end of this email for more details about this error.
As this error happened after the transaction was processed, we suppressed it from the customer, and displayed the transaction result to them on our system.
We recommend that you log into the MMS (https://mms.paymentsensegateway.com) and verify the result against our record of the transaction in the transaction history page.
Your sequence diagram is partly correct - BUT almost all payment providers work differently so I cant make a diagram that fits all. Normally the payment provider generates a form with data to post to the payment gateway and also gives the url that the form is posted to (normally a url for the payment gateway). Remember when you generate the form and it input field valaues that you use the teaCommerceContinueUrl, cancel url and callback url if you need to send them to the gateway. These are parameters for the GeneratePaymentForm method.
Now your client browser is redirected to the payment gateway and enters creditcard info etc. Now the tricky part happens because most gateways is different. Normally you have passed a continue, cancel and callback url to the gateway through the form post. When the gateway has validated the credit card and it was a success it will redirect the client to the continue url (which should be a teaCommerceContinueUrl). This moves the order in the session and then Tea Commerce asks your provider for the real continue url of the shop and the client is redirected to the confirmation step and can print the order etc. If it is cancelled it will redirect to the teaCommerceCancelUrl and then your providers real cancel url.
Behind the screen the gateway makes a server to server call to the callback url. This callback should be a teaCommerceCallbackUrl and this makes the correct finalize of the order and send email confirmation etc. Because this is server to server this should ALWAYS be on a live server with a public DNS record. This call is hard to debug - so what I normally do is to create a file as the first thing in the provider and write either the query string or the form key/values to the file (depends on how the data is send from the gateway. This gives you an idea of what data is returned to you. Now create you logic to validate the callback info and when you have done that return a CllbackInfo object with the order data. This is used to finalize the order.
Sometimes the gateway doesnt support callback. If that is the case you can normally just override the FinalizeAtContinueUrl in your provider. This makes Tea Commerce fake a callback at the continue url before the client is redirected to the real continue page.
I hope this gives you an idea of what happens in the GeneratePaymentForm, the continue/cancel url and in the callback method of your provider. The rest of the methods are for the Tea Commerce backend where the shop owner can capture/get status/cancel and refund the payment if they want to. If you providers doesnt support that you can just override the settings for your provider to tell Tea Commerce that it doesnt support these methods.
Thanks for the help Anders, I will run through this again this evening it sounds like I need to oevrride FinalizeAtContinueUrl, I will give it a go and let you know how I get on.
Custom Payment Provider Issue (PaymentSene)
I am trying to create a custom payment provider for PaymentSense. It is proving a little tricky. I have done a (very rough) sequence diagram of how the transaction process is working, you can see it below.
The Payment Provider is able to send the correct information to the PaymentSense server, but when the details are filled in the callback fails and I get the email below (see variables from the various steps of the post as well).
Can anyone help please?
Variables
------------------------------------------------
GENERATE FORM
ServerResultURL = teaCommerceContinueURL = "http://tuhdoo.com/tcbase/teacommerce/PaymentContinue/PaymentSense/CD14C1575E9ECFB34183AE22FE74C508.aspx"
StringToHash =
"PreSharedKey=ECiuyl2GSQWu/PqRiczHF0s=&
MerchantID=TESTGu-3738331&
Password=23Z7420S05&
Amount=24430&
CurrencyCode=826&
OrderID=102&
TransactionType=SALE&
TransactionDateTime=2013-02-12 01:03:53 +00:00&
CallbackURL=http://tuhdoo.com/tcbase/teacommerce/PaymentCallback/PaymentSense/CD14C1575E9ECFB34183AE22FE74C508.aspx&
OrderDescription=ORDER102&
CustomerName=John Watson&
Address1=32 Edward Street&
Address2=&
Address3=&
Address4=&
City=Camborne&
State=&
PostCode=TR14 8PA&
CountryCode=826&
CV2Mandatory=True&
Address1Mandatory=False&
CityMandatory=False&
PostCodeMandatory=False&
StateMandatory=False&
CountryMandatory=False&
ResultDeliveryMethod=SERVER&
ServerResultURL=http://tuhdoo.com/tcbase/teacommerce/PaymentContinue/PaymentSense/CD14C1575E9ECFB34183AE22FE74C508.aspx&
PaymentFormDisplaysResult=False&
ServerResultURLCookieVariables=&
ServerResultURLFormVariables=&
ServerResultURLQueryStringVariables="
FormPOstUrl = "https://mms.paymentsensegateway.com/Pages/PublicPages/PaymentForm.aspx"
GetContinueURL = "http://www.tuhdoo.com/cart/payment/"
------------------------------------------------
*** PLEASE READ THIS EMAIL *CAREFULLY* AND *COMPLETELY* - IT CONTAINS IMPORTANT INFORMATION FOR BOTH THE MERCHANT AND THE DEVELOPER ***
Hello,
You are receiving this email as an error occurred whilst processing a payment using our hosted payment form solution. We were unable to successfully deliver the transaction result to your system. This could have been caused by a network problem (e.g. a connection timeout), or an error occurring on your ServerResultURL page. Please see the end of this email for more details about this error.
As this error happened after the transaction was processed, we suppressed it from the customer, and displayed the transaction result to them on our system.
Here is the result of this transaction:
StatusCode: 0
Message: AuthCode: 365626
CrossReference: 130212010912541802416051
OrderID: 102
Amount : 244.30 GBP
We recommend that you log into the MMS (https://mms.paymentsensegateway.com) and verify the result against our record of the transaction in the transaction history page.
Thank You,
PaymentSense
-------------------------------------------------------
Additional detailed information relating to this error:
Response from ServerResultURL:
----RECEIVED RESPONSE BEGIN----
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- META TAGS -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="AUTHOR" content="Gumpshen" /><meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" /><title>Payment</title><!-- ICONS --><link rel="shortcut icon" href="" type="image/x-icon" /><link rel="apple-touch-icon-precomposed" href="" /><link rel="apple-touch-icon-precomposed" sizes="72x72" href="" /><link rel="apple-touch-icon-precomposed" sizes="114x114" href="" />
<!-- STYLESHEETS -->
<link rel="stylesheet" type="text/css" href="/css/default.css" media="screen, print" /><link rel="stylesheet" type="text/css" href="/css/ecommerce.css" media="screen, print" /><link rel="stylesheet" type="text/css" href="/css/print.css" media="print" />
Hi Brendan Rice
Your sequence diagram is partly correct - BUT almost all payment providers work differently so I cant make a diagram that fits all. Normally the payment provider generates a form with data to post to the payment gateway and also gives the url that the form is posted to (normally a url for the payment gateway). Remember when you generate the form and it input field valaues that you use the teaCommerceContinueUrl, cancel url and callback url if you need to send them to the gateway. These are parameters for the GeneratePaymentForm method.
Now your client browser is redirected to the payment gateway and enters creditcard info etc. Now the tricky part happens because most gateways is different. Normally you have passed a continue, cancel and callback url to the gateway through the form post. When the gateway has validated the credit card and it was a success it will redirect the client to the continue url (which should be a teaCommerceContinueUrl). This moves the order in the session and then Tea Commerce asks your provider for the real continue url of the shop and the client is redirected to the confirmation step and can print the order etc. If it is cancelled it will redirect to the teaCommerceCancelUrl and then your providers real cancel url.
Behind the screen the gateway makes a server to server call to the callback url. This callback should be a teaCommerceCallbackUrl and this makes the correct finalize of the order and send email confirmation etc. Because this is server to server this should ALWAYS be on a live server with a public DNS record. This call is hard to debug - so what I normally do is to create a file as the first thing in the provider and write either the query string or the form key/values to the file (depends on how the data is send from the gateway. This gives you an idea of what data is returned to you. Now create you logic to validate the callback info and when you have done that return a CllbackInfo object with the order data. This is used to finalize the order.
Sometimes the gateway doesnt support callback. If that is the case you can normally just override the FinalizeAtContinueUrl in your provider. This makes Tea Commerce fake a callback at the continue url before the client is redirected to the real continue page.
I hope this gives you an idea of what happens in the GeneratePaymentForm, the continue/cancel url and in the callback method of your provider. The rest of the methods are for the Tea Commerce backend where the shop owner can capture/get status/cancel and refund the payment if they want to. If you providers doesnt support that you can just override the settings for your provider to tell Tea Commerce that it doesnt support these methods.
Kind regards
Anders
Thanks for the help Anders, I will run through this again this evening it sounds like I need to oevrride FinalizeAtContinueUrl, I will give it a go and let you know how I get on.
is working on a reply...