Refund script


use Payum\Core\Request\Refund;
use Payum\Core\Payum;
use Payum\Core\Reply\HttpResponse;
use Payum\Core\Reply\ReplyInterface;

include __DIR__.'/config.php';

/** @var Payum $payum */

$token = $payum->getHttpRequestVerifier()->verify($_REQUEST);
$gateway = $payum->getGateway($token->getGatewayName());

try {
    $gateway->execute(new Refund($token));

    if (! isset($_REQUEST['noinvalidate'])) {

    if ($token->getAfterUrl()) {
        header("Location: ".$token->getAfterUrl());
    } else {
        echo 'OK';
} catch (HttpResponse $reply) {
    foreach ($reply->getHeaders() as $name => $value) {
        header("$name: $value");

    echo ($reply->getContent());

} catch (ReplyInterface $reply) {
    throw new \LogicException('Unsupported reply', null, $reply);

Back to examples

Supporting Payum

Payum is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and our customers. If you'd like to join them, please consider:

Last updated