This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/CancelInvoice.php

42 lines
1.3 KiB
PHP
Raw Normal View History

2015-06-21 03:30:38 +00:00
<?php
// # Cancel Invoice Sample
// This sample code demonstrate how you can cancel
// an invoice.
/** @var Invoice $invoice */
$invoice = require 'SendInvoice.php';
use PayPal\Api\Invoice;
use PayPal\Api\CancelNotification;
try {
// ### Cancel Notification Object
// This would send a notification to both merchant as well
// the payer about the cancellation. The information of
// merchant and payer is retrieved from the invoice details
$notify = new CancelNotification();
$notify
->setSubject("Past due")
->setNote("Canceling invoice")
->setSendToMerchant(true)
->setSendToPayer(true);
// ### Cancel Invoice
// Cancel invoice object by calling the
// static `cancel` method
// on the Invoice class by passing a valid
// notification object
// (See bootstrap.php for more on `ApiContext`)
$cancelStatus = $invoice->cancel($notify, $apiContext);
} catch (Exception $ex) {
2015-07-01 00:16:22 +00:00
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Cancel Invoice", "Invoice", null, $notify, $ex);
2015-06-21 03:30:38 +00:00
exit(1);
}
2015-07-01 00:16:22 +00:00
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Cancel Invoice", "Invoice", $invoice->getId(), $notify, null);