Skip to content

Commit

Permalink
Merge pull request #22 from RichardCardGate/master
Browse files Browse the repository at this point in the history
Fix: add-on compatibility.
  • Loading branch information
cardgate authored Sep 9, 2021
2 parents 913a0dd + cf86e9b commit 2b30744
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 53 deletions.
2 changes: 1 addition & 1 deletion app/addons/cardgate/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<addon scheme="3.0" edition_type="ROOT,ULT:VENDOR">
<id>cardgate</id>
<version>4.5.0</version>
<version>1.0</version>
<default_language>en</default_language>
<priority>100</priority>
<status>active</status>
Expand Down
3 changes: 2 additions & 1 deletion app/addons/cardgate/func.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function fn_cardgate_install_payment_processors(){
'Paysafecash' => 'paysafecash',
'Przelewy24' => 'przelewy24',
'Sofortbanking' => 'sofortbanking',
'SofortPay' => 'sofortpay'
'SofortPay' => 'sofortpay',
'SprayPay' => 'spraypay'
);

foreach ($payments as $naam => $paymentcode) {
Expand Down
5 changes: 3 additions & 2 deletions app/payments/cardgate/cardgate-clientlib-php/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cardgate/cardgate-clientlib-php",
"description": "CardGate API client library for PHP",
"homepage": "https://github.com/cardgate/cardgate-clientlib-php",
"version": "1.1.12",
"version": "1.1.15",
"license": "MIT",
"authors": [
{
Expand All @@ -19,7 +19,8 @@
"afterpay", "bitcoin", "directdebit"
],
"require" : {
"php": "~5.6.0|~7.0.0|~7.1.0|~7.2.0|~7.3.0"
"php": "~5.6.0|~7.0.0|~7.1.0|~7.2.0|~7.3.0|~7.4.0",
"ext-json": "*"
},
"autoload": {
"psr-4": {
Expand Down
42 changes: 4 additions & 38 deletions app/payments/cardgate/cardgate-clientlib-php/src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class Client {
/**
* Client version.
*/
const CLIENT_VERSION = "1.1.12";
const CLIENT_VERSION = "1.1.15";

/**
* Url to use for production.
Expand Down Expand Up @@ -382,46 +382,12 @@ public function getLastResult() {
* @access public
* @api
*/
static public function pullConfig( $sToken_, $bTestmode_ = FALSE ) {
public function pullConfig( $sToken_ ) {
if ( ! is_string( $sToken_ ) ) {
throw new Exception( 'Client.Token.Invalid', 'invalid token for settings pull: ' . $sToken_ );
}

$sResource = "pullconfig/{$sToken_}/";
$sUrl = ( $bTestmode_ ? self::URL_STAGING : self::URL_PRODUCTION ) . $sResource;

$rCh = curl_init();
curl_setopt( $rCh, CURLOPT_URL, $sUrl );
curl_setopt( $rCh, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $rCh, CURLOPT_TIMEOUT, 60 );
curl_setopt( $rCh, CURLOPT_HEADER, FALSE );
curl_setopt( $rCh, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Accept: application/json'
] );
if ( $bTestmode_ ) {
curl_setopt( $rCh, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt( $rCh, CURLOPT_SSL_VERIFYHOST, 0 );
} else {
curl_setopt( $rCh, CURLOPT_SSL_VERIFYPEER, TRUE ); // verify SSL peer
curl_setopt( $rCh, CURLOPT_SSL_VERIFYHOST, 2 ); // check for valid common name and verify host
}

if ( FALSE == ( $sResults = curl_exec( $rCh ) ) ) {
$sError = curl_error( $rCh );
curl_close( $rCh );
throw new Exception( 'Client.Request.Curl.Error', $sError );
} else {
curl_close( $rCh );
}
if ( NULL === ( $aResults = json_decode( $sResults, TRUE ) ) ) {
throw new Exception( 'Client.Request.JSON.Invalid', 'remote gave invalid JSON: ' . $sResults );
}
if ( isset( $aResults['error'] ) ) {
throw new Exception( 'Client.Request.Remote.' . $aResults['error']['code'], $aResults['error']['message'] );
}

return $aResults;
return $this->doRequest($sResource);
}

/**
Expand Down Expand Up @@ -536,7 +502,7 @@ public function doRequest( $sResource_, $aData_ = NULL, $sHttpMethod_ = 'POST' )
}

if ( 'POST' == $sHttpMethod_ ) {
$this->_sLastRequest = json_encode( $aData_ );
$this->_sLastRequest = json_encode( $aData_, JSON_PARTIAL_OUTPUT_ON_ERROR );
curl_setopt( $rCh, CURLOPT_URL, $sUrl );
curl_setopt( $rCh, CURLOPT_POST, TRUE );
curl_setopt( $rCh, CURLOPT_POSTFIELDS, $this->_sLastRequest );
Expand Down
10 changes: 10 additions & 0 deletions app/payments/cardgate/cardgate-clientlib-php/src/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ final class Method {
*/
const GIFTCARD = 'giftcard';

/**
* EPS
*/
const EPS = 'eps';

/**
* SprayPay
*/
const SPRAYPAY = 'spraypay';

/**
* The client associated with this payment method.
* @var Client
Expand Down
12 changes: 2 additions & 10 deletions app/payments/cardgate/cardgate-clientlib-php/tests/apiUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,8 @@ class apiUnitTest extends \PHPUnit\Framework\TestCase {

private $_oClient;

protected function setUp() {
$this->_oClient = new cardgate\api\Client( 1, 'fake_key', TRUE );
parent::setUp();
}

protected function tearDown() {
$this->_oClient = NULL;
parent::tearDown();
}

public function testCreateClientInstance() {
$this->_oClient = new cardgate\api\Client( 1, 'fake_key', TRUE );
$this->_oClient->setLanguage( 'nl' );
$this->assertEquals( 'nl', $this->_oClient->getLanguage(), 'language not set' );
$this->_oClient->version()->setPlatformName( 'PHP' );
Expand All @@ -24,6 +15,7 @@ public function testCreateClientInstance() {
$this->assertEquals( 'Test Implementation', $this->_oClient->version()->getPluginName(), 'plugin name not set' );
$this->_oClient->version()->setPluginVersion( '0.0.1' );
$this->assertEquals( '0.0.1', $this->_oClient->version()->getPluginVersion(), 'plugin version not set' );
$this->_oClient = NULL;
}

}
2 changes: 1 addition & 1 deletion app/payments/cardgate/cardgate.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Cardgate
// version
const pluginName = 'cs_cart';

const pluginVersion = '4.5.0';
const pluginVersion = '4.5.1';

public function __construct($merchant_id, $api_key, $site_id)
{
Expand Down
7 changes: 7 additions & 0 deletions app/payments/cardgatespraypay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$paymentcode = 'spraypay';
$filename = 'cardgatespraypay';
$redirect = true;

include_once 'cardgate/base.php';
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>{__("text_cardgate_settings")}</p>
Binary file added images/cardgate/cardgatespraypay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2b30744

Please sign in to comment.