Shows details for an authorization, by ID.
public static get ( string $authorizationId, |
||
$authorizationId | string | |
$apiContext | is the APIContext for this call. It can be used to pass dynamic configuration and credentials. | |
$restCall | PayPalRestCall | is the Rest Call Service that is used to make rest calls |
Результат |
/** * @group integration */ public function testOperations() { try { $authId = AuthorizationTest::authorize(); $auth = Authorization::get($authId); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $captr = new Capture(); $captr->setId($authId); $captr->setAmount($amount); $capt = $auth->capture($captr); $captureId = $capt->getId(); $this->assertNotNull($captureId); $refund = new Refund(); $refund->setId($captureId); $refund->setAmount($amount); $capture = Capture::get($captureId); $this->assertNotNull($capture->getId()); $retund = $capture->refund($refund); $this->assertNotNull($retund->getId()); } catch (PayPalConnectionException $ex) { $this->markTestSkipped('Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage()); } }
/** * @dataProvider mockProvider * @param Authorization $obj */ public function testGet($obj, $mockApiContext) { $mockPPRestCall = $this->getMockBuilder('\\PayPal\\Transport\\PayPalRestCall')->disableOriginalConstructor()->getMock(); $mockPPRestCall->expects($this->any())->method('execute')->will($this->returnValue(AuthorizationTest::getJson())); $result = $obj->get("authorizationId", $mockApiContext, $mockPPRestCall); $this->assertNotNull($result); }
public function testOperations() { $authId = AuthorizationTest::authorize(); $auth = Authorization::get($authId); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $captr = new Capture(); $captr->setId($authId); $captr->setAmount($amount); $capt = $auth->capture($captr); $captureId = $capt->getId(); $this->assertNotNull($captureId); $refund = new Refund(); $refund->setId($captureId); $refund->setAmount($amount); $capture = Capture::get($captureId); $this->assertNotNull($capture->getId()); $retund = $capture->refund($refund); $this->assertNotNull($retund->getId()); }
// # GetCapture // This sample code demonstrates how you can lookup the details // of a captured payment. // API used: /v1/payments/capture/<$captureId> require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Capture; use PayPal\Api\Amount; use PayPal\Api\Authorization; // ### Create a mock Capture try { // create a mock authorization to get authorization Id // createAuthorization is defined in common.php $authId = createAuthorization($apiContext); // Lookup the authorization $authorization = Authorization::get($authId, $apiContext); ### Capture $amt = new Amount(); $amt->setCurrency("USD")->setTotal("1.00"); // Create a capture $captureInfo = new Capture(); $captureInfo->setId($authId)->setAmount($amt); $capture = $authorization->capture($captureInfo, $apiContext); } catch (PayPal\Exception\PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } // ### Retrieve Capture details // You can look up a capture by invoking the Capture::get method // with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
public function testReauthorize() { $authorization = Authorization::get('7GH53639GA425732B'); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $authorization->setAmount($amount); try { $reauthorization = $authorization->reauthorize(); } catch (PPConnectionException $ex) { $this->assertEquals(strpos($ex->getMessage(), "500"), false); } }
function get_transaction($id) { // auth $apiContext = $this->apiContext(); try { $payment = Sale::get($id, $apiContext); $valid = true; } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $valid = false; } if ($valid === true) { return $payment; } try { $payment = Authorization::get($id, $apiContext); $valid = true; } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $valid = false; } if ($valid === true) { return $payment; } try { $payment = Capture::get($id, $apiContext); $valid = true; } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $valid = false; } if ($valid === true) { return $payment; } try { $payment = Refund::get($id, $apiContext); $valid = true; } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $valid = false; } if ($valid === true) { return $payment; } }
/** * @group integration */ public function testReauthorize() { $authorization = Authorization::get('7GH53639GA425732B'); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $authorization->setAmount($amount); try { $authorization->reauthorize(); } catch (PayPalConnectionException $ex) { //var_dump($ex->getMessage()); $this->assertEquals(strpos($ex->getMessage(), "500"), false); } $authorization->setId(null); try { $authorization->reauthorize(); } catch (\InvalidArgumentException $ex) { $this->assertEquals($ex->getMessage(), "Id cannot be null"); } }
<?php // ##Reauthorization Sample // Sample showing how to do a reauthorization // API used: v1/payments/authorization/{authorization_id}/reauthorize require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Authorization; use PayPal\Api\Amount; use PayPal\Exception\PPConnectionException; // ###Reauthorization // Retrieve a authorization id from authorization object // by making a `Payment Using PayPal` with intent // as `authorize`. You can reauthorize a payment only once 4 to 29 // days after 3-day honor period for the original authorization // expires. $authorization = Authorization::get('7GH53639GA425732B', $apiContext); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $authorization->setAmount($amount); try { $reauthorization = $authorization->reauthorize($apiContext); } catch (PPConnectionException $ex) { echo "Exception: " . $ex->getMessage() . PHP_EOL; var_dump($ex->getData()); exit(1); } ?> <html> <body> <div>
<?php // # GetAuthorization // This sample code demonstrates how you can get details // of an authorized payment. // API used: /v1/payments/authorization/<$authorizationId> /** @var Authorization $authorization */ $authorization = (require 'AuthorizePayment.php'); $authorizationId = $authorization->getId(); use PayPal\Api\Authorization; // ### GetAuthorization // You can retrieve info about an Authorization // by invoking the Authorization::get method // with a valid ApiContext (See bootstrap.php for more on `ApiContext`) // The return object contains the authorization state. try { // Retrieve the authorization $result = Authorization::get($authorizationId, $apiContext); } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printError("Get Authorization", "Authorization", null, null, $ex); exit(1); } // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY ResultPrinter::printResult("Get Authorization", "Authorization", $authorizationId, null, $result); return $result;
public function getAuthorization($authId) { $apiContext = $this->contextFactory->createContext(); $authorization = Authorization::get($authId, $apiContext); return $authorization; }