sentence1
stringlengths 52
3.87M
| sentence2
stringlengths 1
47.2k
| label
stringclasses 1
value |
---|---|---|
public function getConstraint(\ReflectionProperty $reflectionProperty, $constraintClass, $getFromAll = true)
{
if (
($constraint = $this->reader->getPropertyAnnotation($reflectionProperty, $constraintClass)) &&
$constraint instanceof Constraint
) {
return $constraint;
}
// if not found, and not searching the All Constraint, return
if (!$getFromAll) {
return;
}
if (
($allConstraint = $this->getConstraintFromAll($reflectionProperty, $constraintClass)) &&
$allConstraint instanceof Constraint
) {
return $allConstraint;
}
}
|
Retrieve a specific constraint of a property ; defaults to retrieving from the All constraint if that exists.
@param \ReflectionProperty $reflectionProperty
@param string $constraintClass
@param bool $getFromAll whether to search an All constraint of the property
@return Constraint|null
|
entailment
|
public function getConstraintFromAll(\ReflectionProperty $reflectionProperty, $constraintClass)
{
/** @var All $allConstraint */
if (!($allConstraint = $this->getConstraint($reflectionProperty, All::class, false))) {
return;
}
foreach ($allConstraint->constraints as $constraint) {
if ($constraint instanceof $constraintClass) {
return $constraint;
}
}
}
|
Retrieve a specific Symfony Constraint from within a Symfony All Constraint.
@param \ReflectionProperty$reflectionProperty
@param string $constraintClass
@return Constraint|null
|
entailment
|
public static function getExampleValues(): array
{
return array_merge(parent::getExampleValues(), [
'season' => '2015-16',
'seasonYear' => '2015-16',
'seasonId' => 22015,
'gameScope' => GameScopeParam::SEASON,
'playerScope' => PlayerScopeParam::ALL_PLAYERS,
'playerOrTeam' => PlayerOrTeamParam::PLAYER,
'statCategory' => StatCategoryParam::POINTS,
'statType' => StatTypeParam::TRADITIONAL,
'stat' => StatParam::POINTS,
'gameScope' => GameScopeParam::LAST_10,
'contextMeasure' => ContextMeasureParam::POINTS,
]);
}
|
{@inheritdoc}
|
entailment
|
private function getConfig($key = null, $args = null)
{
if($key!=null) {
$value = null;
if(isset($this->_config[$key])) {
$value = $this->_config[$key];
} elseif(isset($this->_updateConfig[$key])) {
$value = $this->_updateConfig[$key];
}
if (isset($args["returnAsArray"]) && $args["returnAsArray"]){
/** Return the response as an array */
if(is_array($value)){
return $value;
}
}elseif(is_array($value)) {
/** @var CheckoutApi_Lib_RespondObj $to_return */
$to_return = CheckoutApi_Lib_Factory::getInstance('CheckoutApi_Lib_RespondObj');
$to_return->setConfig( $value);
return $to_return;
}
return $value;
}
if($key == null) {
return $this->_config;
}
return null;
}
|
This method return value from the attribute config
@param null $key attribute you want to retrive
@return array|CheckoutApi_Lib_RespondObj|null
@throws Exception
|
entailment
|
public static function getSingletonInstance($className, array $arguments = array())
{
$registerKey = $className;
if (!isset(self::$_registry[$registerKey])) {
if(class_exists($className)) {
self::$_registry[$registerKey] = new $className($arguments);
}else {
throw new Exception ('Invalid class name:: ' .$className."(".print_r($arguments,1).')');
}
}
return self::$_registry[$registerKey];
}
|
This helper method create a singleton object , given the name of the class
@param $className
@param array $arguments arguemnet for class constructor
@return mixed
@throws Exception
Simple usage:
CheckoutApi_Lib_Factory::getSingletonInstance('CheckoutApi_Client_ClientGW3');
|
entailment
|
public static function isEmpty($var)
{
$toReturn = false;
if(is_array($var) && empty($var)) {
$toReturn = true;
}
if(is_string($var) && ($var =='' || is_null($var))) {
$toReturn = true;
}
if(is_integer($var) && ($var =='' || is_null($var)) ) {
$toReturn = true;
}
if(is_float($var) && ($var =='' || is_null($var)) ) {
$toReturn = true;
}
return $toReturn;
}
|
A helper method that check if variable is empty
@param mixed $var
@return boolean
Simple usage:
CheckoutApi_Lib_Validator::isEmpty($var)
|
entailment
|
public function getCardToken(array $param)
{
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::TOKEN_CARD_TYPE;
$postedParam = $param['postedParam'];
$this->flushState();
$isEmailValid = CheckoutApi_Client_Validation_GW3::isEmailValid($postedParam);
$isCardValid = CheckoutApi_Client_Validation_GW3::isCardValid($postedParam);
$uri = $this->getUriToken().'/card';
return $this->request( $uri ,$param,!$hasError);
}
|
Create Card Token
@param array $param payload for creating a card token parameter
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['postedParam'] = array (
'email' => '[email protected]',
'card' => array(
'phoneNumber' => '0123465789',
'name' => 'test name',
'number' => 'XXXXXXXXX',
'expiryYear' => 2017,
'cvv' => 956
)
);
$respondCardToken = $Api->getCardToken( $param );
Use by having, first an instance of the gateway 3.0 and set of arguments as above
|
entailment
|
public function getPaymentToken(array $param)
{
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::TOKEN_SESSION_TYPE;
$postedParam = $param['postedParam'];
$this->flushState();
$isAmountValid = CheckoutApi_Client_Validation_GW3::isValueValid($postedParam);
$isCurrencyValid = CheckoutApi_Client_Validation_GW3::isValidCurrency($postedParam);
$uri = $this->getUriToken().'/payment';
if(!$isAmountValid) {
$hasError = true;
$this->throwException('Please provide a valid amount (in cents)', array('pram'=>$param));
}
if(!$isCurrencyValid) {
$hasError = true;
$this->throwException('Please provide a valid currency code (ISO currency code)', array('pram'=>$param));
}
return $this->request( $uri ,$param,!$hasError);
}
|
Create payment token
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$sessionConfig['postedParam'] = array( "value"=>100, "currency"=>"GBP");
$sessionTokenObj = $Api->getPaymentToken($sessionConfig);
Use by having, first an instance of the gateway 3.0 and set of argument base on documentation for creating a session token.
|
entailment
|
public function createCharge(array $param)
{
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::CHARGE_TYPE;
$postedParam = $param['postedParam'];
$this->flushState();
$isAmountValid = CheckoutApi_Client_Validation_GW3::isValueValid($postedParam);
$isCurrencyValid = CheckoutApi_Client_Validation_GW3::isValidCurrency($postedParam);
$isEmailValid = CheckoutApi_Client_Validation_GW3::isEmailValid($postedParam);
$isCustomerIdValid = CheckoutApi_Client_Validation_GW3::isCustomerIdValid($postedParam);
$isCardValid = CheckoutApi_Client_Validation_GW3::isCardValid($postedParam);
$isCardIdValid = CheckoutApi_Client_Validation_GW3::isCardIdValid($postedParam);
$isCardTokenValid = CheckoutApi_Client_Validation_GW3::isCardToken($postedParam);
if(!$isEmailValid && !$isCustomerIdValid) {
$hasError = true;
$this->throwException('Please provide a valid Email address or Customer id', array('param'=>$postedParam));
}
if($isCardTokenValid) {
if(isset($postedParam['card'])) {
$this->throwException('unset card object', array('param'=>$postedParam),false);
// unset($param['postedParam']['card']);
}
$this->setUriCharge('','token');
}elseif($isCardValid) {
if(isset($postedParam['token'])){
$this->throwException('unset invalid token object', array('param'=>$postedParam),false);
unset($param['postedParam']['token']);
}
$this->setUriCharge('','card');
}elseif($isCardIdValid) {
$this->setUriCharge('','card');
if(isset($postedParam['token'])){
$this->throwException('unset invalid token object', array('param'=>$postedParam),false);
unset($param['postedParam']['token']);
}
if(isset($postedParam['card'])) {
$this->throwException('unset invalid token object', array('param' => $postedParam), false);
if (isset($param['postedParam']['card']['name'])) {
unset($param['postedParam']['card']['name']);
}
if (isset($param['postedParam']['card']['number'])) {
unset($param['postedParam']['card']['number']);
}
if (isset($param['postedParam']['card']['expiryMonth'])) {
unset($param['postedParam']['card']['expiryMonth']);
}
if (isset($param['postedParam']['card']['expiryYear'])) {
unset($param['postedParam']['card']['expiryYear']);
}
}
} elseif($isEmailValid || $isCustomerIdValid){
$this->setUriCharge('','customer');
} else {
$hasError = true;
$this->throwException('Please provide either a valid card token or a card object or a card id', array('pram'=>$param));
}
if(!$isAmountValid) {
$hasError = true;
$this->throwException('Please provide a valid amount (in cents)', array('pram'=>$param));
}
if(!$isCurrencyValid) {
$hasError = true;
$this->throwException('Please provide a valid currency code (ISO currency code)', array('pram'=>$param));
}
return $this->_responseUpdateStatus($this->request( $this->getUriCharge() ,$param,!$hasError));
}
|
Create Charge
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
This methods can be call to create charge for checkout.com gateway 3.0 by passing
full card details :
$param['postedParam'] = array ( 'email'=>'[email protected]',
'value'=>100,
'currency'=>'usd',
'description'=>'desc',
'caputure'=>false,
'card' => array(
'phoneNumber'=>'0123465789',
'name'=>'test name',
'number' => '4543474002249996',
'expiryMonth' => 06,
'expiryYear' => 2017,
'cvv' => 956,
)
);
or by passing a card token:
$param['postedParam'] = array ( 'email'=>'[email protected]',
'value'=>100,
'currency'=>'usd',
'description'=>'desc',
'caputure'=>false,
'cardToken'=>'card_tok_2d033cf7-1542-4a3d-bd08-bd9d26533551'
)
or by passing a card id:
$param['postedParam'] = array ( 'email'=>'[email protected]',
'value'=>100,
'currency'=>'usd',
'description'=>'desc',
'caputure'=>false,
'cardId'=>'card_fb10a0a5-05ef-4254-ac85-3aa221e8d50d'
)
and then just call the method:
$charge = $Api->createCharge($param);
|
entailment
|
public function getRefundAmountInfo($param){
$chargeHistory = $this->getChargeHistory($param);
$charges = $chargeHistory->getCharges();
$chargesArray = $charges->toArray();
$totalRefunded = 0;
foreach($chargesArray as $num => $values) {
if (in_array(CheckoutApi_Client_Constant::STATUS_CAPTURE,$values)){
$capturedAmount = $values[ 'value' ];
}
if (in_array(CheckoutApi_Client_Constant::STATUS_REFUND,$values)){
$totalRefunded += $values[ 'value' ];
}
}
$refundInfo = array(
'capturedAmount' => $capturedAmount,
'totalRefunded' => $totalRefunded,
'remainingAmount' => $capturedAmount - $totalRefunded
);
return $refundInfo;
}
|
Refund Info
This method returns the Captured amount, total refunded amount and the amount remaing
to refund
$refundInfo = $Api->getRefundInfo($param);
|
entailment
|
public function refundCharge($param)
{
$chargeHistory = $this->getChargeHistory($param);
$charges = $chargeHistory->getCharges();
$uri = $this->getUriCharge();
if(!empty($charges)) {
$chargesArray = $charges->toArray();
$toRefund = false;
$toVoid = false;
$toRefundData = false;
$toVoidData = false;
foreach ($chargesArray as $key=> $charge) {
if (in_array(CheckoutApi_Client_Constant::STATUS_CAPTURE, $charge)
|| in_array(CheckoutApi_Client_Constant::STATUS_REFUND,$charge)){
if(strtolower($charge['status']) == strtolower(CheckoutApi_Client_Constant::STATUS_CAPTURE)) {
$toRefund = true;
$toRefundData = $charge;
break;
}
}
else {
$toVoid = true;
$toVoidData = $charge;
}
}
if($toRefund) {
$refundChargeId = $toRefundData['id'];
$param['chargeId'] = $refundChargeId;
$uri = "$uri/{$param['chargeId']}/refund";
}
if($toVoid) {
$voidChargeId = $toVoidData['id'];
$param['chargeId'] = $voidChargeId;
$uri = "$uri/{$param['chargeId']}/void";
}
}
else {
$this->throwException('Please provide a valid charge id',array('param'=>$param));
}
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::CHARGE_TYPE;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_POST;
$postedParam = $param['postedParam'];
$this->flushState();
$isAmountValid = CheckoutApi_Client_Validation_GW3::isValueValid($postedParam);
$isChargeIdValid = CheckoutApi_Client_Validation_GW3::isChargeIdValid($param);
if(!$isChargeIdValid) {
$hasError = true;
$this->throwException('Please provide a valid charge id',array('param'=>$param));
}
if(!$isAmountValid) {
$this->throwException('Please provide a amount (in cents)',array('param'=>$param),false);
}
return $this->_responseUpdateStatus($this->request($uri ,$param,!$hasError));
}
|
Refund Charge
This method refunds a Card Charge that has previously been created but not yet refunded
or void a charge that has been capture
@param array $param payload param for refund a charge
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['postedParam'] = array (
'value'=>150
);
$refundCharge = $Api->refundCharge($param);
|
entailment
|
public function voidCharge($param)
{
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::CHARGE_TYPE;
$postedParam = $param['postedParam'];
$this->flushState();
$isAmountValid = CheckoutApi_Client_Validation_GW3::isValueValid($postedParam);
$isChargeIdValid = CheckoutApi_Client_Validation_GW3::isChargeIdValid($param);
$uri = $this->getUriCharge();
if(!$isChargeIdValid) {
$hasError = true;
$this->throwException('Please provide a valid charge id',array('param'=>$param));
} else {
$uri = "$uri/{$param['chargeId']}/void";
}
if(!$isAmountValid) {
$this->throwException('Please provide a amount (in cents)',array('param'=>$param),false);
}
return $this->_responseUpdateStatus($this->request( $uri ,$param,!$hasError));
}
|
Void Charge
This method void a Card Charge that has previously been created
@param array $param payload param for void a charge
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['postedParam'] = array ('value'=>150);
$refundCharge = $Api->refundCharge($param);
|
entailment
|
public function updateMetadata($chargeObj, $metaData = array())
{
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::CHARGE_TYPE;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_PUT;
$this->flushState();
$chargeId = $chargeObj->getId();
$metaArray = array();
if($chargeObj->getMetadata()) {
$metaArray = $chargeObj->getMetadata()->toArray();
}
$newMetadata = array_merge($metaArray,$metaData);
$param['postedParam']['metadata'] = $newMetadata;
$uri = $this->getUriCharge();
$uri = "$uri/{$chargeId}";
return $this->request( $uri ,$param,!$hasError);
}
|
Update MetaData Charge.
Updates the specified Card Charge by setting the values of the parameters passed.
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$updateCharge = $Api->updateMetadata($param array('keycode'=>$value));
|
entailment
|
public function updateTrackId($chargeObj, $trackId)
{
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::CHARGE_TYPE;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_PUT;
$this->flushState();
$chargeId = $chargeObj->getId();
$param['postedParam']['trackId'] = $trackId;
$uri = $this->getUriCharge();
$uri = "$uri/{$chargeId}";
return $this->request( $uri ,$param,!$hasError);
}
|
Update Trackid Charge.
Updates the specified Card Charge by setting the values of the parameters passed.
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$updateCharge = $Api->updateTrackId($chargeObj, $trackId);
|
entailment
|
public function updatePaymentToken($param)
{
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::CHARGE_TYPE;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_PUT;
$this->flushState();
$uri = $this->getUriToken()."/payment/{$param['paymentToken']}";
return $this->request($uri ,$param,!$hasError);
}
|
Update PaymentToken Charge.
Updates the specified Card Charge by setting the values of the parameters passed.
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$updatePaymentToken = $Api->updatePaymentToken($paymentToken);
|
entailment
|
public function getCharge($param)
{
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::CHARGE_TYPE;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_GET;
$this->flushState();
$isChargeIdValid = CheckoutApi_Client_Validation_GW3::isChargeIdValid($param);
$uri = $this->getUriCharge();
if(!$isChargeIdValid) {
$hasError = true;
$this->throwException('Please provide a valid charge id',array('param'=>$param));
} else {
$uri = "$uri/{$param['chargeId']}";
}
return $this->_responseUpdateStatus($this->request($uri ,$param,!$hasError));
}
|
Get Charge.
Get the specified Card Charge by setting the values of the parameters passed.
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['postedParam'] = array ('description'=> 'dhiraj is doing some test');
$updateCharge = $Api->updateCharge($param);
|
entailment
|
public function createLocalPaymentCharge($param)
{
$hasError = false;
$param['postedParam']['type'] = CheckoutApi_Client_Constant::LOCALPAYMENT_CHARGE_TYPE;
$postedParam = $param['postedParam'];
$this->flushState();
$uri = $this->getUriCharge();
$isValidEmail = CheckoutApi_Client_Validation_GW3::isEmailValid($postedParam);
$isValidSessionToken = CheckoutApi_Client_Validation_GW3::isSessionToken($postedParam);
$isValidLocalPaymentHash = CheckoutApi_Client_Validation_GW3::isLocalPyamentHashValid($postedParam);
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_POST;
if(!$isValidEmail){
$hasError = true;
$this->throwException('Please provide a valid email address',array('postedParam'=>$postedParam));
}
if(!$isValidSessionToken){
$hasError = true;
$this->throwException('Please provide a valid session token',array('postedParam'=>$postedParam));
}
if(!$isValidLocalPaymentHash){
$hasError = true;
$this->throwException('Please provide a local payment hash',array('postedParam'=>$postedParam));
}
if(!isset($param['postedParam']['localPayment']['userData']) ) {
$param['postedParam']['localPayment']['userData'] = '{}';
}
return $this->request( $uri ,$param,!$hasError);
}
|
Create LocalPayment Charge.
Creates a LocalPayment Charge using a Session Token and
@param array $param payload param for creating a localpayment
@return CheckoutApi_Lib_RespondObj
This can be call in this way:
$chargeLocalPaymentConfig['authorization'] = $publicKey ;
$param['postedParam'] = array(
'email' => '[email protected]',
'token' => $Api->getSessionToken($sessionConfig),
'localPayment' => array(
'lppId' => $Api->getLocalPaymentProvider($localPaymentConfig)->getId()
)
) ;
$chargeLocalPaymentObj = $Api->createLocalPaymentCharge($chargeLocalPaymentConfig);
|
entailment
|
public function createCustomer($param)
{
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_POST;
$postedParam = $param['postedParam'];
$this->flushState();
$uri = $this->getUriCustomer();
$isValidEmail = CheckoutApi_Client_Validation_GW3::isEmailValid($postedParam);
$isCardValid = CheckoutApi_Client_Validation_GW3::isCardValid($postedParam);
$isTokenValid = CheckoutApi_Client_Validation_GW3::isCardToken($postedParam);
if(!$isValidEmail) {
$hasError = true;
$this->throwException('Please provide a valid Email Address',array('param'=>$param));
}
if($isTokenValid) {
if(isset($postedParam['card'])) {
$this->throwException('unsetting card object',array('param'=>$param),false);
unset($param['postedParam']['card']);
}
}elseif($isCardValid) {
if(isset($postedParam['token'])){
$this->throwException('unsetting token ',array('param'=>$param),false);
unset($param['postedParam']['token']);
}
}else {
$hasError = true;
$this->throwException('Please provide a valid card detail or card token',array('param'=>$param));
}
return $this->request( $uri ,$param,!$hasError);
}
|
Create a customer
@param array $param payload param for creating a customer
@return CheckoutApi_Lib_RespondObj
@throws Exception
This method can be call in the following way:
$customerConfig['postedParam'] = array (
'email' => '[email protected]',
'name' => 'test customer',
'description' => 'desc',
'card' => array(
'name' => 'test name',
'number' => '4543474002249996',
'expiryMonth' => 06,
'expiryYear' => 2017,
'cvv' => 956,
)
);
$customer = $Api->createCustomer($customerConfig);
|
entailment
|
public function updateCustomer($param)
{
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_PUT;
$this->flushState();
$uri = $this->getUriCustomer();
$isCustomerIdValid = CheckoutApi_Client_Validation_GW3::isCustomerIdValid($param);
if(!$isCustomerIdValid) {
$hasError = true;
$this->throwException('Please provide a valid customer id',array('param'=>$param));
}else {
$uri = "$uri/{$param['customerId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Update Customer
@param array $param payload param for updating
@return CheckoutApi_Lib_RespondObj
@throws Exception
This method can be call in the following way:
$param['customerId'] = {$customerId} ;
$param['postedParam'] = array (
'email' => '[email protected]',
'name' => 'customer name',
'description' => 'desc',
'card' => array(
'name' => 'test name',
'number' => '4543474002249996',
'expiryMonth' => 06,
'expiryYear' => 2017,
'cvv' => 956,
)
);
$customerUpdate = $Api->updateCustomer($param);
|
entailment
|
public function getListCustomer($param)
{
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_GET;
$this->flushState();
$uri = $this->getUriCustomer();
$delimiter = '?';
$createdAt = 'created=';
if(isset($param['created_on'])) {
$uri="{$uri}{$delimiter}{$createdAt}{$param['created_on']}|";
$delimiter = '&';
}else {
if (isset($param['from_date'])) {
$fromDate = time($param['from_date']);
$uri = "{$uri}{$delimiter}{$createdAt}{$fromDate}";
$delimiter = '&';
$createdAt = '|';
}
if (isset($param['to_date'])) {
$toDate = time($param['to_date']);
$uri = "{$uri}{$createdAt}{$toDate}";
$delimiter = '&';
}
}
if(isset($param['count'])){
$uri = "{$uri}{$delimiter}count={$param['count']}";
$delimiter = '&';
}
if(isset($param['offset'])){
$uri = "{$uri}{$delimiter}offset={$param['offset']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Getting a list of customer
@param array $param payload param for getting list of customer.
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple Usage:
$param['count'] = 100 ;
$param['from_date'] = '09/30/2014' ;
$param['to_date'] = '10/02/2014' ;
$customerUpdate = $Api->getListCustomer($param);
|
entailment
|
public function deleteCustomer($param)
{
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_DELETE;
$this->flushState();
$uri = $this->getUriCustomer();
$hasError = false;
$isCustomerIdValid = CheckoutApi_Client_Validation_GW3::isCustomerIdValid($param);
if(!$isCustomerIdValid) {
$hasError = true;
$this->throwException('Please provide a valid customer id',array('param'=>$param));
}else {
$uri = "$uri/{$param['customerId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Delete a customer
@param array $param payload param for deleteing a customer
@return CheckoutApi_Lib_RespondObj
@throws Exception
This method can be call this way:
$param['customerId'] = {$customerId} ;
$deleteCustomer = $Api->deleteCustomer($param);
|
entailment
|
public function createCard($param)
{
$this->flushState();
$uri = $this->getUriCustomer();
$hasError = false;
$postedParam = $param['postedParam'];
$isCustomerIdValid = CheckoutApi_Client_Validation_GW3::isCustomerIdValid($param);
$isCardValid = CheckoutApi_Client_Validation_GW3::isCardValid($postedParam);
if(!$isCustomerIdValid) {
$hasError = true;
$this->throwException('Please provide a valid customer id',array('param'=>$param));
}else {
$uri = "$uri/{$param['customerId']}/cards";
}
if(!$isCardValid) {
$hasError = true;
$this->throwException('Please provide a valid card object',array('param'=>$param));
}
return $this->request( $uri ,$param,!$hasError);
}
|
Creating a card, link to a customer
@param array $param payload param for creating a card
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['customerId'] = $Api->createCustomer($customerConfig)->getId() ;
$param['postedParam'] = array (
'customerID'=> $customerId,
'card' => array(
'name'=>'test name',
'number' => '4543474002249996',
'expiryMonth' => 06,
'expiryYear' => 2017,
'cvv' => 956,
)
);
$cardObj = $Api->createCard($param);
The creadCard method can be call this way and it required a customer id
|
entailment
|
public function updateCard($param)
{
$this->flushState();
$uri = $this->getUriCustomer();
$hasError = false;
// $param['method'] = CheckoutApi_Client_Adapter_Constant::API_PUT;
$isCustomerIdValid = CheckoutApi_Client_Validation_GW3::isCustomerIdValid($param);
$isCardIdValid = CheckoutApi_Client_Validation_GW3::isGetCardIdValid($param);
if(!$isCustomerIdValid) {
$hasError = true;
$this->throwException('Please provide a valid customer id',array('param'=>$param));
}elseif(!$isCardIdValid){
$hasError = true;
$this->throwException('Please provide a valid card id',array('param'=>$param));
} else {
$uri = "$uri/{$param['customerId']}/cards/{$param['cardId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Update a card
@param array $param payload param for update a card
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['customerId'] = $customerId ;
$param['cardId'] = $cardId ;
$param['postedParam'] = array (
'card' => array(
'name' => 'New name',
'number' => '4543474002249996',
'expiryMonth' => 08,
'expiryYear' => 2017,
'cvv' => 956,
)
);
$updateCardObj = $Api->updateCard($param);
|
entailment
|
public function getCard($param)
{
$this->flushState();
$uri = $this->getUriCustomer();
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_GET;
$isCustomerIdValid = CheckoutApi_Client_Validation_GW3::isCustomerIdValid($param);
$isCardIdValid = CheckoutApi_Client_Validation_GW3::isGetCardIdValid($param);
if(!$isCustomerIdValid) {
$hasError = true;
$this->throwException('Please provide a valid customer id',array('param'=>$param));
}elseif(!$isCardIdValid){
$hasError = true;
$this->throwException('Please provide a valid card id',array('param'=>$param));
} else {
$uri = "$uri/{$param['customerId']}/cards/{$param['cardId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Get a card
@param array $param payload param for getting a card info
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['customerId'] = $customerId ;
$param['cardId'] = $cardId ;
$getCardObj = $Api->getCard($param);
Required a customer id and a card id to work
|
entailment
|
public function getCardList($param)
{
$this->flushState();
$uri = $this->getUriCustomer();
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_GET;
$isCustomerIdValid = CheckoutApi_Client_Validation_GW3::isCustomerIdValid($param);
if(!$isCustomerIdValid) {
$hasError = true;
$this->throwException('Please provide a valid customer id',array('param'=>$param));
} else {
$uri = "$uri/{$param['customerId']}/cards";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Get Card List
@param array $param payload param for getting a list of cart
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['customerId'] = $customerId ;
$getCardListObj = $Api->getCardList($param);
Require a customer id
|
entailment
|
public function deleteCard($param)
{
$this->flushState();
$uri = $this->getUriCustomer();
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_DELETE;
$isCustomerIdValid = CheckoutApi_Client_Validation_GW3::isCustomerIdValid($param);
$isCardIdValid = CheckoutApi_Client_Validation_GW3::isGetCardIdValid($param);
if(!$isCustomerIdValid) {
$hasError = true;
$this->throwException('Please provide a valid customer id',array('param'=>$param));
}elseif(!$isCardIdValid){
$hasError = true;
$this->throwException('Please provide a valid card id',array('param'=>$param));
} else {
$uri = "$uri/{$param['customerId']}/cards/{$param['cardId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Get Card List
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['customerId'] = $customerId ;
$param['cardId'] = $cardId ;
$deleteCard = $Api->deleteCard($param);
|
entailment
|
public function getLocalPaymentList($param)
{
$this->flushState();
$uri = $this->getUriProvider();
$hasError = false;
$isTokenValid = CheckoutApi_Client_Validation_GW3::isSessionToken($param);
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_GET;
$delimiter = '/localpayments?';
if(!$isTokenValid) {
$hasError = true;
$this->throwException('Please provide a valid session token',array('param'=>$param));
}else {
$uri = "{$uri}{$delimiter}token={$param['token']}";
$delimiter ='&';
if(isset($param['countryCode'])){
$uri = "{$uri}{$delimiter}countryCode={$param['countryCode']}";
$delimiter ='&';
}
if(isset($param['ip'])){
$uri = "{$uri}{$delimiter}ip={$param['ip']}";
$delimiter ='&';
}
if(isset($param['limit'])){
$uri = "{$uri}{$delimiter}limit={$param['limit']}";
$delimiter ='&';
}
if(isset($param['region'])){
$uri = "{$uri}{$delimiter}region={$param['region']}";
$delimiter ='&';
}
if(isset($param['name'])){
$uri = "{$uri}{$delimiter}name={$param['name']}";
}
}
return $this->request( $uri ,$param,!$hasError);
}
|
Get LocalPayment Provider list
@param array $param payload param for retriving a list of local payment provider
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['token'] = $sessionToken ;
$localPaymentListObj = $Api->getLocalPaymentList($param);
refer to create sesssionToken for getting the session token value
|
entailment
|
public function getLocalPaymentProvider($param)
{
$this->flushState();
$uri = $this->getUriProvider();
$hasError = false;
$isTokenValid = CheckoutApi_Client_Validation_GW3::isSessionToken($param);
$isValidProvider = CheckoutApi_Client_Validation_GW3::isProvider($param);
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_GET;
$delimiter = '/localpayments/';
if(!$isTokenValid) {
$hasError = true;
$this->throwException('Please provide a valid session token',array('param'=>$param));
}
if(!$isValidProvider)
{
$hasError = true;
$this->throwException('Please provide a valid provider id',array('param'=>$param));
}
if(!$hasError){
$uri = "{$uri}{$delimiter}{$param['providerId']}?token={$param['token']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Get LocalPayment Provider
@param array $param payload param for getting a local payment provider dettail
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['token'] = $sessionToken ;
$param['providerId'] = $providerId ;
$localPaymentObj = $Api->getLocalPaymentProvider($param);
|
entailment
|
public function getCardProvidersList($param)
{
$this->flushState();
$uri = $this->getUriProvider().'/cards';
$hasError = false;
return $this->request( $uri ,$param,!$hasError);
}
|
Get Card Provider list
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$cardProviderListObj = $Api->getCardProvidersList($param);
|
entailment
|
public function getCardProvider($param)
{
$this->flushState();
$isValidProvider = CheckoutApi_Client_Validation_GW3::isProvider($param);
$uri = $this->getUriProvider().'/cards';
$hasError = false;
if(!$isValidProvider)
{
$hasError = true;
$this->throwException('Please provide a valid provider id',array('param'=>$param));
}
if(!$hasError){
$uri = "{$uri}/{$param['providerId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Get a list of card provider
@param array $param payload param for retriving a list of card by providers
@return CheckoutApi_Lib_RespondObj
Simple usage:
$param['providerId'] = $providerId ;
$cardProvidersObj = $Api->getCardProvider($param);
|
entailment
|
public function updatePaymentPlan($param)
{
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_PUT;
$this->flushState();
$uri = $this->getUriRecurringPayments().'/plans';;
$isPlanIdValid = CheckoutApi_Client_Validation_GW3::isPlanIdValid($param);
if(!$isPlanIdValid) {
$hasError = true;
$this->throwException('Please provide a valid plan id',array('param'=>$param));
} else {
$uri = "$uri/{$param['planId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Update Recurring Payment Plan.
Updates the specified Recurring Payment Plan by setting the values of the parameters passed.
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['planId'] = {$planId} ;
$param['postedParam'] = array (
'name' => 'New subscription name',
'planTrackId' => 'newPlanTrackId',
'autoCapTime' => 24,
'value' => 200,
'status' => 4
);
$updateCharge = $Api->updateCharge($param);
|
entailment
|
public function cancelPaymentPlan($param)
{
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_DELETE;
$this->flushState();
$uri = $this->getUriRecurringPayments().'/plans';
$hasError = false;
$isPlanIdValid = CheckoutApi_Client_Validation_GW3::isPlanIdValid($param);
if(!$isPlanIdValid ) {
$hasError = true;
$this->throwException('Please provide a valid plan id',array('param'=>$param));
}else {
$uri = "$uri/{$param['planId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Cancel a payment plan
@param array $param payload param for deleting a payment plan
@return CheckoutApi_Lib_RespondObj
@throws Exception
This method can be call this way:
$param['planId'] = {$planId} ;
cancelPaymentPlan = $Api->cancelPaymentPlan($param);
|
entailment
|
public function getPaymentPlan($param)
{
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_GET;
$this->flushState();
$uri = $this->getUriRecurringPayments().'/plans';;
$isPlanIdValid = CheckoutApi_Client_Validation_GW3::isPlanIdValid($param);
if(!$isPlanIdValid) {
$hasError = true;
$this->throwException('Please provide a valid plan id',array('param'=>$param));
}else {
$uri = "$uri/{$param['customerId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Get payment plan
@param array $param payload param for returning a payment plan
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage :
$param['planId'] = {planId} ;
$getPaymentPlan = $Api->getPaymentPlan($param);
|
entailment
|
public function updateCustomerPaymentPlan($param)
{
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_PUT;
$this->flushState();
$uri = $this->getUriRecurringPayments().'/customers';;
$isCustomerPlanIdValid = CheckoutApi_Client_Validation_GW3::isCustomerPlanIdValid($param);
if(!$isCustomerPlanIdValid) {
$hasError = true;
$this->throwException('Please provide a valid customer plan id',array('param'=>$param));
} else {
$uri = "$uri/{$param['customerPlanId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Update Recurring Customer Payment Plan.
Updates the specified Recurring Customer Payment Plan by setting the values of the parameters passed.
@param array $param payload param
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage:
$param['customerPlanId'] = {$customerPlanId} ;
$param['postedParam'] = array (
'cardId' => 'card_XXXXXXXX',
'status' => 1
);
$updateCharge = $Api->updateCharge($param);
|
entailment
|
public function cancelCustomerPaymentPlan($param)
{
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_DELETE;
$this->flushState();
$uri = $this->getUriRecurringPayments().'/customers';
$hasError = false;
$isCustomerPlanIdValid = CheckoutApi_Client_Validation_GW3::isCustomerPlanIdValid($param);
if(!$isCustomerPlanIdValid ) {
$hasError = true;
$this->throwException('Please provide a valid customer plan id',array('param'=>$param));
}else {
$uri = "$uri/{$param['customerPlanId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Cancel a customer payment plan
@param array $param payload param for deleting a payment plan
@return CheckoutApi_Lib_RespondObj
@throws Exception
This method can be call this way:
$param['customerPlanId'] = {$customerPlanId} ;
cancelCustomerPaymentPlan = $Api->cancelCustomerPaymentPlan($param);
|
entailment
|
public function getCustomerPaymentPlan($param)
{
$hasError = false;
$param['method'] = CheckoutApi_Client_Adapter_Constant::API_GET;
$this->flushState();
$uri = $this->getUriRecurringPayments().'/customers';;
$isCustomerPlanIdValid = CheckoutApi_Client_Validation_GW3::isCustomerPlanIdValid($param);
if(!$isCustomerPlanIdValid) {
$hasError = true;
$this->throwException('Please provide a valid plan id',array('param'=>$param));
}else {
$uri = "$uri/{$param['customerPlanId']}";
}
return $this->request( $uri ,$param,!$hasError);
}
|
Get customer payment plan
@param array $param payload param for returning a payment plan
@return CheckoutApi_Lib_RespondObj
@throws Exception
Simple usage :
$param['customerPlanId'] = {customerPlanId} ;
$getCustomerPaymentPlan = $Api->getCustomerPaymentPlan($param);
|
entailment
|
public function request($uri,array $param, $state)
{
/** @var CheckoutApi_Lib_RespondObj $respond */
$respond = CheckoutApi_Lib_Factory::getSingletonInstance('CheckoutApi_Lib_RespondObj');
$this->setConfig($param);
if(!isset($param['postedParam'])) {
$param['postedParam'] = array();
}
$param['rawpostedParam'] = $param['postedParam'];
$param['postedParam'] = $this->getParser()->preparePosted($param['postedParam']);
$respondArray = null;
if($state){
$headers = $this->initHeader();
$param['headers'] = $headers;
/** @var CheckoutApi_Client_Adapter_Abstract $adapter */
$adapter = $this->getAdapter($this->getProcessType(),array('uri'=>$uri,'config'=>$param));
if($adapter){
$adapter->connect();
$respondString = $adapter->request()->getRespond();
$statusResponse = $adapter->getResourceInfo();
$this->getParser()->setResourceInfo($statusResponse);
$respond = $this->getParser()->parseToObj($respondString);
if($respond && isset($respond['errors']) && $respond->hasErrors() ) {
/** @var CheckoutApi_Lib_ExceptionState $exceptionStateObj */
$exceptionStateObj = $respond->getExceptionState();
$errors = $respond->getErrors()->toArray();
$exceptionStateObj->flushState();
foreach( $errors as $error) {
$this->throwException($error, $respond->getErrors()->toArray());
}
}elseif( $respond && isset($respond['errorCode']) && $respond->hasErrorCode()) {
/** @var CheckoutApi_Lib_ExceptionState $exceptionStateObj */
$exceptionStateObj = $respond->getExceptionState();
$this->throwException($respond->getMessage(),$respond->toArray() );
}elseif($respond && $respond->getHttpStatus()!='200') {
$this->throwException('Gateway is temporary down',$param );
}
$adapter->close();
}
}
return $respond;
}
|
Build up the request to the gateway
@param string $uri endpoint to be used
@param array $param payload param
@param boolean $state if error occured don't send charge
@return CheckoutApi_Lib_RespondObj
@throws Exception
|
entailment
|
public function getMode()
{
if(isset($this->_config['mode']) && $this->_config['mode']) {
$this->_mode =$this->_config['mode'];
}
return $this->_mode;
}
|
return the mode . can be either dev or preprod or live
@return string
|
entailment
|
public function setUriCharge( $uri = '',$sufix ='')
{
$toSetUri = $uri;
if(!$uri) {
$toSetUri = $this->getUriPrefix().'charges';
}
if($sufix) {
$toSetUri .= "/$sufix";
}
$this->_uriCharge = $toSetUri;
}
|
A method that set it charge url
@param string $uri set the endpoint url
@param string $sufix a sufix to the cart token
|
entailment
|
public function setUriToken($uri = null)
{
$toSetUri = $uri;
if(!$uri) {
$toSetUri = $this->getUriPrefix().'tokens';
}
$this->_uriToken = $toSetUri;
}
|
set uri token
@param null|string $uri the uri for the token
|
entailment
|
public function setUriCustomer( $uri = null)
{
$toSetUri = $uri;
if(!$uri) {
$toSetUri = $this->getUriPrefix().'customers';
}
$this->_uriCustomer = $toSetUri;
}
|
set customer uri
@param null|string $uri endpoint url for customer
|
entailment
|
public function setUriProvider( $uri = null)
{
$toSetUri = $uri;
if(!$uri) {
$toSetUri = $this->getUriPrefix().'providers';
}
$this->_uriProvider = $toSetUri;
}
|
set provider uri
@param null|string $uri endpoint url for provider
|
entailment
|
public function setUriRecurringPayments($uri = null)
{
$toSetUri = $uri;
if(!$uri) {
$toSetUri = $this->getUriPrefix().'recurringPayments';
}
$this->_uriRecurringPayments = $toSetUri;
}
|
set uri recurring payments
@param null|string $uri the uri for the recurring payments
|
entailment
|
private function getUriPrefix()
{
$mode = strtolower($this->getMode());
switch ($mode) {
case 'live':
$prefix = CheckoutApi_Client_Constant::APIGW3_URI_PREFIX_LIVE.CheckoutApi_Client_Constant::VERSION.'/';
break;
default :
$prefix = CheckoutApi_Client_Constant::APIGW3_URI_PREFIX_SANDBOX.CheckoutApi_Client_Constant::VERSION.'/';
break;
}
return $prefix;
}
|
return which uri prefix to be used base on mode type
@return string
|
entailment
|
private function throwException($message,array $stackTrace , $error = true )
{
$this->exception($message,$stackTrace,$error);
}
|
setting exception state log
@param string $message error message
@param array $stackTrace statck trace
@param boolean $error if it's an error
|
entailment
|
public function flushState()
{
parent::flushState();
if($mode = $this->getMode()) {
$this->setMode($mode);
}
$this->setUriCharge();
$this->setUriToken();
$this->setUriCustomer();
$this->setUriProvider();
$this->setUriRecurringPayments();
}
|
flushing all config
@todo need to remove singleton concept causing issue
@reset all state
@throws Exception
|
entailment
|
public function isAuthorise($response){
$result = false;
$hasError = $this->isError($response);
$isApprove = $this->isApprove($response);
if(!$hasError && $isApprove){
$result = true;
}
return $result;
}
|
Check charge response
If response is approve or has error, return boolean
|
entailment
|
protected function isApprove($response){
$result = false;
if($response->getResponseCode() == CheckoutApi_Client_Constant::RESPONSE_CODE_APPROVED
|| $response->getResponseCode()== CheckoutApi_Client_Constant::RESPONSE_CODE_APPROVED_RISK ){
$result = true;
}
return $result;
}
|
Check if response is approve
return boolean
|
entailment
|
public function getResponseId($response){
$isError = $this->isError($response);
if($isError){
$result = array (
'message' => $response->getMessage(),
'eventId' => $response->getEventId()
);
return $result;
} else {
$result = array (
'responseMessage' => $response->getResponseMessage(),
'id' => $response->getId()
);
return $result;
}
}
|
return eventId if charge has error.
return chargeID if charge is decline
|
entailment
|
public function isFlagResponse($response){
$result = false;
if($response->getResponseCode() == CheckoutApi_Client_Constant::RESPONSE_CODE_APPROVED_RISK){
$result = array(
'responseMessage' => $response->getResponseMessage(),
);
}
return $result;
}
|
Check if response is flag
return response message
|
entailment
|
public function createSinglePlan(RequestModels\BaseRecurringPayment $requestModel)
{
$recurringPaymentMapper = new \com\checkout\ApiServices\RecurringPayments\RecurringPaymentMapper($requestModel);
$requestPayload = array (
'authorization' => $this->_apiSetting->getSecretKey(),
'mode' => $this->_apiSetting->getMode(),
'postedParam' => $recurringPaymentMapper->requestPayloadConverter(),
);
$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($this->_apiUrl->getRecurringPaymentsApiUri(),
$this->_apiSetting->getSecretKey(),$requestPayload);
$responseModel = new ResponseModels\RecurringPayment($processCharge);
return $responseModel;
}
|
Creates a new payment plan
@param RequestModels\BaseRecurringPayment $requestModel
@return ResponseModels\RecurringPayment
|
entailment
|
public function getAdapter($adapterName, $arguments = array())
{
$stdName = ucfirst($adapterName);
$classAdapterName = CheckoutApi_Client_Constant::ADAPTER_CLASS_GROUP.$stdName;
$class = null;
if (class_exists($classAdapterName)) {
/** @var CheckoutApi_Client_Adapter_Abstract $class */
$class = CheckoutApi_Lib_Factory::getSingletonInstance($classAdapterName,$arguments);
if(isset($arguments['uri'])) {
$class->setUri($arguments['uri']);
}
if(isset($arguments['config'])) {
$class->setConfig($arguments['config']);
}
} else {
$this->exception("Not a valid Adapter", debug_backtrace());
}
return $class;
}
|
CheckoutApi_ initialise return an adapter.
@param $adapterName Adapter Name
@param array $arguments argument for creating the adapter
@return CheckoutApi_Client_Adapter_Abstract|null
@throws Exception
|
entailment
|
public function setHeaders($headers)
{
if(!$this->_parserObj) {
$this->initParser($this->getRespondType());
}
/** @var array _headers */
$this->_headers = $this->getParser()->getHeaders();
$this->_headers = array_merge($this->_headers,$headers);
}
|
set the headers array base on which paser we are using
@param array $headers extra headers
|
entailment
|
public function getRespondType()
{
$_respondType = $this->_respondType;
if($respondType = $this->getConfig('respondType')) {
$_respondType = $respondType;
}
return $_respondType;
}
|
return the respond type default json
@return string
|
entailment
|
public function initParser()
{
$parserType = CheckoutApi_Client_Constant::PARSER_CLASS_GROUP.$this->getRespondType();
$parserObj = CheckoutApi_Lib_Factory::getSingletonInstance($parserType) ;
$this->setParser($parserObj);
}
|
create and set a parser
@throws Exception
|
entailment
|
public function parseToObj($parser)
{
/** @var CheckoutApi_Lib_RespondObj $respondObj */
$respondObj = CheckoutApi_Lib_Factory::getInstance('CheckoutApi_Lib_RespondObj');
if($parser && is_string ($parser)) {
$encoding = mb_detect_encoding($parser);
if($encoding =="ASCII") {
$parser = iconv('ASCII', 'UTF-8', $parser);
}else {
$parser = mb_convert_encoding($parser, "UTF-8", $encoding);
}
$jsonObj = json_decode($parser,true);
$jsonObj['rawOutput'] = $parser;
$respondObj->setConfig($jsonObj);
}
$respondObj->setConfig($this->getResourceInfo());
return $respondObj;
}
|
Convert a json to a CheckoutApi_Lib_RespondObj object
@param JSON $parser
@return CheckoutApi_Lib_RespondObj|null
@throws Exception
|
entailment
|
public static function getApi(array $arguments = array(),$_apiClass = null)
{
if($_apiClass) {
self::setApiClass($_apiClass);
}
//Initialise the exception library
$exceptionState = CheckoutApi_Lib_Factory::getSingletonInstance('CheckoutApi_Lib_ExceptionState');
$exceptionState->setErrorState(false);
return CheckoutApi_Lib_Factory::getSingletonInstance(self::getApiClass(),$arguments);
}
|
Helper static function to get singleton instance of a gateway interface.
@param array $arguments A set arguments for initialising class constructor.
@param null|string $_apiClass Gateway class name.
@return CheckoutApi_Client_Client An singleton instance of CheckoutApi_Client_Client
@throws Exception
|
entailment
|
public function getConfig($key = null)
{
if($key!=null && isset($this->_config[$key])) {
return $this->_config[$key];
} elseif($key == null) {
return $this->_config;
}
return null;
}
|
A method that get the configuration for an object
@param null $key name of configuration you wnat to retrive
@return array|null
|
entailment
|
public function setConfig($config = array())
{
if(is_array($config) ) {
if(!empty($config)) {
foreach($config as $key=>$value) {
$this->_config[$key] = $value;
}
}
} else {
throw new Exception( "Invalid parameter");
}
}
|
A settter. it get an array and update or add new configuration value to object
@param array $config configuration value
@throws Exception
|
entailment
|
public function exception($errorMsg, array $trace, $error = true )
{
$classException = "CheckoutApi_Lib_ExceptionState";
if (class_exists($classException)) {
/** @var CheckoutApi_Lib_ExceptionState $class */
$class = CheckoutApi_Lib_Factory::getSingletonInstance($classException);
} else {
throw new Exception("Not a valid class :: CheckoutApi_Lib_ExceptionState");
}
$class->setLog($errorMsg,$trace,$error);
return $class;
}
|
setting and logging error message
@param string $errorMsg error message you wan to log
@param array $trace stack trace
@param bool $error state of the error. true for important error
@return mixed
@throws Exception
|
entailment
|
public function chargeWithCard(RequestModels\CardChargeCreate $requestModel)
{
$chargeMapper = new ChargesMapper($requestModel);
$requestPayload = array (
'authorization' => $this->_apiSetting->getSecretKey(),
'mode' => $this->_apiSetting->getMode(),
'postedParam' => $chargeMapper->requestPayloadConverter(),
);
$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($this->_apiUrl->getCardChargesApiUri(),
$this->_apiSetting->getSecretKey(),$requestPayload);
$responseModel = new ResponseModels\Charge($processCharge);
return $responseModel;
}
|
Creates a charge with full card details.
@param RequestModels\CardChargeCreate $requestModel
@return ResponseModels\Charge
|
entailment
|
public function chargeWithCardToken(RequestModels\CardTokenChargeCreate
$requestModel)
{
$chargeMapper = new ChargesMapper($requestModel);
$requestPayload = array (
'authorization' => $this->_apiSetting->getSecretKey(),
'mode' => $this->_apiSetting->getMode(),
'postedParam' => $chargeMapper->requestPayloadConverter(),
);
$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($this->_apiUrl->getCardTokensApiUri(),
$this->_apiSetting->getSecretKey(),$requestPayload);
$responseModel = new ResponseModels\Charge($processCharge);
return $responseModel;
}
|
Creates a charge with cardToken.
@param RequestModels\CardTokenChargeCreate $requestModel
@return ResponseModels\Charge
|
entailment
|
public function chargeWithDefaultCustomerCard(RequestModels\BaseCharge
$requestModel)
{
$chargeMapper = new ChargesMapper($requestModel);
$requestPayload = array (
'authorization' => $this->_apiSetting->getSecretKey(),
'mode' => $this->_apiSetting->getMode(),
'postedParam' => $chargeMapper->requestPayloadConverter(),
);
$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($this->_apiUrl->getDefaultCardChargesApiUri(),
$this->_apiSetting->getSecretKey(),$requestPayload);
$responseModel = new ResponseModels\Charge($processCharge);
return $responseModel;
}
|
Creates a charge with Default Customer Card.
@param RequestModels\BaseCharge $requestModel
@return ResponseModels\Charge
|
entailment
|
public function refundCardChargeRequest(RequestModels\ChargeRefund
$requestModel)
{
$chargeMapper = new ChargesMapper($requestModel);
$requestPayload = array (
'authorization' => $this->_apiSetting->getSecretKey(),
'mode' => $this->_apiSetting->getMode(),
'postedParam' => $chargeMapper->requestPayloadConverter(),
);
$refundUri = sprintf ($this->_apiUrl->getChargeRefundsApiUri(),$requestModel->getChargeId());
$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($refundUri,
$this->_apiSetting->getSecretKey(),$requestPayload);
$responseModel = new ResponseModels\Charge($processCharge);
return $responseModel;
}
|
refund a charge
@param RequestModels\ChargeRefund $requestModel
@return ResponseModels\Charge
|
entailment
|
public function voidCharge($chargeId , RequestModels\ChargeVoid
$requestModel)
{
$chargeMapper = new ChargesMapper($requestModel);
$requestPayload = array (
'authorization' => $this->_apiSetting->getSecretKey(),
'mode' => $this->_apiSetting->getMode(),
'postedParam' => $chargeMapper->requestPayloadConverter(),
);
$refundUri = sprintf ($this->_apiUrl->getVoidChargesApiUri(),$chargeId);
$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($refundUri,
$this->_apiSetting->getSecretKey(),$requestPayload);
$responseModel = new ResponseModels\Charge($processCharge);
return $responseModel;
}
|
void a charge
@param RequestModels\ChargeVoid $requestModel
@return ResponseModels\Charge
|
entailment
|
public function CaptureCardCharge(RequestModels\ChargeCapture
$requestModel)
{
$chargeMapper = new ChargesMapper($requestModel);
$requestPayload = array (
'authorization' => $this->_apiSetting->getSecretKey(),
'mode' => $this->_apiSetting->getMode(),
'postedParam' => $chargeMapper->requestPayloadConverter(),
);
$refundUri = sprintf ($this->_apiUrl->getCaptureChargesApiUri(),$requestModel->getChargeId());
$processCharge = \com\checkout\helpers\ApiHttpClient::postRequest($refundUri,
$this->_apiSetting->getSecretKey(),$requestPayload);
$responseModel = new ResponseModels\Charge($processCharge);
return $responseModel;
}
|
Capture a charge
@param RequestModels\ChargeCapture $requestModel
@return ResponseModels\Charge
|
entailment
|
public function UpdateCardCharge(RequestModels\ChargeUpdate
$requestModel)
{
$chargeMapper = new ChargesMapper($requestModel);
$requestPayload = array (
'authorization' => $this->_apiSetting->getSecretKey(),
'mode' => $this->_apiSetting->getMode(),
'postedParam' => $chargeMapper->requestPayloadConverter(),
);
$updateUri = sprintf ($this->_apiUrl->getUpdateChargesApiUri(),$requestModel->getChargeId());
$processCharge = \com\checkout\helpers\ApiHttpClient::putRequest($updateUri,
$this->_apiSetting->getSecretKey(),$requestPayload);
$responseModel = new \com\checkout\ApiServices\SharedModels\OkResponse($processCharge);
return $responseModel;
}
|
Update a charge
@param RequestModels\ChargeUpdate $requestModel
@return ResponseModels\Charge
|
entailment
|
public function getChargeHistory($chargeId)
{
$requestPayload = array (
'authorization' => $this->_apiSetting->getSecretKey(),
'mode' => $this->_apiSetting->getMode(),
'method' => 'GET',
);
$retrieveChargeHistoryWithChargeUri = sprintf ($this->_apiUrl->getRetrieveChargeHistoryApiUri(),$chargeId);
$processCharge = \com\checkout\helpers\ApiHttpClient::getRequest($retrieveChargeHistoryWithChargeUri,
$this->_apiSetting->getSecretKey(),$requestPayload);
$responseModel = new ResponseModels\ChargeHistory($processCharge);
return $responseModel;
}
|
retrieve a Charge History With a ChargeId
@param RequestModels\ChargeRetrieve $requestModel
@return ResponseModels\ChargeHistory
|
entailment
|
public static function isEmailValid($postedParam)
{
$isEmailEmpty = true;
$isValidEmail = false;
if(isset($postedParam['email'])) {
$isEmailEmpty = CheckoutApi_Lib_Validator::isEmpty($postedParam['email']);
}
if(!$isEmailEmpty) {
$isValidEmail = CheckoutApi_Lib_Validator::isValidEmail($postedParam['email']);
}
return !$isEmailEmpty && $isValidEmail;
}
|
A helper method to check if email has been set in the payload and if it's a valid email
@param array $postedParam
@return boolean
CheckoutApi_ check if email valid
Simple usage:
CheckoutApi_Client_Validation_GW3::isEmailValid($postedParam);
|
entailment
|
public static function isCustomerIdValid($postedParam)
{
$isCustomerIdEmpty = true;
$isValidCustomerId = false;
if(isset($postedParam['customerId'])) {
$isCustomerIdEmpty = CheckoutApi_Lib_Validator::isEmpty($postedParam['customerId']);
}
if(!$isCustomerIdEmpty) {
$isValidCustomerId = CheckoutApi_Lib_Validator::isString($postedParam['customerId']);
}
return !$isCustomerIdEmpty && $isValidCustomerId;
}
|
A helper method that is use to check if payload has set a customer id.
@param array $postedParam
@return boolean
check if customer id is valid.
Simple usage:
CheckoutApi_Client_Validation_GW3::CustomerIdValid($postedParam);
|
entailment
|
public static function isValueValid($postedParam)
{
$isValid = false;
if(isset($postedParam['value'])) {
$amount = $postedParam['value'];
$isAmountEmpty = CheckoutApi_Lib_Validator::isEmpty($amount);
if(!$isAmountEmpty ) {
$isValid = true;
}
}
return $isValid;
}
|
A helper method that is use to valid if amount is correct in a payload.
@param array $postedParam
@return boolean
CheckoutApi_ check if amount is valid.
Simple usage:
CheckoutApi_Client_Validation_GW3::isValueValid($postedParam)
|
entailment
|
public static function isValidCurrency($postedParam)
{
$isValid = false;
if(isset($postedParam['currency'])) {
$currency = $postedParam['currency'];
$currencyEmpty = CheckoutApi_Lib_Validator::isEmpty($currency);
if(!$currencyEmpty){
$isCurrencyLen = CheckoutApi_Lib_Validator::isLength($currency, 3);
if($isCurrencyLen) {
$isValid = true;
}
}
}
return $isValid;
}
|
A helper method that is use check if payload has a currency set and if length of currency value is 3
@param array $postedParam
@return boolean
Simple usage:
CheckoutApi_Client_Validation_GW3::isValidCurrency($postedParam);
|
entailment
|
public static function isNameValid($postedParam)
{
$isValid = false;
if(isset($postedParam['name'])) {
$isNameEmpty = CheckoutApi_Lib_Validator::isEmpty($postedParam['name']);
if(!$isNameEmpty) {
$isValid = true;
}
}
return $isValid ;
}
|
A helper method that check if a name is set in the payload
@param array $postedParam
@return boolean
Simple usage:
CheckoutApi_Client_Validation_GW3::isNameValid($postedParam);
|
entailment
|
public static function isCardNumberValid($param)
{
$isValid = false;
if(isset($param['number'])) {
$errorIsEmpty = CheckoutApi_Lib_Validator::isEmpty($param['number']) ;
if(!$errorIsEmpty) {
//$this->logError(true, "Card number can not be empty.", array('card'=>$param),false);
$isValid = true;
}
}
return $isValid;
}
|
A helper method that check if card number is set in payload.
@param array $param
@return bool
Simple usage:
CheckoutApi_Client_Validation_GW3::isCardNumberValid($param)
|
entailment
|
public static function isMonthValid($card)
{
$isValid = false;
if(isset($card['expiryMonth'])) {
$isExpiryMonthEmpty = CheckoutApi_Lib_Validator::isEmpty($card['expiryMonth'],false);
if(!$isExpiryMonthEmpty && CheckoutApi_Lib_Validator::isInteger($card['expiryMonth']) && ($card['expiryMonth'] > 0 && $card['expiryMonth'] < 13)) {
$isValid = true;
}
}
return $isValid;
}
|
A helper method that check if month is properly set in payload card object
@param array $card
@return bool
Simple usage:
CheckoutApi_Client_Validation_GW3::isMonthValid($card)
|
entailment
|
public static function isValidYear($card)
{
$isValid = false;
if(isset($card['expiryYear'])) {
$isExpiryYear = CheckoutApi_Lib_Validator::isEmpty($card['expiryYear']);
if( !$isExpiryYear && CheckoutApi_Lib_Validator::isInteger($card['expiryYear']) &&
( CheckoutApi_Lib_Validator::isLength($card['expiryYear'], 2) || CheckoutApi_Lib_Validator::isLength($card['expiryYear'], 4) ) ) {
$isValid = true;
}
}
return $isValid;
}
|
A helper method that check if year is properly set in payload
@param array $card
@return bool
Simple usage:
CheckoutApi_Client_Validation_GW3::isValidYear($card)
|
entailment
|
public static function isValidCvv($card)
{
$isValid = false;
if(isset($card['cvv'])) {
$isCvvEmpty = CheckoutApi_Lib_Validator::isEmpty($card['cvv']);
if(!$isCvvEmpty && CheckoutApi_Lib_Validator::isValidCvvLen($card['cvv'])) {
$isValid = true;
}
}
return $isValid;
}
|
A helper method that check if cvv is properly set in payload
@param array $card
@return bool
Simple usage:
CheckoutApi_Client_Validation_GW3::isValidCvv($card)
|
entailment
|
public static function isCardValid($param)
{
$isValid = true;
if(isset($param['card'])) {
$card = $param['card'];
$isNameValid = CheckoutApi_Client_Validation_GW3::isNameValid($card);
if (!$isNameValid) {
$isValid = false;
}
$isCardNumberValid = CheckoutApi_Client_Validation_GW3::isCardNumberValid($card);
if (!$isCardNumberValid && ! isset($param['card']['number'])) {
$isValid = false;
}
$isValidMonth = CheckoutApi_Client_Validation_GW3::isMonthValid($card);
if (!$isValidMonth && !isset($param['card']['expiryMonth'])) {
$isValid = false;
}
$isValidYear = CheckoutApi_Client_Validation_GW3::isValidYear($card);
if (!$isValidYear && !isset($param['card']['expiryYear'])) {
$isValid = false;
}
$isValidCvv = CheckoutApi_Client_Validation_GW3::isValidCvv($card);
if (!$isValidCvv && !isset($param['card']['cvv'])) {
$isValid = false;
}
return $isValid;
}
return true;
}
|
A helper method that check if card is properly set in payload. It check if expiry date , card number , cvv and name is set
@param $param
@return bool
Simple usage:
CheckoutApi_Client_Validation_GW3::isCardValid($param)
|
entailment
|
public static function isCardIdValid($param)
{
$isValid = false;
if(isset($param['card'])) {
$card = $param['card'];
if(isset($card['id'])) {
$isCardIdEmpty = CheckoutApi_Lib_Validator::isEmpty($card['id']);
if(!$isCardIdEmpty && CheckoutApi_Lib_Validator::isString($card['id']) )
{
$isValid = true;
}
}
return $isValid;
}
return true;
}
|
A helper method that check if card id was set in payload
@param $param
@return bool
Simple usage:
CheckoutApi_Client_Validation_GW3::CardIdValid($param)
|
entailment
|
public static function isGetCardIdValid($param)
{
$isValid = false;
$card = $param['cardId'];
if(isset($param['cardId'])) {
$isValid = self::isCardIdValid(array('card'=>$param['cardId']));
}
return $isValid;
}
|
A helper method that check if card id is set in payload.
The difference between isCardIdValid and isGetCardIdValid is, isCardIdValid check if card id is set
in postedparam where as isGetCardIdValid check if configuration pass has a card id
@param array $param
@return boolean
Simple usage:
CheckoutApi_Client_Validation_GW3::isGetCardIdValid($param)
|
entailment
|
public static function isPhoneNoValid($postedParam)
{
$isValid = false;
if(isset($postedParam['phoneNumber'])) {
$isPhoneEmpty = CheckoutApi_Lib_Validator::isEmpty($postedParam['phoneNumber']);
if(!$isPhoneEmpty && CheckoutApi_Lib_Validator::isString($postedParam['phoneNumber']) ){
$isValid = true;
}
}
return $isValid;
}
|
A helper method that check in payload if phone number was set
@param array $postedParam
@return boolean
|
entailment
|
public static function isCardToken($param)
{
$isValid = false;
if(isset($param['cardToken'])){
$isTokenEmpty = CheckoutApi_Lib_Validator::isEmpty($param['cardToken']);
if(!$isTokenEmpty) {
$isValid = true;
}
}
return $isValid;
}
|
A helper method that check that check if token is set in payload
@param array $param
@return boolean
Simple usage:
CheckoutApi_Client_Validation_GW3::isCardToken($param)
|
entailment
|
public static function isLocalPyamentHashValid($postedParam)
{
$isValid = false;
if(isset($postedParam['localPayment']) && !(CheckoutApi_Lib_Validator::isEmpty($postedParam['localPayment']))) {
if(isset($postedParam['localPayment']['lppId']) && !(CheckoutApi_Lib_Validator::isEmpty($postedParam['localPayment']['lppId']))) {
$isValid = true;
}
}
return $isValid;
}
|
A helper method that check if localpayment object is valid in payload. It check if lppId is set
@param array $postedParam
@return boolean
Simple usage:
CheckoutApi_Client_Validation_GW3::isLocalPyamentHashValid($postedParam)
|
entailment
|
public static function isChargeIdValid($param)
{
$isValid = false;
if(isset($param['chargeId']) && !(CheckoutApi_Lib_Validator::isEmpty($param['chargeId']))) {
$isValid = true;
}
return $isValid;
}
|
A helper method that check if a charge id was set in the payload
@param array $param
@return boolean
Simple usage:
CheckoutApi_Client_Validation_GW3::isChargeIdValid($param)
|
entailment
|
public static function isProvider($param)
{
$isValid = false;
if(isset($param['providerId']) && !(CheckoutApi_Lib_Validator::isEmpty($param['providerId']))) {
$isValid = true;
}
return $isValid;
}
|
A helper method that check provider id is set in payload.
@param $param
@return bool
Simple usage:
CheckoutApi_Client_Validation_GW3::isProvider($param)
|
entailment
|
public static function isPlanIdValid($postedParam)
{
$isPlanIdEmpty = true;
$isValidPlanId = false;
if(isset($postedParam['planId'])) {
$isPlanIdEmpty = CheckoutApi_Lib_Validator::isEmpty($postedParam['planId']);
}
if(!$isPlanIdEmpty) {
$isValidPlanId = CheckoutApi_Lib_Validator::isString($postedParam['planId']);
}
return !$isPlanIdEmpty && $isValidPlanId;
}
|
A helper method that check plan id is set in payload.
@param $param
@return bool
Simple usage:
CheckoutApi_Client_Validation_GW3::isPlanIdValid($param)
|
entailment
|
public static function isCustomerPlanIdValid($postedParam)
{
$isCustomerPlanIdEmpty = true;
$isValidCustomerPlanId = false;
if(isset($postedParam['customerPlanId'])) {
$isCustomerPlanIdEmpty = CheckoutApi_Lib_Validator::isEmpty($postedParam['customerPlanId']);
}
if(!$isCustomerPlanIdEmpty) {
$isValidCustomerPlanId = CheckoutApi_Lib_Validator::isString($postedParam['customerPlanId']);
}
return !$isCustomerPlanIdEmpty && $isValidCustomerPlanId;
}
|
A helper method that check customer plan id is set in payload.
@param $param
@return bool
Simple usage:
CheckoutApi_Client_Validation_GW3::isCustomerPlanIdValid($param)
|
entailment
|
public function request()
{
if(!$this->getResource()) {
$this->exception("No curl resource was found", debug_backtrace());
}
$resource = $this->getResource();
curl_setopt($resource, CURLOPT_URL, $this->getUri());
//setting curl options
$headers = $this->getHeaders();
if(!empty($headers)) {
curl_setopt($resource, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($resource, CURLOPT_HEADER, true);
}
$method = $this->getMethod();
$curlMethod = '';
switch ($method) {
case CheckoutApi_Client_Adapter_Constant::API_POST:
$curlMethod = CheckoutApi_Client_Adapter_Constant::API_POST;
break;
case CheckoutApi_Client_Adapter_Constant::API_GET:
$curlMethod = CheckoutApi_Client_Adapter_Constant::API_GET;
break;
case CheckoutApi_Client_Adapter_Constant::API_DELETE:
$curlMethod = CheckoutApi_Client_Adapter_Constant::API_DELETE;
break;
case CheckoutApi_Client_Adapter_Constant::API_PUT:
$curlMethod = CheckoutApi_Client_Adapter_Constant::API_PUT;
break;
default :
$this->exception("Method currently not supported", debug_backtrace());
break;
}
if($curlMethod != CheckoutApi_Client_Adapter_Constant::API_GET) {
curl_setopt($resource, CURLOPT_CUSTOMREQUEST, $curlMethod);
}
// curl_setopt($resource , $curlMethod, true);
if($method == CheckoutApi_Client_Adapter_Constant::API_POST || $method == CheckoutApi_Client_Adapter_Constant::API_PUT ) {
curl_setopt($resource, CURLOPT_POSTFIELDS, $this->getPostedParam());
}
curl_setopt($resource, CURLOPT_RETURNTRANSFER, true);
curl_setopt($resource, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($resource);
$http_status = curl_getinfo($resource, CURLINFO_HTTP_CODE);
if($http_status != 200 ) {
$this->exception("An error has occurred while processing your transaction",
array(
'respond_code'=> $http_status,
'curl_info' => curl_getinfo($resource),
'respondBody'=> $response,
'postedParam' =>$this->getPostedParam(),
'rawPostedParam' => $this->getRawpostedParam(),
)
);
} elseif (curl_errno($resource)) {
$info = curl_getinfo($resource);
$this->exception("Curl issues ",$info);
}
$this->setResource($resource);
$this->setRespond($response);
return $this;
}
|
A method that do a request on provide uri and return itsel
@return CheckoutApi_Client_Adapter_Curl return self
Simple usage:
$adapter->request()->getRespond()
|
entailment
|
public function connect()
{
if($this->getResource()) {
$this->close();
}
$resource = curl_init();
curl_setopt($resource,CURLOPT_CONNECTTIMEOUT,$this->getTimeout());
$this->setResource($resource);
parent::connect();
return $this;
}
|
Close all open connections and release all set variables
|
entailment
|
public function getTimeout()
{
$timeout = $this->_timeout;
if($this->getConfig('timeout')) {
$timeout = $this->getConfig('timeout');
}
return $timeout;
}
|
gateway timeout value
@return int timeout
|
entailment
|
public function getErrorMessage()
{
$messages = $this->getMessage();
$critical = $this->getCritical();
$msgError = "";
$i = 0;
foreach ($messages as $message ) {
if ($critical[$i++]) {
$msgError .= "{$message}\n";
}
}
return $msgError;
}
|
compile all errors in one line
@return string
|
entailment
|
public function setLog($errorMsg,$trace, $state = true)
{
$this->setErrorState($state);
$this->setTrace($trace);
$this->setMessage($errorMsg);
$this->setCritical($state);
}
|
set error state of object. we can have an error but still proceed
@var string $errorMsg error message
@var array $trace statck trace
@var boolean $state if critical or not
|
entailment
|
public function debug()
{
$errorToreturn = '';
if($this->_debug && $this->hasError() ){
$message = $this->getMessage();
$trace = $this->getTrace();
$critical = $this->getCritical();
for($i= 0, $count = sizeOf($message); $i<$count;$i++ ) {
if($critical[$i]){
echo '<strong style="color:red">';
} else {
continue;
}
CheckoutApi_Utility_Utilities::dump($message[$i] .'==> { ');
foreach($trace[$i] as $errorIndex => $errors) {
echo "<pre>";
echo $errorIndex ."=> "; print_r($errors);
echo "</pre>";
}
if($critical[$i]) {
echo '</strong>';
}
CheckoutApi_Utility_Utilities::dump('} ');
}
}
return $errorToreturn;
}
|
CheckoutApi_ print out the error
@return string $errorToreturn a list of errors
|
entailment
|
public function setCookie(
$name = "",
$value = "",
$expire = 0,
$path = "/",
$domain = "",
$secure = false,
$httpOnly = false
) {
Cookies::$plugin->cookies->set(
$name,
$value,
$expire,
$path,
$domain,
$secure,
$httpOnly
);
}
|
Set a cookie
@param string $name
@param string $value
@param int $expire
@param string $path
@param string $domain
@param bool $secure
@param bool $httpOnly
|
entailment
|
public function setSecureCookie(
$name = "",
$value = "",
$expire = 0,
$path = "/",
$domain = "",
$secure = false,
$httpOnly = false
) {
Cookies::$plugin->cookies->setSecure(
$name,
$value,
$expire,
$path,
$domain,
$secure,
$httpOnly
);
}
|
Set a secure cookie
@param string $name
@param string $value
@param int $expire
@param string $path
@param string $domain
@param bool $secure
@param bool $httpOnly
|
entailment
|
public function set(
$name = '',
$value = '',
$expire = 0,
$path = '/',
$domain = '',
$secure = false,
$httpOnly = false
) {
if (empty($value)) {
Craft::$app->response->cookies->remove($name);
} else {
$domain = empty($domain) ? Craft::$app->getConfig()->getGeneral()->defaultCookieDomain : $domain;
$expire = (int)$expire;
setcookie($name, $value, $expire, $path, $domain, $secure, $httpOnly);
$_COOKIE[$name] = $value;
}
}
|
Set a cookie
@param string $name
@param string $value
@param int $expire
@param string $path
@param string $domain
@param bool $secure
@param bool $httpOnly
|
entailment
|
public function get($name = '')
{
$result = '';
if (isset($_COOKIE[$name])) {
$result = $_COOKIE[$name];
}
return $result;
}
|
Get a cookie
@param string $name
@return mixed
|
entailment
|
public function setSecure(
$name = '',
$value = '',
$expire = 0,
$path = '/',
$domain = '',
$secure = false,
$httpOnly = false
) {
if (empty($value)) {
Craft::$app->response->cookies->remove($name);
} else {
$domain = empty($domain) ? Craft::$app->getConfig()->getGeneral()->defaultCookieDomain : $domain;
$expire = (int)$expire;
$cookie = new Cookie(['name' => $name, 'value' => '']);
try {
$cookie->value = Craft::$app->security->hashData(base64_encode(serialize($value)));
} catch (InvalidConfigException $e) {
Craft::error(
'Error setting secure cookie: '.$e->getMessage(),
__METHOD__
);
return;
} catch (Exception $e) {
Craft::error(
'Error setting secure cookie: '.$e->getMessage(),
__METHOD__
);
return;
}
$cookie->expire = $expire;
$cookie->path = $path;
$cookie->domain = $domain;
$cookie->secure = $secure;
$cookie->httpOnly = $httpOnly;
Craft::$app->response->cookies->add($cookie);
}
}
|
Set a secure cookie
@param string $name
@param string $value
@param int $expire
@param string $path
@param string $domain
@param bool $secure
@param bool $httpOnly
|
entailment
|
public function getSecure($name = '')
{
$result = '';
$cookie = Craft::$app->request->cookies->get($name);
if ($cookie !== null) {
try {
$data = Craft::$app->security->validateData($cookie->value);
} catch (InvalidConfigException $e) {
Craft::error(
'Error getting secure cookie: '.$e->getMessage(),
__METHOD__
);
$data = false;
} catch (Exception $e) {
Craft::error(
'Error getting secure cookie: '.$e->getMessage(),
__METHOD__
);
$data = false;
}
if ($cookie
&& !empty($cookie->value)
&& $data !== false
) {
$result = unserialize(base64_decode($data), ['allowed_classes' => false]);
}
}
return $result;
}
|
Get a secure cookie
@param string $name
@return mixed
|
entailment
|
protected function build()
{
$operation = $this->buildOperation('ManualClear');
$merchantID = $this->document->createElement('merchantID', $this->merchantId);
$operation->appendChild($merchantID);
$clearingDetails = $this->document->createElement('clearingDetails');
$clearingDetails = $operation->appendChild($clearingDetails);
$xmlMPayTid = $this->document->createElement('mpayTID', $this->mpayTid);
$clearingDetails->appendChild($xmlMPayTid);
if ($this->amount) {
$price = $this->document->createElement('amount', $this->amount);
$clearingDetails->appendChild($price);
}
if ($this->order) {
// TODO:: Add the order to the request
}
}
|
Build the Body ot the Request and add it to $this->document
|
entailment
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.