1. Go to this page and download the library: Download datingvip/payon-xml-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
datingvip / payon-xml-api example snippets
use DatingVIP\Payment\PayOn\TransactionParams;
use DatingVIP\Payment\PayOn\QueryParams;
use DatingVIP\Payment\PayOn\XmlApi;
// config - replace to your values
$config = [
'sender' => 'PAYON_SERVER_ID',
'channel' => 'PAYON_CHANNEL',
'userid' => 'PAYON_USER_ID',
'password' => 'PAYON_PASSWORD'
];
// init api class
$po_api = new XmlApi(
$config['sender'],
$config['channel'],
$config['userid'],
$config['password'],
true );
// init and build transaction params
$po_req = new TransactionParams();
// register user for CC payment
$po_req->setAccountNumber('4111111111111111');
$po_req->setAccountExpYear('2015');
$po_req->setAccountExpMonth('12');
$po_req->setAccountHolder('John Smith');
$po_req->setAccountVerif('123');
$po_req->setCustNameFamily('Smith');
$po_req->setCustNameGiven('John');
$po_req->setCustAddrZip('12345');
$po_req->setCustAddrStreet('Main Street');
$po_req->setCustAddrCountry('US');
$po_req->setCustAddrCity('New York');
$po_req->setCustAddrState('New York');
$po_req->setCustContIp($_SERVER['REMOTE_ADDR']);
$po_req->setCustContEmail('[email protected]');
$po_req->setAccountBrand('VISA');
$po_req->setPaymentMethod('CC.RG');
// execute request
$res = $po_api->executeTransaction($po_req);
if (empty($res)) // probably curl/communication error
{
die('Communication error!');
}
if (!$po_api->wasTranSuccessful()) // unsuccessful reginstration
{
$response = $po_api->getTranResponseData();
die('ERROR: ' . $response['return_code'] . ' : ' . $response['return_msg']);
}
// display
displayReqResp($po_api, 'Registration');
// get registration UID for future use
$reg_uid = $po_api->getTranResponseData('unique_id');
// build params for charging the account
$po_req = new TransactionParams();
$po_req->setPaymentAmount('1.23');
$po_req->setPaymentCurrency('USD');
$po_req->setPaymentUsage('INV-TEST-' . time());
$po_req->setShopperId('CUST-' . time());
$po_req->setInvoiceId('INV-TEST-' . time());
$po_req->setPaymentMethod('CC.DB');
$po_req->setAccountRegId($reg_uid);
$po_req->setRecurrenceMode(Xml_Api::RECURRENCE_INIT);
// charge it
$res = $po_api->executeTransaction($po_req);
if (empty($res)) // probably curl/communication error
{
die('Communication error!');
}
if (!$po_api->wasTranSuccessful()) // unsuccessful registration
{
$response = $po_api->getTranResponseData();
die('ERROR: ' . $response['return_code'] . ' : ' . $response['return_msg']);
}
// display
displayReqResp($po_api, 'Initial Charge');