Skip to content

Instantly share code, notes, and snippets.

@bradberger
Created May 28, 2015 16:16
Show Gist options
  • Save bradberger/9d0d2873ba39236b301e to your computer and use it in GitHub Desktop.
Save bradberger/9d0d2873ba39236b301e to your computer and use it in GitHub Desktop.
Capture Invoice Payment Gist
// Make sure user has card on file.
if (empty($user['cclastfour'])) {
$config['vars']['nocard'] = true;
$config['vars']['error'] = 'You do not have any payment methods on file';
return $config;
}
$payment = localAPI('capturepayment', ['invoiceid' => $invoice_id], 'admin');
if ($payment['result'] === 'success') {
$config['vars']['payment']['success'] = sprintf('Payment succeeded');
} else {
$config['vars']['payment']['error'] = sprintf('Payment failed: %s', $payment['message']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment