Skip to content

Commit

Permalink
Add authorize handling for using a stored billing agreement
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Dec 12, 2018
1 parent b2a5e0d commit e31317b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Message/RestAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,20 @@ public function getData()
$data['transactions'][0]['item_list']["items"] = $itemList;
}

if ($this->getCardReference()) {
if ($this->getCardReference() && substr($this->getCardReference(), 0, 2) === 'B-') {
// Card references can be for a billing agreement (format B-....) or a stored card format CARD-...
// here billing agreement
// https://developer.paypal.com/docs/limited-release/reference-transactions/#use-a-reference-transaction-to-make-a-payment
$this->validate('amount');
$data['payer']['funding_instruments'][] = array(
'billing' => array(
'billing_agreement_id' => $this->getCardReference(),
),
);
$data['payer']['payment_method'] = 'paypal';
} elseif ($this->getCardReference()) {
// stored card
//https://developer.paypal.com/docs/integration/direct/vault/#pay-with-vaulted-card
$this->validate('amount');

$data['payer']['funding_instruments'][] = array(
Expand Down

0 comments on commit e31317b

Please sign in to comment.