Skip to content

Instantly share code, notes, and snippets.

@makasim
Created August 9, 2011 14:29
Show Gist options
  • Save makasim/1134194 to your computer and use it in GitHub Desktop.
Save makasim/1134194 to your computer and use it in GitHub Desktop.
Payment processing
<?php
public function paymentAction($paymentId)
{
$ppc = $this->container->get('payment.plugin_controller');
// todo get amount from payment
$result = $ppc->approve($paymentId, '66.00');
if (Result::STATUS_PENDING === $result->getStatus()) {
$ex = $result->getPluginException();
if ($ex instanceof ActionRequiredException) {
$action = $ex->getAction();
if ($action instanceof VisitUrl) {
return $this->redirect($action->getUrl());
}
throw $ex;
}
} else if (Result::STATUS_SUCCESS !== $result->getStatus()) {
throw new \RuntimeException('Transaction was not successful: '.$result->getReasonCode());
}
var_dump('successfuly paid');
die;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment