forked from LiveCarta/PayPal-PHP-SDK
passing API context to create authorization
This commit is contained in:
@@ -12,9 +12,10 @@ use PayPal\Api\Payer;
|
||||
use PayPal\Api\Payment;
|
||||
use PayPal\Api\FundingInstrument;
|
||||
use PayPal\Api\Transaction;
|
||||
use PayPal\Api\Authorization;
|
||||
|
||||
// create payment to get authorization Id
|
||||
$authId = createAuthorization();
|
||||
$authId = createAuthorization($apiContext);
|
||||
$amt = new Amount();
|
||||
$amt->setCurrency("USD");
|
||||
$amt->setTotal("1.00");
|
||||
@@ -62,7 +63,7 @@ try {
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
function createAuthorization()
|
||||
function createAuthorization($apiContext)
|
||||
{
|
||||
$addr = new Address();
|
||||
$addr->setLine1("3909 Witmer Road");
|
||||
@@ -103,7 +104,7 @@ function createAuthorization()
|
||||
$payment->setPayer($payer);
|
||||
$payment->setTransactions(array($transaction));
|
||||
|
||||
$paymnt = $payment->create();
|
||||
$paymnt = $payment->create($apiContext);
|
||||
$resArray = $paymnt->toArray();
|
||||
|
||||
return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];
|
||||
|
||||
Reference in New Issue
Block a user