Forum > Networking and Web Programming

How to use the Elavon Converge Payment Gateway

(1/5) > >>

RedOctober:
Platform:  Lazarus 2.0.10, FPC 3.2.0, Brook 5 Framework 5.4.9,  Microsoft Server 2016

I am trying to send a token request to the Elavon Converge server.  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".   The Elavon Converge help cannot understand what is wrong, but they said I shd be using PHP.  How do I send a Request body with the "XML" style formatting, in PHP?

Here is what I'm trying to emulate.  I have all the correct authorization numbers:  (All examples are in the "XML" sytle)

https://developer.elavon.com/na/docs/converge/1.0.0/integration-guide/transaction_types/credit_card/sale


Here is what works, I can get a token from Elavon using this formatting in the body:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ssl_merchant_id=(withheld)ssl_user_id=(withheld)ssl_pin=(withheld)ssl_transaction_type=ccsale 
When I use the following XML style format, shown below, it fails with a "bad request"


--- Code: XML  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---<ssl_merchant_id>(withheld)</ssl_merchant_id><ssl_user_id>(withheld)</ssl_user_id><ssl_pin>(withheld)</ssl_pin><ssl_transaction_type>ccsale</ssl_transaction_type> 

Here are my TIdHTTP component settings:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    xHandler.SSLOptions.SSLVersions := [sslvTLSv1_2];     xHTTP.AllowCookies := True;    xHTTP.Request.BasicAuthentication := False;     xHTTP.Request.ContentType := 'application/x-www-form-urlencoded';  //  <-- This ContentType is required by Elavon, shd it be different for PHP (XML style) content?    xHTTP.Request.Accept := '*/*';     xHTTP.HTTPOptions := xHTTP.HTTPOptions + [hoForceEncodeParams, hoKeepOrigProtocol];    xHTTP.ProtocolVersion := pv1_1;
Thanks in advance for any help you can provide.

[Edited to fix title]

lucamar:
It has nothing to do, I think, with the language you use; the point is that you must send an HTTP request in the format expected by the server, whether your program is in PHP, Pascal, or whatever.

Of course, the request message must be correct HTTP, so if you're sending an XML document you can't tell the server your request is "form-URL-encoded", because it isn't.

What I don't know off the top of my head is what type you should use for XML, sorry :-[

Maybe they can tell it to you? Or it they have some kind of "integration" library, check it and see how they are doing it ...

sstvmaster:
Maybe:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---xHTTP.Request.ContentType := 'application/xml; charset="utf-8"'; 

Gustavo 'Gus' Carreno:
Hi RedOctober,

First of all, can I ask you to make sense of the mess that you got yourself into, please?

Lemme ask you some questions and maybe we can get this sorted out:

First of all, if you have it working with form encoded, why are you trying to do it another way?

Second would be, why are you trying to send XML when you declare that you're sending form encoded?

And third, why are you sending badly formed XML and expecting any positive results?

If you can answer me some of these questions maybe we can help you progress further.

Cheers,
Gus

RedOctober:
Hi Gus, yes, you may ask.  Here are the answers:

Background:

My goal is to use Elavon's Hosted Payments Page (HPP) to take payments from customers on-line.  They give instructions how to do that in the following links.  All of which I am told, are PHP or CURL examples.  They don't support Lazarus, Indy components, Free Pascal etc. (I must be the first to attempt this) So when ever I ask Elavon developer help a question, I'm just a pain in their ass and they usually give me a terse answer just to get rid of me.  That is why I am turning to this forum for help.

https://developer.elavon.com/na/docs/converge/1.0.0/integration-guide/transaction_types/credit_card/sale
https://developer.elavon.com/na/docs/converge/1.0.0/integration-guide/integration_methods/hosted_payments
https://developer.elavon.com/na/docs/converge/1.0.0/test-cards
https://developer.elavon.com/na/docs/converge/1.0.0/overview

The first step, is to obtain a token from a "get token" URL, then, I'm to use that token in a redirect of the customer's browser to a different URL. 
I was able to obtain a token, after many weeks of frustration, using Postman as an intermediary tool. 

Just obtaining a token and redirecting, ends up sending the customer to a blank Hosted Payments Page, where the customer is able to enter their own product description, (even though they will be choosing a product from my website, which clearly has a description), what ever price they want (even zero), and fill in what ever tax they want, even zero, then click the pay button.

To have "un-editable" fields in the Hosted Payments Page, I was told that I have to pass all product information, in the initial "get token" request, then, when the customer is redirected, the Hosted Payments Page will be populated with all that info (supposedly, I haven't got that far yet).  The format that you have to send the product info info in, in the initial "get token" request,  is shown at the bottom of this page:

https://developer.elavon.com/na/docs/converge/1.0.0/integration-guide/transaction_types/credit_card/sale

You see that the format is not form encoded key,value pairs.  It looks like XML, but it's not that either.

I think the easiest way to solve this, is if an experienced TIdHTTP programmer wd obtain a developer account with Elavon and tinker with it.  I'm very close to being a beginner with TIdHTTP, even though I've built API interfaces for RingCentral and Data 24/7 and CDYNE.  PayPal "buy now" buttons are a breeze compared to Elavon.

So, to answer your questions specifically:


--- Quote ---First of all, if you have it working with form encoded, why are you trying to do it another way?
--- End quote ---

Because the Elavon dev help personel and Elavon examples require two different formats for data submission.  I can get one to work (get token), the other I can't (submit product info).


--- Quote ---Second would be, why are you trying to send XML when you declare that you're sending form encoded?
--- End quote ---
and

--- Quote ---And third, why are you sending badly formed XML and expecting any positive results?
--- End quote ---

Bc I'm a dum-ass beginner throwing myself at the mercy of Lazarus gurus for help.

I was also told to send the body in Raw format, what ever that is. So, again, form-encoded versus (something else).  The Elavon help group is of no help to us Lazarus devs.

Thanks for any help you can provide Gus.

Navigation

[0] Message Index

[#] Next page

Go to full version