Skip to content

Commit

Permalink
Support for Billing Address in Charges with Card Token + Update Lib v…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
santiago-delpuerto-cko committed Sep 12, 2017
1 parent c2dda9e commit cfe0e3a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 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.9"
"checkout/checkout-php-api": "1.2.10"
},
```
__Manually__
Expand Down
21 changes: 21 additions & 0 deletions com/checkout/ApiServices/Charges/ChargesMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,27 @@ public function requestPayloadConverter($requestModel = null )
$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;
}

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

foreach ( $productsItem as $i => $item ) {
Expand Down
14 changes: 14 additions & 0 deletions com/checkout/ApiServices/Charges/RequestModels/BaseCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class BaseCharge extends BaseChargeInfo
protected $_chargeMode;
protected $_riskCheck;
protected $_attemptN3D;
protected $_billingDetails;

/**
* @return mixed
Expand Down Expand Up @@ -233,4 +234,17 @@ public function getAttemptN3D()
{
return $this->_attemptN3D;
}

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

public function getBillingDetails()
{
return $this->_billingDetails;
}
}
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.9';
const LIB_VERSION = 'v1.2.10';
}
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.9",
"version": "1.2.10",
"type": "library",
"license": "MIT",
"keywords": ["checkout.com","payment","gateway","online payment","checkoutcom","GW3","CKO"],
Expand Down

0 comments on commit cfe0e3a

Please sign in to comment.