Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
commit PHP SDK 4.45.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien SUAREZ committed Mar 10, 2016
1 parent cd1d019 commit 36c2cfb
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
* 4.45.1 (2016-03-10)

* add of Recurring class
* require any 1.* monolog/monolog version
* date_default_timezone_set("Europe/Paris") in PaylineSDK class constructor
* add widget related constants (js and css url path)

* 4.45 (2016-01-22)

* add of softDescriptor payment attribute (Payment class)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"require" : {
"php" : ">=5.3.0",
"monolog/monolog" : "1.0.*"
"monolog/monolog" : "1.*"
},
"support" : {
"email" : "[email protected]",
Expand Down
106 changes: 100 additions & 6 deletions src/Payline/PaylineSDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use SoapClient;
use SoapVar;

$vendorPath = realpath(dirname(dirname(dirname(dirname(dirname(__FILE__)))))) . DIRECTORY_SEPARATOR;
$classesPath = $vendorPath . 'monext' . DIRECTORY_SEPARATOR . 'payline-sdk' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Payline' . DIRECTORY_SEPARATOR;
require_once $vendorPath . 'autoload.php';
Expand All @@ -31,19 +33,30 @@
require_once $classesPath . 'Authorization.class.php';
require_once $classesPath . 'Creditor.class.php';
require_once $classesPath . 'Cheque.class.php';
require_once $classesPath . 'Recurring.class.php';

class PaylineSDK
{

/**
* Payline release corresponding to this version of the package
*/
const SDK_RELEASE = 'PHP SDK 4.45';
const SDK_RELEASE = 'PHP SDK 4.45.1';

/**
* WSDL file name
*/
const WSDL = 'v4.45.1.wsdl';

/**
* path to WSDL file
* development environment flag
*/
const ENV_DEV = "DEV";

/**
* integration environment flag
*/
const WSDL = 'v4.45.wsdl';
const ENV_INT = "INT";

/**
* homologation environment flag
Expand Down Expand Up @@ -148,7 +161,22 @@ class PaylineSDK
/**
* SOAP name of billingRecordForUpdate object
*/
const BILLING_RECORD_FOR_UPDATE = 'billingRecordForUpdate';
const SOAP_BILLING_RECORD_FOR_UPDATE = 'billingRecordForUpdate';

/**
* SOAP name of recurring object
*/
const SOAP_RECURRING = 'recurring';

/**
* web services endpoint in development environment
*/
const DEV_ENDPOINT = 'https://ws.dev.payline.com/V4/services/';

/**
* web services endpoint in integration environment
*/
const INT_ENDPOINT = 'https://ws.int.payline.com/V4/services/';

/**
* web services endpoint in homologation environment
Expand All @@ -159,6 +187,16 @@ class PaylineSDK
* web services endpoint in production environment
*/
const PROD_ENDPOINT = 'https://services.payline.com/V4/services/';

/**
* URL of getToken servlet, used by AJAX API, in development environment
*/
const DEV_GET_TOKEN_SERVLET = "https://webpayment.dev.payline.com/webpayment/getToken";

/**
* URL of getToken servlet, used by AJAX API, in integration environment
*/
const INT_GET_TOKEN_SERVLET = "https://webpayment.int.payline.com/webpayment/getToken";

/**
* URL of getToken servlet, used by AJAX API, in homologation environment
Expand All @@ -170,6 +208,36 @@ class PaylineSDK
*/
const PROD_GET_TOKEN_SERVLET = "https://webpayment.payline.com/webpayment/getToken";

/**
* Widget JavaScript in development environment
*/
const DEV_WDGT_JS = "https://webpayment.dev.payline.com/payline-widget/scripts/widget-min.js";

/**
* Widget JavaScript in homologation environment
*/
const HOMO_WDGT_JS = "https://homologation-payment.payline.com/scripts/widget-min.js";

/**
* Widget JavaScript in production environment
*/
const PROD_WDGT_JS = "https://payment.payline.com/scripts/widget-min.js";

/**
* Widget css in development environment
*/
const DEV_WDGT_CSS = "https://webpayment.dev.payline.com/payline-widget/styles/widget-min.css";

/**
* Widget css in homologation environment
*/
const HOMO_WDGT_CSS = "https://homologation-payment.payline.com/styles/widget-min.css";

/**
* Widget css in production environment
*/
const PROD_WDGT_CSS = "https://payment.payline.com/styles/widget-min.css";

/**
* homologation administration center URL
*/
Expand Down Expand Up @@ -229,6 +297,7 @@ class PaylineSDK
*/
function __construct($merchant_id, $access_key, $proxy_host, $proxy_port, $proxy_login, $proxy_password, $environment, $pathLog = null, $logLevel = Logger::INFO)
{
date_default_timezone_set("Europe/Paris");
$this->logger = new Logger('PaylineSDK');
if (is_null($pathLog)) {
$this->logger->pushHandler(new StreamHandler(realpath(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . date('Y-m-d') . '.log', $logLevel)); // set default log folder
Expand Down Expand Up @@ -258,6 +327,10 @@ function __construct($merchant_id, $access_key, $proxy_host, $proxy_port, $proxy
$this->webServicesEndpoint = PaylineSDK::HOMO_ENDPOINT;
} elseif (strcmp($environment, PaylineSDK::ENV_PROD) == 0) {
$this->webServicesEndpoint = PaylineSDK::PROD_ENDPOINT;
} elseif (strcmp($environment, PaylineSDK::ENV_DEV) == 0) {
$this->webServicesEndpoint = PaylineSDK::DEV_ENDPOINT;
} elseif (strcmp($environment, PaylineSDK::ENV_INT) == 0) {
$this->webServicesEndpoint = PaylineSDK::INT_ENDPOINT;
}
$this->header_soap['style'] = SOAP_DOCUMENT;
$this->header_soap['use'] = SOAP_LITERAL;
Expand Down Expand Up @@ -475,7 +548,7 @@ protected function billingRecordForUpdate($array)
$billingRecordForUpdate->$k = $v;
}
}
return new \SoapVar($billingRecordForUpdate, SOAP_ENC_OBJECT, PaylineSDK::BILLING_RECORD_FOR_UPDATE, PaylineSDK::PAYLINE_NAMESPACE);
return new \SoapVar($billingRecordForUpdate, SOAP_ENC_OBJECT, PaylineSDK::SOAP_BILLING_RECORD_FOR_UPDATE, PaylineSDK::PAYLINE_NAMESPACE);
}

/**
Expand Down Expand Up @@ -564,6 +637,26 @@ protected function cheque($array)
}
return new \SoapVar($cheque, SOAP_ENC_OBJECT, PaylineSDK::SOAP_CHEQUE, PaylineSDK::PAYLINE_NAMESPACE);
}

/**
* build Recurring instance from $array and make SoapVar object for recurring
*
* @param array $array
* the array keys are listed in Recurring CLASS.
* @return SoapVar representation of Recurring instance
*/
protected function recurring($array)
{
$recurring = new Recurring();
if ($array && is_array($array)) {
foreach ($array as $k => $v) {
if (array_key_exists($k, $recurring) && (strlen($v))) {
$recurring->$k = $v;
}
}
}
return new \SoapVar($recurring, SOAP_ENC_OBJECT, PaylineSDK::SOAP_RECURRING, PaylineSDK::PAYLINE_NAMESPACE);
}

/**
* Hide characters in a string
Expand Down Expand Up @@ -1003,7 +1096,8 @@ private function webServiceRequest($array, $WSRequest, $PaylineAPI, $Method)
$this->logger->addInfo($Method . 'Request', $logRequest);
$this->logger->addError('Exception occured at ' . $Method . ' call', array(
'code' => $e->getCode(),
'message' => $e->getMessage()
'message' => $e->getMessage(),
'endpoint' => $this->webServicesEndpoint . $PaylineAPI
));
$ERROR = array();
$ERROR['result']['code'] = PaylineSDK::ERR_CODE;
Expand Down
28 changes: 28 additions & 0 deletions src/Payline/Recurring.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/*
* This file is part of the Payline package.
*
* (c) Monext <http://www.monext.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Payline;

class Recurring
{

public $firstAmount;

public $amount;

public $billingCycle;

public $billingLeft;

public $billingDay;

public $startDate;

public $endDate;
}
File renamed without changes.

0 comments on commit 36c2cfb

Please sign in to comment.