Recent

Author Topic: How to use the Elavon Converge Payment Gateway  (Read 16935 times)

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1090
  • Professional amateur ;-P
Re: How do I send a Request in PHP format?
« Reply #15 on: June 02, 2021, 03:35:13 am »
Hey RedOctober,

After what @PierceNg said I've added a button to send it with Content Type as application/x-www-form-urlencoded with variable xmldata.

From what @egsuh wrote, looks like it's the correct way and it just needs the correct values inputted.

I also realized that I had a typo on the root element's name, so I corrected that.

Have a go at this version, please.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

RedOctober

  • Sr. Member
  • ****
  • Posts: 450
Re: How do I send a Request in PHP format?
« Reply #16 on: June 02, 2021, 07:19:08 pm »
The tool is almost completely irrelevant. The issue is not the tool, but the proper format of the HTTP request to send to the server. This was pointed our earlier.

You also said "When I use simple Key=Value pairs in the request body, it works.  But when I use, what I call a "XML" style format in the body, it fails with a 'bad request'."

So, one has to ask, why change what works?

In this case, the tool has to be Lazarus and Free Pascal, and an HTTP component of some kind.  I don't want to use any other language (like Java, PHP, CURL, etc.)  I take your point though, that the Elavon server shd not care what tool was used to issue the request, as long as it is formatted properly and the correct Content-Type is selected.

As to "why change what works?"... the "working" call is only part of an .. at least... two step process.  And even the first, now "working" step is incomplete, and cannot allow the second step to proceed.  So, I have to "fix" the fist step, which.. doesn't work.  I have to hand more info in the first "Get Key" step, which is explained on the Elavon dev help web page... shown in a different format than the other "get key" example.  Elavon dev helps are not that helpful.  The examples are not cohesive.


Here is the logic trap:

Phase 1:  Can I simply get a key from Elavon?
Answer:  Yes, but not in the format explained on the Elavon dev help website.  I had to use Elavon's PostMan "Get Key" example, which is not in the same format at what is shown on the Elavon dev help website, and it doesn't allow any more info to be sent, other than a request for a key.

Phase 2:  I need to send much more info in the "Get Key" request sent to Elavon.
Answer:  I cannot send more info, in the format shown on the Elavon dev help website.  There is no Postman example of this.

Latest update from Elavon... (after my very lengthy email explaining all of this, their dev help (person or team) now understands what I am talking about, and is in the process of creating a PostMan example for me (and you all, once I post it up here).  I will, in the next few days, try out Gus's latest iteration of his Elavon client.

Thanks to all for your continued assistance.  We've been dealing with Elavon for many years and found them to be a great company to work with.  This is the first attempt at using their API.
« Last Edit: June 02, 2021, 07:29:01 pm by RedOctober »

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1090
  • Professional amateur ;-P
Re: How do I send a Request in PHP format?
« Reply #17 on: June 03, 2021, 01:11:10 pm »
Hey all,

This is a general appraisal, and a very biased one, of the Elavon thingamajig based on the information provided by Red October's recount of support interactions and the very limited Docs I read:
  • Their Web API has no basis on any standard present or past.
  • Their documentation sucks balls, hairy ones.
  • What they call an API I call a very bad catch up on technological debt.
  • I could continue but I think you get my point.

<End or rant/>

Cheers,
Gus

PS: I needed to vent this. I apologise for the NSFW language and attitude.
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

RedOctober

  • Sr. Member
  • ****
  • Posts: 450
Re: How do I send a Request in PHP format?
« Reply #18 on: June 03, 2021, 02:56:48 pm »
BHAW HAW Ha ha ha hah..  Gus says what we were all thinking. 

Aaanywaaaayyy.... If Elavon help can deliver me some working PostMan scripts... I will forgive them.

Hey all,

This is a general appraisal, and a very biased one, of the Elavon thingamajig based on the information provided by Red October's recount of support interactions and the very limited Docs I read:
  • Their Web API has no basis on any standard present or past.
  • Their documentation sucks balls, hairy ones.
  • What they call an API I call a very bad catch up on technological debt.
  • I could continue but I think you get my point.

<End or rant/>

Cheers,
Gus

PS: I needed to vent this. I apologise for the NSFW language and attitude.

RedOctober

  • Sr. Member
  • ****
  • Posts: 450
Re: How do I send a Request in PHP format?
« Reply #19 on: June 09, 2021, 09:21:37 pm »
Hi All.  I now have a working PostMan script that calls the Elavon server, supplies to the Elavon server all the info I need sent, then gets the generated token back from the Elavon server.  Now the problem I have is... translating the PostMan script to a TIdHTTP.Request.  I keep getting "Bad Request" using Gus's example .exe above.  Notice that there are THREE Content-Types involved.. Raw, XML and Form encoded.  I will attach a screen shot of the headers and body so you can see.  Here is the PostMan script I need translated. 

Error message I am getting:

[Debugger Exception Notification]

Project elavon_client raised exception class 'EIdHTTPProtocolException' with message:
HTTP/1.0 400 Bad Request

 In file 'Protocols\IdHTTP.pas' at line 2840:
raise EIdHTTPProtocolException.CreateError(LResponseCode, Response.ResponseText,


[Ignore this exception type]

[Break] [Continue]


Thanks for any help you can provide.

Code: Text  [Select][+][-]
  1. {
  2.         "info": {
  3.                 "_postman_id": "7981dc6b-d702-42e3-bd1f-1c33a458dd7b",
  4.                 "name": "ccSaleEmptyExample",
  5.                 "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  6.         },
  7.         "item": [
  8.                 {
  9.                         "name": "ccsale Copy",
  10.                         "request": {
  11.                                 "auth": {
  12.                                         "type": "noauth"
  13.                                 },
  14.                                 "method": "POST",
  15.                                 "header": [
  16.                                         {
  17.                                                 "key": "Content-Type",
  18.                                                 "name": "Content-Type",
  19.                                                 "value": "application/x-www-form-urlencoded",
  20.                                                 "type": "text"
  21.                                         },
  22.                                 ],
  23.                                 "body": {
  24.                                         "mode": "raw",
  25.                                         "raw": "xmldata=<txn>\n\t<ssl_merchant_id> withheld </ssl_merchant_id>\n\t<ssl_user_id> withheld </ssl_user_id>\n\t<ssl_pin> withheld </ssl_pin>\n\t<ssl_transaction_type>ccsale</ssl_transaction_type>\n\t<ssl_card_number>4000000000000002</ssl_card_number>\n\t<ssl_exp_date>1222</ssl_exp_date>\n\t<ssl_amount>1.00</ssl_amount>\n\t<ssl_cvv2cvc2_indicator>1</ssl_cvv2cvc2_indicator>\n\t<ssl_cvv2cvc2>123</ssl_cvv2cvc2>\n\t</txn>",
  26.                                         "options": {
  27.                                                 "raw": {
  28.                                                         "language": "xml"
  29.                                                 }
  30.                                         }
  31.                                 },
  32.                                 "url": {
  33.                                         "raw": "https://api.demo.convergepay.com/VirtualMerchantDemo/processxml.do",
  34.                                         "protocol": "https",
  35.                                         "host": [
  36.                                                 "api",
  37.                                                 "demo",
  38.                                                 "convergepay",
  39.                                                 "com"
  40.                                         ],
  41.                                         "path": [
  42.                                                 "VirtualMerchantDemo",
  43.                                                 "processxml.do"
  44.                                         ]
  45.                                 }
  46.                         },
  47.                         "response": []
  48.                 }
  49.         ]
  50. }
  51.  
« Last Edit: June 09, 2021, 11:32:22 pm by RedOctober »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: How to use the Elavon Converge Payment Gateway
« Reply #20 on: June 10, 2021, 06:35:20 am »
Debugging the request based on egsuh's post in reply #14, and reducing it to the minimum accepted version by the server:
Code: Text  [Select][+][-]
  1. POST /VirtualMerchantDemo/processxml.do HTTP/1.1
  2. Host: api.demo.convergepay.com
  3. Accept: application/xml
  4. Content-Type: application/x-www-form-urlencoded
  5. Content-Length: 347
  6.  
  7. <txn>
  8.   <ssl_merchant_id>my_merchant_id</ssl_merchant_id>
  9.   <ssl_user_id>my_user_id</ssl_user_id>
  10.   <ssl_pin>my_pin</ssl_pin>
  11.   <ssl_test_mode>false</ssl_test_mode>
  12.   <ssl_transaction_type>ccsale</ssl_transaction_type>
  13.   <ssl_card_number>000000000000000</ssl_card_number>
  14.   <ssl_exp_date>1215</ssl_exp_date>
  15.   <ssl_amount>1.00</ssl_amount>
  16. </txn>

It needs "Accept: application/xml" and "Content-Type: application/x-www-form-urlencoded". Changing the code in Gus' app in the "Send Raw" button to something along these lines:
Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.actFileSendRawExecute(Sender: TObject);
  2. ...
  3.     //http.Request.ContentType:='application/xml';
  4.     http.Request.ContentType:='application/x-www-form-urlencoded';
  5.     http.Request.Accept:='application/xml';
  6. ...

should make it work (did not test it).

The response from the server is:
Code: Text  [Select][+][-]
  1. HTTP/1.1 200 OK
  2. Server: Server
  3. X-Frame-Options: SAMEORIGIN
  4. Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
  5. Expires: 0
  6. Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  7. Pragma: no-cache
  8. X-Frame-Options: SAMEORIGIN
  9. AuthErrorNb: 4025
  10. Content-Security-Policy: frame-ancestors 'self'
  11. Content-Disposition: inline; filename=response.xml
  12. CPID: AD4-670d2032-7a93-4db0-a3fa-60f9b806b7b8
  13. Content-Type: text/xml
  14. AuthError: true
  15. Content-Length: 214
  16. Date: Thu, 10 Jun 2021 04:33:11 GMT
  17. Connection: keep-alive
  18. Set-Cookie: JSESSIONID=h5ugkZCNXopMZswRjexQOtEE1ZXO42nFlMdiKO2D.server; path=/VirtualMerchantDemo; secure; HttpOnly
  19. Debug-XFF-Seen-by-Edge: 206.189.xxx.xxx
  20. Client-IP-Seen-by-Edge: 206.189.xxx.xxx
  21.  
  22. <?xml version="1.0" encoding="UTF-8"?>
  23. <txn><errorCode>4025</errorCode><errorName>Invalid Credentials</errorName><errorMessage>The credentials supplied in the authorization request are invalid.</errorMessage></txn>

As you can see, "Invalid Credentials"

For similar problems you can use an online service like ReqBin to see request, response and headers.
« Last Edit: June 10, 2021, 06:45:45 am by engkin »

RedOctober

  • Sr. Member
  • ****
  • Posts: 450
Re: How to use the Elavon Converge Payment Gateway
« Reply #21 on: July 21, 2021, 04:46:15 pm »
I've found that Elavon is a good company to work with for credit card processing.  Their point of sale equipment and computer system is way more reliable than Moneris.  Moneris was complete garbage and left us stranded about once every two weeks. My first exposure to on-line payments was using PayPal's "buy now" buttons, which are really easy to use, self contained, and don't require any programming at all.  It took me only about 20 minutes to set up a Buy Now button.

I did not realize that by using PayPal first, the ease-of-use, convenience, and straight forwardness provided by PayPal, actually poisoned my mind when approaching Elavon's API.  I found using the Elavon API a month's long struggle, bc I kept thinking it shd be as easy as PayPal. That was the wrong attitude.

Eventually, I just gave up on the XML interaction with Elavon and used their GetToken and Hosted Payments Page  (HPP) combination which itself took weeks to decipher how to use. 

I was about to try Square, but just at that moment, I got the Elavon HPP working so I did not pursue the Square attempt any further.  This may not answer your question, but maybe gives you a bit of insight and preparation if you want to use Elavon.

The reason I started with Elavon is bc our company already uses them as a CC processing company, so it simplifies our accounting processes to use the same company.


« Last Edit: July 26, 2021, 10:39:29 pm by RedOctober »

 

TinyPortal © 2005-2018