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

37 lines
990 B
PHP

<?php
// # VoidAuthorization
// This sample code demonstrate how you can void an authorized payment
// API used: /v1/payments/authorization/<{authorizationid}>/void"
require __DIR__ . '/../bootstrap.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 {
// create payment to get authorization Id
// createAuthorization is defined in common.php
$authId = createAuthorization($apiContext);
$authorization = Authorization::get($authId, $apiContext);
$voidedAuth = $authorization->void($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
}
?>
<html>
<body>
<div>
Voided authorization
</div>
<pre><?php var_dump($voidedAuth->toArray());?></pre>
<a href='../index.html'>Back</a>
</body>
</html>