Skip to content

Commit e31317b

Browse files
Add authorize handling for using a stored billing agreement
1 parent b2a5e0d commit e31317b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Message/RestAuthorizeRequest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,20 @@ public function getData()
253253
$data['transactions'][0]['item_list']["items"] = $itemList;
254254
}
255255

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

259272
$data['payer']['funding_instruments'][] = array(

0 commit comments

Comments
 (0)