Skip to content

Commit

Permalink
Merge pull request #100 from checkout/dev
Browse files Browse the repository at this point in the history
Add dynamic 3DS URL functionality
  • Loading branch information
nicolas-maalouf-cko authored Dec 21, 2017
2 parents b85ff8f + bdf210b commit fd7f3ad
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 100 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Or require the Checkout.com package inside the composer.json of your project:
```
"require": {
"php": ">=5.2.4",
"checkout/checkout-php-api": "1.2.11"
"checkout/checkout-php-api": "1.2.13"
},
```
__Manually__
Expand Down
184 changes: 96 additions & 88 deletions com/checkout/ApiServices/Charges/ChargesMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public function requestPayloadConverter($requestModel = null )
if(method_exists($requestModel,'getEmail') && $requestModel->getEmail()) {
$requestPayload['email'] = $requestModel->getEmail();
}
if(method_exists($requestModel,'getCustomerName') && $requestModel->getCustomerName()) {
if(method_exists($requestModel,'getCustomerName') && $requestModel->getCustomerName()) {
$requestPayload['customerName'] = $requestModel->getCustomerName();
}
if(method_exists($requestModel,'getCustomerId') && $requestModel->getCustomerId()) {
if(method_exists($requestModel,'getCustomerId') && $requestModel->getCustomerId()) {
$requestPayload['customerId'] = $requestModel->getCustomerId();
}

Expand All @@ -65,19 +65,27 @@ public function requestPayloadConverter($requestModel = null )
if(method_exists($requestModel,'getDescription') && $requestModel->getDescription()) {
$requestPayload['description'] = $requestModel->getDescription();
}
if(method_exists($requestModel,'getChargeMode') && $requestModel->getChargeMode()) {
$requestPayload['chargeMode'] = $requestModel->getChargeMode();
}
if(method_exists($requestModel,'getChargeMode') && $requestModel->getChargeMode()) {
$requestPayload['chargeMode'] = $requestModel->getChargeMode();
}

if(method_exists($requestModel,'getRiskCheck') && $requestModel->getRiskCheck()) {
$requestPayload['riskCheck'] = $requestModel->getRiskCheck();
}
if(method_exists($requestModel,'getRiskCheck') && $requestModel->getRiskCheck()) {
$requestPayload['riskCheck'] = $requestModel->getRiskCheck();
}

if(method_exists($requestModel,'getAttemptN3D') && $requestModel->getAttemptN3D()) {
$requestPayload['attemptN3D'] = $requestModel->getAttemptN3D();
}

if(method_exists($requestModel,'getSuccessUrl') && $requestModel->getSuccessUrl()) {
$requestPayload['successUrl'] = $requestModel->getSuccessUrl();
}

if(method_exists($requestModel,'getFailUrl') && $requestModel->getFailUrl()) {
$requestPayload['failUrl'] = $requestModel->getFailUrl();
}

if(method_exists($requestModel,'getChargeId') && $requestModel->getChargeId()) {
$requestPayload['chargeId'] = $requestModel->getChargeId();
}
Expand Down Expand Up @@ -123,17 +131,17 @@ public function requestPayloadConverter($requestModel = null )
$requestPayload['descriptor'] = $descriptorConfig;
}

if(method_exists($requestModel,'getAutoCapTime') && $autoCapTime = $requestModel->getAutoCapTime()) {
$requestPayload['autoCapTime'] = $autoCapTime;
}
if(method_exists($requestModel,'getAutoCapTime') && $autoCapTime = $requestModel->getAutoCapTime()) {
$requestPayload['autoCapTime'] = $autoCapTime;
}

if(method_exists($requestModel,'getAutoCapture') && $autoCapture = $requestModel->getAutoCapture()) {
$requestPayload['autoCapture'] = $autoCapture;
}
if(method_exists($requestModel,'getAutoCapture') && $autoCapture = $requestModel->getAutoCapture()) {
$requestPayload['autoCapture'] = $autoCapture;
}

if(method_exists($requestModel,'getTransactionIndicator') && $transactionIndicator = $requestModel->getTransactionIndicator()) {
$requestPayload['transactionIndicator'] = $transactionIndicator;
}
if(method_exists($requestModel,'getTransactionIndicator') && $transactionIndicator = $requestModel->getTransactionIndicator()) {
$requestPayload['transactionIndicator'] = $transactionIndicator;
}

if( method_exists($requestModel,'getShippingDetails') && $shippingAddress = $requestModel->getShippingDetails()) {
$shippingAddressConfig = array (
Expand All @@ -145,37 +153,37 @@ public function requestPayloadConverter($requestModel = null )
'state' => $shippingAddress->getState () ,

);
if ($shippingAddress->getPhone() != null) {
$shippingAddressConfig = array_merge_recursive($shippingAddressConfig, array(
'phone' => $shippingAddress->getPhone()->getPhoneDetails()
)
);
}
if ($shippingAddress->getPhone() != null) {
$shippingAddressConfig = array_merge_recursive($shippingAddressConfig, array(
'phone' => $shippingAddress->getPhone()->getPhoneDetails()
)
);
}

$requestPayload['shippingDetails'] = $shippingAddressConfig;
$requestPayload['shippingDetails'] = $shippingAddressConfig;
}


if (method_exists($requestModel, 'getBillingDetails') && $billingAddress = $requestModel->getBillingDetails()) {
$billingAddressConfig = array(
'addressLine1' => $billingAddress->getAddressLine1(),
'addressLine2' => $billingAddress->getAddressLine2(),
'postcode' => $billingAddress->getPostcode(),
'country' => $billingAddress->getCountry(),
'city' => $billingAddress->getCity(),
'state' => $billingAddress->getState(),
);

if ($billingAddress->getPhone() != null) {
$billingAddressConfig = array_merge_recursive($billingAddressConfig, array(
'phone' => $billingAddress->getPhone()->getPhoneDetails()
)
);
}

$requestPayload['billingDetails'] = $billingAddressConfig;
}
$billingAddressConfig = array(
'addressLine1' => $billingAddress->getAddressLine1(),
'addressLine2' => $billingAddress->getAddressLine2(),
'postcode' => $billingAddress->getPostcode(),
'country' => $billingAddress->getCountry(),
'city' => $billingAddress->getCity(),
'state' => $billingAddress->getState(),
);

if ($billingAddress->getPhone() != null) {
$billingAddressConfig = array_merge_recursive($billingAddressConfig, array(
'phone' => $billingAddress->getPhone()->getPhoneDetails()
)
);
}

$requestPayload['billingDetails'] = $billingAddressConfig;
}

if(method_exists($requestModel,'getProducts') && $productsItem = $requestModel->getProducts()) {

Expand Down Expand Up @@ -226,13 +234,13 @@ public function requestPayloadConverter($requestModel = null )
'city' => $billingAddress->getCity () ,
'state' => $billingAddress->getState () ,
);
if($billingAddress->getPhone () != null){
$billingAddressConfig = array_merge_recursive ( $billingAddressConfig ,
array (
'phone' => $billingAddress->getPhone()->getPhoneDetails()
)
);
}
if($billingAddress->getPhone () != null){
$billingAddressConfig = array_merge_recursive ( $billingAddressConfig ,
array (
'phone' => $billingAddress->getPhone()->getPhoneDetails()
)
);
}
$requestPayload[ 'card' ][ 'billingDetails' ] = $billingAddressConfig;
}

Expand Down Expand Up @@ -260,8 +268,8 @@ public function requestPayloadConverter($requestModel = null )
if(method_exists($requestModel,'getCardId') && $cardId = $requestModel->getCardId()) {
$requestPayload[ 'cardId' ] = $cardId;
}
if(method_exists($requestModel,'getCvv') && $cvv = $requestModel->getCvv()) {
if(method_exists($requestModel,'getCvv') && $cvv = $requestModel->getCvv()) {
$requestPayload[ 'cvv' ] = $cvv;
}

Expand All @@ -274,50 +282,50 @@ public function requestPayloadConverter($requestModel = null )
}

if(method_exists($requestModel,'getPaymentPlans') ) {
$paymentPlans = $requestModel->getPaymentPlans();
$paymentPlans = $requestModel->getPaymentPlans();

foreach($paymentPlans as $singlePlan) {
foreach($paymentPlans as $singlePlan) {

$requestSinglePaymentPlan = array();
$requestSinglePaymentPlan = array();

if (method_exists($singlePlan, 'getName') && ($name = $singlePlan->getName())) {
$requestSinglePaymentPlan['name'] = $name;
}
if (method_exists($singlePlan, 'getName') && ($name = $singlePlan->getName())) {
$requestSinglePaymentPlan['name'] = $name;
}

if (method_exists($singlePlan, 'getPlanTrackId') && ($planTrackId = $singlePlan->getPlanTrackId())) {
$requestSinglePaymentPlan['planTrackId'] = $planTrackId;
}
if (method_exists($singlePlan, 'getPlanTrackId') && ($planTrackId = $singlePlan->getPlanTrackId())) {
$requestSinglePaymentPlan['planTrackId'] = $planTrackId;
}

if (method_exists($singlePlan, 'getAutoCapTime') && ($autoCapTime = $singlePlan->getAutoCapTime())) {
$requestSinglePaymentPlan['autoCapTime'] = $autoCapTime;
}
if (method_exists($singlePlan, 'getAutoCapTime') && ($autoCapTime = $singlePlan->getAutoCapTime())) {
$requestSinglePaymentPlan['autoCapTime'] = $autoCapTime;
}

if (method_exists($singlePlan, 'getCurrency') && ($currency = $singlePlan->getCurrency())) {
$requestSinglePaymentPlan['currency'] = $currency;
}
if (method_exists($singlePlan, 'getCurrency') && ($currency = $singlePlan->getCurrency())) {
$requestSinglePaymentPlan['currency'] = $currency;
}

if (method_exists($singlePlan, 'getValue') && ($value = $singlePlan->getValue())) {
$requestSinglePaymentPlan['value'] = $value;
}
if (method_exists($singlePlan, 'getCycle') && ($cycle = $singlePlan->getCycle())) {
$requestSinglePaymentPlan['cycle'] = $cycle;
}
if (method_exists($singlePlan, 'getValue') && ($value = $singlePlan->getValue())) {
$requestSinglePaymentPlan['value'] = $value;
}
if (method_exists($singlePlan, 'getCycle') && ($cycle = $singlePlan->getCycle())) {
$requestSinglePaymentPlan['cycle'] = $cycle;
}

if (method_exists($singlePlan, 'getRecurringCount') && ($recurringCount = $singlePlan->getRecurringCount())) {
$requestSinglePaymentPlan['recurringCount'] = $recurringCount;
}
if (method_exists($singlePlan, 'getRecurringCount') && ($recurringCount = $singlePlan->getRecurringCount())) {
$requestSinglePaymentPlan['recurringCount'] = $recurringCount;
}

if (method_exists($singlePlan, 'getPlanId') && ($planId = $singlePlan->getPlanId())) {
$requestSinglePaymentPlan['planId'] = $planId;
}
if (method_exists($singlePlan, 'getPlanId') && ($planId = $singlePlan->getPlanId())) {
$requestSinglePaymentPlan['planId'] = $planId;
}

if (method_exists($singlePlan, 'getStartDate') && ($startDate = $singlePlan->getStartDate())) {
$requestSinglePaymentPlan['startDate'] = $startDate;
}
if (method_exists($singlePlan, 'getStartDate') && ($startDate = $singlePlan->getStartDate())) {
$requestSinglePaymentPlan['startDate'] = $startDate;
}

$requestPayload['paymentPlans'][] = $requestSinglePaymentPlan;
}
}
$requestPayload['paymentPlans'][] = $requestSinglePaymentPlan;
}
}

}

Expand Down
47 changes: 38 additions & 9 deletions com/checkout/ApiServices/Charges/RequestModels/BaseCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class BaseCharge extends BaseChargeInfo
protected $_riskCheck;
protected $_attemptN3D;
protected $_billingDetails;
protected $_successUrl;
protected $_failUrl;

/**
* @return mixed
Expand Down Expand Up @@ -235,16 +237,43 @@ public function getAttemptN3D()
return $this->_attemptN3D;
}

/**
/**
* @param mixed billingDetails
*/
public function setBillingDetails( $billingDetails)
{
$this->_billingDetails= $billingDetails;
}
public function setBillingDetails( $billingDetails)
{
$this->_billingDetails= $billingDetails;
}

public function getBillingDetails()
{
return $this->_billingDetails;
}
public function getBillingDetails()
{
return $this->_billingDetails;
}

/**
* @param mixed $successUrl
*/
public function setSuccessUrl( $successUrl)
{
$this->_successUrl= $successUrl;
}

public function getSuccessUrl()
{
return $this->_successUrl;
}

/**
* @param mixed $failUrl
*/
public function setFailUrl( $failUrl)
{
$this->_failUrl= $failUrl;
}

public function getFailUrl()
{
return $this->_failUrl;
}

}
2 changes: 1 addition & 1 deletion com/checkout/packages/CheckoutApi/Client/Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ final class CheckoutApi_Client_Constant
const VERSION = 'v2';
const STATUS_CAPTURE = 'Captured';
const STATUS_REFUND = 'Refunded';
const LIB_VERSION = 'v1.2.12';
const LIB_VERSION = 'v1.2.13';
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "checkout/checkout-php-api",
"description": "Checkout PHP API Library",
"homepage": "https://github.com/checkout/checkout-php-library",
"version": "1.2.12",
"version": "1.2.13",
"type": "library",
"license": "MIT",
"keywords": ["checkout.com","payment","gateway","online payment","checkoutcom","GW3","CKO"],
Expand Down

0 comments on commit fd7f3ad

Please sign in to comment.