Skip to content

Commit

Permalink
Added SaveCustomer flag to Transactions to create a token when a tran…
Browse files Browse the repository at this point in the history
…saction is completed
  • Loading branch information
incarnate committed Dec 2, 2015
1 parent 503fab5 commit ad50ca4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes will be documented in this file

## 1.1.3

- Added `SaveCustomer` flag to Transactions to create a token when a transaction is completed

## 1.1.2

- Removed exception thrown when Rapid field is not in SDK Model
Expand Down
6 changes: 4 additions & 2 deletions src/Rapid/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ private function _createTransaction($apiMethod, $transaction)

case ApiMethod::RESPONSIVE_SHARED:
if ($transaction->Capture) {
if (isset($transaction->Customer) && isset($transaction->Customer->TokenCustomerID)) {
if ((isset($transaction->Customer) && isset($transaction->Customer->TokenCustomerID))
|| (isset($transaction->SaveCustomer) && $transaction->SaveCustomer == true)) {
$transaction->Method = PaymentMethod::TOKEN_PAYMENT;
} else {
$transaction->Method = PaymentMethod::PROCESS_PAYMENT;
Expand All @@ -301,7 +302,8 @@ private function _createTransaction($apiMethod, $transaction)

case ApiMethod::TRANSPARENT_REDIRECT:
if ($transaction->Capture) {
if (isset($transaction->Customer) && isset($transaction->Customer->TokenCustomerID)) {
if ((isset($transaction->Customer) && isset($transaction->Customer->TokenCustomerID))
|| (isset($transaction->SaveCustomer) && $transaction->SaveCustomer == true)) {
$transaction->Method = PaymentMethod::TOKEN_PAYMENT;
} else {
$transaction->Method = PaymentMethod::PROCESS_PAYMENT;
Expand Down
3 changes: 3 additions & 0 deletions src/Rapid/Model/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* @property string $TransactionType What type of transaction this is (Purchase, MOTO,etc)
* @property bool $Capture Set to true to create a regular transaction with immediate capture.
* Set to false to create an Authorisation transaction that can be used in a subsequent transaction.
* @property bool $SaveCustomer Set to true to create a token for a customer when a transaction is
* complete.
* @property Customer $Customer Customer details (name address token etc)
* @property ShippingAddress $ShippingAddress (optional) Shipping Address, name etc for the product ordered with
* this transaction
Expand Down Expand Up @@ -57,6 +59,7 @@ class Transaction extends AbstractModel
protected $fillable = [
'TransactionType',
'Capture',
'SaveCustomer',
'Customer',
// Customer again
'CustomerIP',
Expand Down

0 comments on commit ad50ca4

Please sign in to comment.