wpc_pay(1).php

<?php
/**
* Created by PhpStorm.
* User: DEV_TEAM
* Date: 1/4/2018
* Time: 3:24 PM
*
*/
include("../../../init.php");
include("../../../includes/functions.php");
include("../../../includes/gatewayfunctions.php");
include("../../../includes/invoicefunctions.php");

$gatewaymodule = "wpc";

// Fetch gateway configuration parameters.

$gatewayParams = getGatewayVariables($gatewaymodule);

// Die if module is not active.

if (!$gatewayParams['type']) {

die("Module Not Activated");

}



//World Payments Corp Config
$wpcTestMode = $gatewayParams['testMode'];
$wpcMerchantUserName = $gatewayParams['vendorName']; //Replace it by your merchant user name
$wpcMerchantSecretKey = $gatewayParams['secretKey']; //Replace it by your merchant secret key
if ($wpcTestMode =='on') {
//TEST MODE ENDPOINT
$wpcEndpoint = 'https://securetest.paycec.com/redirect-service';
} else {
//LIVE MODE ENDPOINT
$wpcEndpoint = 'https://secure.paycec.com/redirect-service';
}

//Get the transaction detail from Secure WorldPaymentsCor
$purchaseDetailsEndpoint = $wpcEndpoint.'/purchase-details';

$token = $_GET['token'];

$params = array(
'merchantName' => $wpcMerchantUserName,
'merchantSecretKey' => $wpcMerchantSecretKey,
'token' => $token,
);
$params['sig'] = generateSignatureWpc($purchaseDetailsEndpoint, $params, $wpcMerchantSecretKey);

//Call to Secure PayCEC Service to get the transaction details
$reply = callWpc($purchaseDetailsEndpoint, $params, $errorCode, $errorMessage);
$response = explode("#",$reply->referenceCode);
$status = $reply->isSuccessful;
$invoiceId = trim($response[1]);
$mount = trim($response[2]);

$invoiceId = checkCbInvoiceID($invoiceId, 'wpc');
$transid = $reply->transactionId;
checkCbTransID($transid);
$arrayData = json_decode(json_encode($reply),TRUE);
if ($reply != null && $reply->isSuccessful == 'true') {
//Charged successfully!

addInvoicePayment($invoiceId, $transid, $mount, $gatewaymodule); # Apply Payment to Invoice: invoiceid, transactionid, amount paid, fees, modulename
update_query("tblinvoices",array("id"=>$invoiceId));
logTransaction($gatewayParams["name"],$arrayData,"Successful"); # Save to Gateway Log: name, data array, status
$filename = $gatewayParams['systemurl'].'/viewinvoice.php?id=' . $invoiceId; // path of your viewinvoice.php

}else {
//Error handling
logTransaction($gatewayParams["name"],$arrayData,"Unsuccessful");
$filename = $gatewayParams['systemurl'].'/viewinvoice.php?id=' . $invoiceId.'&paymentfailed=true'; // path of your viewinvoice.php
}
//$filename = $gatewayParams['systemurl'].'/viewinvoice.php?id=' . $invoiceId; // path of your viewinvoice.php
HEADER("location:$filename");




Download
  • Developed by OpenCart Community
  • Documentation Included

Rating

Compatibility

Last Update
4 Dec 2022

Created
4 Dec 2022
9 Downloads
0 Comments
slatorelizabeth007
slatorelizabeth007
Member since: 24 Nov 2022

View all extensions Get Support