Skip to content

Instantly share code, notes, and snippets.

@courtesysoft
Created April 6, 2023 21:07
Show Gist options
  • Save courtesysoft/5319ab0d66b75db336b21e2b92ac2026 to your computer and use it in GitHub Desktop.
Save courtesysoft/5319ab0d66b75db336b21e2b92ac2026 to your computer and use it in GitHub Desktop.
Communicate to Elavon Converge XML API using raw PHP
//This should successfully connect to Elavon's Converge system using the XML api, as of 04/05/2023
//As of today, this isn't documented in: https://developer.elavon.com/na/docs/converge/1.0.0/integration-guide/integration_methods/xmlapi
//Please give this a star on github if i saved you a headache!
$postData = [];
$postData['ssl_merchant_id'] = "";
$postData['ssl_user_id'] = "";
$postData['ssl_pin'] = "";
$postData['ssl_transaction_type'] = "ccsale";
$postData['ssl_amount'] = "1.00";
$postData['ssl_description'] = "test payment";
$postData['ssl_card_present'] = "N";
$postData['ssl_cvv2cvc2_indicator'] = 1; //say the CCV is present
$postData['ssl_card_number'] = "4000000000000002";
$postData['ssl_exp_date'] = "0324";
$postData['ssl_cvv2cvc2'] = "123"
$postData['ssl_avs_address'] = "";
$postData['ssl_avs_zip'] = "";
$postData['ssl_first_name'] = "";
$postData['ssl_last_name'] = "";
$postData['ssl_email'] = "";
$postData['ssl_phone'] = "";
$postData['ssl_company'] = "";
$postData['ssl_cardholder_ip'] = $_SERVER['REMOTE_ADDR'];
//because simpleXML is actually more code, let's do it the short way:
$xmlOut = '<txn>' . "\n";
foreach($postData as $k => $v) { $xmlOut .= " <" . $k . ">" . urlencode($v) . '</' . $k . '>' ."\n"; }
$xmlOut .= '</txn>';
//raw curl
$CS = curl_init('https://api.demo.convergepay.com/VirtualMerchantDemo/processxml.do');
$curlOptions =
[
CURLOPT_CONNECTTIMEOUT => 5, //Time to complete initial handshakes, etc.
CURLOPT_TIMEOUT => 30, //Total amount of time allowed for a CURL call.
CURLOPT_RETURNTRANSFER => 1, //Don't print stuff to screen!
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => "xmldata=" . $xmlOut,
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded']
];
curl_setopt_array($CS, $curlOptions);
//return the transfer as a string
$html = curl_exec($CS);
$curlData = curl_getinfo($CS);
$curlError = curl_error($CS);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment