passing API context to create authorization

This commit is contained in:
Ganesh Hegde
2013-05-30 15:23:13 +05:30
parent bbfa240161
commit 321e7de108
5 changed files with 26 additions and 20 deletions

View File

@@ -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'];