This repository has been archived on 2026-04-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
PayPal-PHP-SDK/sample/payments/VoidAuthorization.php
japatel 3c02790138 Updates to Sample Code
- Updated UI Presentation on samples
- Fixed Bugs
2014-11-02 18:22:35 -06:00

32 lines
948 B
PHP

<?php
// # VoidAuthorization
// This sample code demonstrates how you can
// void an authorized payment.
// API used: /v1/payments/authorization/<{authorizationid}>/void"
/** @var Authorization $authorization */
$authorization = require 'AuthorizePayment.php';
use PayPal\Api\Authorization;
// ### VoidAuthorization
// You can void a previously authorized payment
// by invoking the $authorization->void method
// with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
try {
// Lookup the authorization
$authorization = Authorization::get($authorization->getId(), $apiContext);
// Void the authorization
$voidedAuth = $authorization->void($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Void Authorization", "Authorization", null, null, $ex);
exit(1);
}
ResultPrinter::printResult("Void Authorization", "Authorization", $voidedAuth->getId(), null, $voidedAuth);
return $voidedAuth;