Created
August 9, 2011 14:29
-
-
Save makasim/1134194 to your computer and use it in GitHub Desktop.
Payment processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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