1. Go to this page and download the library: Download atlpay/php-sdk-v2 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/ */
atlpay / php-sdk-v2 example snippets
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$token = new \ATLPay\Token();
$token->createToken('5555 5555 5555 4444', 12, 2020, '009', 'CARD_HOLDER_NAME' '192.168.1.1', 'USER SESSION ID', '[email protected]');
if($token->isError()){
//Error Happened
}else{
// Everything went well
}
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$token = new \ATLPay\Token('5555 5555 5555 4444', 12, 2020, '009', '192.168.1.1', 'USER SESSION ID', '[email protected]');
$token->createToken();
if($token->isError()){
if(in_array($token->httpCode, [500, 502, 503, 504])){
die("Something went wrong on ATLPay's end. (These are rare.)");
}else if($token->httpCode == 400){
if(isset($token->param) && $token->param == "card.name"){
die("Problem with Cardholder's name : (".$token->code.") ".$token->message);
}else if(isset($token->param) && $token->param == "card.number"){
die("Problem with Card Number : (".$token->code.") ".$token->message);
}else if(isset($token->param) && $token->param == "card.exp_month"){
die("Problem with Card Expiry Month : (".$token->code.") ".$token->message);
}else if(isset($token->param) && $token->param == "card.exp_year"){
die("Problem with Card Expiry Year : (".$token->code.") ".$token->message);
}else if(isset($token->param) && $token->param == "card.cvc"){
die("Problem with Card CVC : (".$token->code.") ".$token->message);
}else if(isset($token->param) && $token->param == "shopper.ip"){
die("Problem with Shopper IP Address : (".$token->code.") ".$token->message);
}else if(isset($token->param) && $token->param == "shopper.session_id"){
die("Problem with Shopper Session ID : (".$token->code.") ".$token->message);
}else if(isset($token->param) && $token->param == "shopper.email"){
die("Problem with Shopper E-Mail : (".$token->code.") ".$token->message);
}else{
die("Problem : ".$token->message);
}
}else if($token->httpCode == 401){
die("Check your API Key");
}else if($token->httpCode == 402){
die("You may encounter this error if you're not using TLS_1_2");
}else if($token->httpCode == 403){
die("Check your API Key");
}
//Since we are creating token, this request shall not be ended httpCode 404 i.e. Not Found
}else{
$tokenId = $token->getId();
$cardBrand = $token->getCardBrand();
$cardIssuerCountry = $token->getCardCountry();
$cardFundingType = $token->getFundingType();
$cardLast4 = $token->getLast4Digits();
$threeDRedirectStatus = $token->getRedirectStatus();
$transactionMode = $token->getMode();
// See Model/TokenModel.php for more Getter Methods
}
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$token = new \ATLPay\Token();
$token->getToken($tokenId);
if($token->isError()){
if(in_array($token->httpCode, [500, 502, 503, 504])){
die("Something went wrong on ATLPay's end. (These are rare.)");
}else if($token->httpCode == 400){
die($token->message);
}else if($token->httpCode == 401){
die("Check your API Key");
}else if($token->httpCode == 402){
die("You may encounter this error if you're not using TLS_1_2");
}else if($token->httpCode == 403){
die("Check your API Key");
}else if($token->httpCode == 404){
die("Token Not Found.");
}
//Since we are retrieving token, this request shall not be ended httpCode 402 i.e. BAD_REQUEST
}else{
$tokenId = $token->getId();
$cardBrand = $token->getCardBrand();
$cardIssuerCountry = $token->getCardCountry();
$cardFundingType = $token->getFundingType();
$cardLast4 = $token->getLast4Digits();
$threeDRedirectStatus = $token->getRedirectStatus();
$transactionMode = $token->getMode();
// See Model/TokenModel.php for more Getter Methods
}
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$charge = new \ATLPay\Charge(ATLPAY_TOKEN_ID, 50.00, EUR, ORDER_NUMBER, ORDER_DESCRIPTION, 'https://www.your-return-url.com');
//Here https://www.your-return-url.com is used as placeholder replace it with your url.
//After 3D Authorization is completed User will be redirected back this url and you can proceed with
//capturing or cancelling the charge. Refer to Handling 3DS or 3-D Security for more details
$charge->initialize();
if($charge->isError()){
if(in_array($charge->httpCode, [500, 502, 503, 504])){
die("Something went wrong on ATLPay's end. (These are rare.)");
}else if($charge->httpCode == 400){
if(isset($charge->param) && $charge->param == "amount"){
die("Problem with Charge Amount : (".$charge->code.") ".$charge->message);
}else if(isset($charge->param) && $charge->param == "currency"){
die("Problem with Charge Currency : (".$charge->code.") ".$charge->message);
}else if(isset($charge->param) && $charge->param == "description"){
die("Problem with Charge Description : (".$charge->code.") ".$charge->message);
}else if(isset($charge->param) && $charge->param == "return_url"){
die("Problem with Return URL : (".$charge->code.") ".$charge->message);
}else{
die("Problem : ".$charge->message);
}
}else if($charge->httpCode == 401){
die("Check your API Key");
}else if($charge->httpCode == 402){
die("You may encounter this error if you're not using TLS_1_2");
}else if($charge->httpCode == 403){
die("Check your API Key");
}
//Since we are creating charge, this request shall not be ended httpCode 404 i.e. Not Found
}else{
$chargeId = $charge->getId();
$chargeCurrency = $charge->getCurrency();
$chargeAmount = $charge->getAmount();
$atlpayFees = $charge->getFees();
$token = $charge->token();
// See Model/TokenModel.php for more Getter Methods
$threeDRedirectUrl = $charge->getRedirectUrl();
$threeDRedirectResult = $charge->get3DRedirectStatus();
$transactionMode = $charge->getMode();
// See Model/ChargeModel.php for more Getter Methods
if( $token->getRedirectStatus() == "REQUIRED" ){
header("Location:".$threeDRedirectUrl);
exit;
}else{
//Capture the charge directly, See Capturing a Charge
}
}
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$charge = new \ATLPay\Charge();
$charge->get($apChargeId);
if($charge->isError()){
if(in_array($charge->httpCode, [500, 502, 503, 504])){
die("Something went wrong on ATLPay's end. (These are rare.)");
}else if($charge->httpCode == 400){
die($charge->message);
}else if($charge->httpCode == 401){
die("Check your API Key");
}else if($charge->httpCode == 402){
die("You may encounter this error if you're not using TLS_1_2");
}else if($charge->httpCode == 403){
die("Check your API Key");
}else if($charge->httpCode == 404){
die("Charge Not Found.");
}
}else{
$chargeId = $charge->getId();
$chargeCurrency = $charge->getCurrency();
$chargeAmount = $charge->getAmount();
$chargeStatus = $charge->getStatus();
if($charge->isSuccess()){
$atlpayFees = $charge->getFees();
}else{
$failureReason = $charge->getReason();
}
$token = $charge->token();
// See Model/TokenModel.php for more Getter Methods
$threeDRedirectUrl = $charge->getRedirectUrl();
$threeDRedirectResult = $charge->get3DRedirectStatus();
$transactionMode = $charge->getMode();
// See Model/ChargeModel.php for more Getter Methods
}
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$charge = new \ATLPay\Charge();
$charge->cancel($apChargeId);
if($charge->isError()){
if(in_array($charge->httpCode, [500, 502, 503, 504])){
die("Something went wrong on ATLPay's end. (These are rare.)");
}else if($charge->httpCode == 400){
die($charge->message);
}else if($charge->httpCode == 401){
die("Check your API Key");
}else if($charge->httpCode == 402){
die("You may encounter this error if you're not using TLS_1_2");
}else if($charge->httpCode == 403){
die("Check your API Key");
}else if($charge->httpCode == 404){
die("Charge Not Found.");
}
}else{
$chargeStatus = $charge->getStatus(); //CHARGE_FAILED
$failureReason = $charge->getReason(); //CANCEL_USING_API
$transactionMode = $charge->getMode();
// See Model/ChargeModel.php for more Getter Methods
}
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$charge = new \ATLPay\Charge();
$charge->get($apChargeId);
if($charge->isError()){
if(in_array($charge->httpCode, [500, 502, 503, 504])){
die("Something went wrong on ATLPay's end. (These are rare.)");
}else if($charge->httpCode == 400){
die($charge->message);
}else if($charge->httpCode == 401){
die("Check your API Key");
}else if($charge->httpCode == 402){
die("You may encounter this error if you're not using TLS_1_2");
}else if($charge->httpCode == 403){
die("Check your API Key");
}else if($charge->httpCode == 404){
die("Charge Not Found.");
}
}else{
$threeDRedirectUrl = $charge->getRedirectUrl();
$threeDRedirectResult = $charge->get3DRedirectStatus();
if($threeDRedirectResult == "CHARGEABLE"){
$charge->capture();
if($charge->isError()){
if(in_array($charge->httpCode, [500, 502, 503, 504])){
die("Something went wrong on ATLPay's end. (These are rare.)");
}else if($charge->httpCode == 400){
die($charge->message);
}else if($charge->httpCode == 401){
die("Check your API Key");
}else if($charge->httpCode == 402){
die("You may encounter this error if you're not using TLS_1_2");
}else if($charge->httpCode == 403){
die("Check your API Key");
}else if($charge->httpCode == 404){
die("Charge Not Found.");
}
}else{
$chargeStatus = $charge->getStatus();
if($charge->isSuccess()){
$atlpayFees = $charge->getFees();
}else{
$failureReason = $charge->getReason();
}
$transactionMode = $charge->getMode();
}
}else if($threeDRedirectResult == "PENDING"){
header("Location:".$threeDRedirectUrl);
exit;
}else{
die("Charge Status : <strong>".$chargeStatus."</strong> is not capturable.");
}
}
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$refund = new \ATLPay\Charge();
$refund->refund($apChargeId, $amountToRefund);
if($refund->isError()){
if(in_array($refund->httpCode, [500, 502, 503, 504])){
die("Something went wrong on ATLPay's end. (These are rare.)");
}else if($refund->httpCode == 400){
die($refund->message);
}else if($refund->httpCode == 401){
die("Check your API Key");
}else if($refund->httpCode == 402){
die("You may encounter this error if you're not using TLS_1_2");
}else if($refund->httpCode == 403){
die("Check your API Key");
}else if($refund->httpCode == 404){
die("Charge Not Found.");
}
}else{
$refundId = $refund->getId();
$refundAmount = $refund->getAmount();
$refundFees = $refund->getFees();
$transactionMode = $refund->getMode();
}
\ATLPay\ATLPay::setSecretKey('PLACE_YOUR_SECRET_KEY_HERE');
$refund = new \ATLPay\Charge();
$refund->refund($apChargeId);
if($refund->isError()){
if(in_array($refund->httpCode, [500, 502, 503, 504])){
die("Something went wrong on ATLPay's end. (These are rare.)");
}else if($refund->httpCode == 400){
die($refund->message);
}else if($refund->httpCode == 401){
die("Check your API Key");
}else if($refund->httpCode == 402){
die("You may encounter this error if you're not using TLS_1_2");
}else if($refund->httpCode == 403){
die("Check your API Key");
}else if($refund->httpCode == 404){
die("Charge Not Found.");
}
}else{
$refundId = $refund->getId();
$refundAmount = $refund->getAmount();
$refundFees = $refund->getFees();
$transactionMode = $refund->getMode();
}