Skip to content

Commit

Permalink
Merge pull request #6 from cardinity/whmcs8_compatibility_patch
Browse files Browse the repository at this point in the history
Whmcs8 compatibility patch
  • Loading branch information
shababcardinity authored Dec 11, 2020
2 parents 72f7f9f + 91bd388 commit 59510f0
Show file tree
Hide file tree
Showing 710 changed files with 114,101 additions and 166 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.idea/
.vscode/
/modules/gateways/cardinity/vendor
/modules/gateways/cardinity/composer.lock

43 changes: 8 additions & 35 deletions modules/gateways/callback/cardinityexternal.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,8 @@
require_once __DIR__ . '/../../../includes/invoicefunctions.php';


//Autoload Cardinity SDK
require_once __DIR__ . '/../cardinity/vendor/autoload.php';

use \Cardinity\Client;
use \Cardinity\Method\Payment;
use \Cardinity\Method\Refund;
use \Cardinity\Exception;
use WHMCS\Database\Capsule;

//$whmcs->load_function('gateway');
//$whmcs->load_function('invoice');

// Detect module name from filename.
$gatewayModuleName = basename(__FILE__, '.php');

Expand All @@ -33,25 +23,6 @@
}


//Select the api credentials by gateway mode
$gatewayMode = $gatewayParams['gatewayMode'];
if ($gatewayMode == 'Test') {
$consumer_key = $gatewayParams['testConsumerKey'];
$consumer_secret = $gatewayParams['testConsumerSecret'];
} else {
$consumer_key = $gatewayParams['liveConsumerKey'];
$consumer_secret = $gatewayParams['liveConsumerSecret'];
}

//Create Cardinity Client
$client = Client::create([
'consumerKey' => $consumer_key,
'consumerSecret' => $consumer_secret,
]);




/**
* External Callback
*/
Expand Down Expand Up @@ -97,15 +68,18 @@
*
* @param string $transactionId Unique Transaction ID
*/
checkCbTransID($transactionId);
checkCbTransID($transactionId);


//Verify response is not tampered
if ($signature == $_POST['signature']) {
// check if payment is approved
if ($_POST['status'] == "approved") {
//Payment Accepted
if ($_POST['status'] == "approved") {
//Payment Accepted
$isVerificationSuccessful = true;

logTransaction($gatewayParams['name'], ['Invoice ID' => $invoiceId], 'Success');

addInvoicePayment(
$invoiceId,
$transactionId,
Expand All @@ -114,8 +88,7 @@
$gatewayModuleName
);
}
}
}

//Finished callback, redirect to whmcs
callback3DSecureRedirect($invoiceId, $isVerificationSuccessful);

22 changes: 6 additions & 16 deletions modules/gateways/cardinity.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
* Cardinity Gateway Module for WHMCS
*/

//Autoload Cardinity SDK
require_once "cardinity/vendor/autoload.php";

//autoload gateway functions
require_once __DIR__ . '/../../includes/gatewayfunctions.php';

//Autoload Cardinity SDK
require_once __DIR__."/cardinity/vendor/autoload.php";


use Cardinity\Client;
use Cardinity\Exception;
use Cardinity\Method\Payment;
Expand Down Expand Up @@ -64,20 +67,7 @@ function cardinity_config()
'Description' => 'Enter live consumer secret here',
),

/*'projectId' => array(
'FriendlyName' => 'Cardinity Project ID',
'Type' => 'text',
'Size' => '100',
'Default' => '',
),
'projectSecret' => array(
'FriendlyName' => 'Cardinity Project Secret',
'Type' => 'text',
'Size' => '100',
'Default' => '',
),*/


'gatewayMode' => array(
'FriendlyName' => 'Gateway Mode',
'Type' => 'radio',
Expand Down
14 changes: 14 additions & 0 deletions modules/gateways/cardinity/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,19 @@
"require": {
"php": ">=7.2.5",
"cardinity/cardinity-sdk-php": "~3.0"
},
"autoload": {
"files": [
"vendor-static/guzzlehttp/guzzle/src/functions_include.php",
"vendor-static/guzzlehttp/psr7/src/functions_include.php",
"vendor-static/guzzlehttp/promises/src/functions_include.php",
"vendor-static/guzzlehttp/oauth-subscriber/src/Oauth1.php"
],
"psr-4": {
"GuzzleHttp6\\": "vendor-static/guzzlehttp/guzzle/src/",
"GuzzleHttp6\\Psr7\\": "vendor-static/guzzlehttp/psr7/src/",
"GuzzleHttp6\\Promise\\": "vendor-static/guzzlehttp/promises/src/",
"GuzzleHttp6\\Subscriber\\Oauth\\": "vendor-static/guzzlehttp/oauth-subscriber/src/"
}
}
}
Loading

0 comments on commit 59510f0

Please sign in to comment.