We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
i was trying to make some custom action when PaymentInterface::STATE_APPROVED was reached.
I am logging all status changes:
Payment status changed from 6 to 2 Payment status changed from 2 to 8
And it is over transition form 8 to 1 is missing i thing.
The last state that is caught by listener is 8 - STATE_DEPOSITED
Also payment ends with this status. On the other hand in paypal dev accounts payment is verified and completed on both sides - client and store.
My code for the last step is very typical and based on doc.
/** * @Route("/payment/complete/{id}", name="payment_complete") * @Template() */ public function paymentCompleteAction($id) { $order = $this->em->getRepository('WNCOrganizerBundle:Donate')->find($id); $instruction = $order->getPaymentInstruction(); if (null === $pendingTransaction = $instruction->getPendingTransaction()) { $payment = $this->ppc->createPayment($instruction->getId(), $instruction->getAmount() - $instruction->getDepositedAmount()); } else { $payment = $pendingTransaction->getPayment(); } $result = $this->ppc->approveAndDeposit($payment->getId(), $payment->getTargetAmount()); if (Result::STATUS_PENDING === $result->getStatus()) { $ex = $result->getPluginException(); if ($ex instanceof ActionRequiredException) { $action = $ex->getAction(); if ($action instanceof VisitUrl) { return new RedirectResponse($action->getUrl()); } throw $ex; } } else if (Result::STATUS_SUCCESS !== $result->getStatus()) { throw new \RuntimeException('Transaction was not successful: '.$result->getReasonCode()); } }
The listener looks like this:
class PaymentListener { /** * @var EntityManager */ private $em; private $logger; /** * @param EntityManager $em */ public function __construct(EntityManager $em, LoggerInterface $logger) { $this->em = $em; $this->logger = $logger; } /** * @param PaymentStateChangeEvent $event */ public function onPaymentStateChange(PaymentStateChangeEvent $event) { $this->logger->debug(sprintf('Payment status changed from %s to %s: ', $event->getOldState(), $event->getNewState())); switch ($event->getNewState()) { case PaymentInterface::STATE_APPROVED: { $donate = $this->em->getRepository('WNCOrganizerBundle:Order')->findOneByPaymentInstruction($event->getPaymentInstruction()); $donate->setConfirmed(true); $this->em->persist($donate); $this->em->flush($donate); } break; } } }
The text was updated successfully, but these errors were encountered:
Per the model diagram wouldn't the correct state changes be from:
Payment status changed from 6 to 2 Payment status changed from 2 to 1 Payment status changed from 1 to 8
This means that it goes from New -> Approving -> Approved -> Deposited since Deposited means that it was already approved.
Sorry, something went wrong.
Merge pull request schmittjoh#53 from adrienbrault/fix-21error
8924c8f
Fix 21error
No branches or pull requests
Hi,
i was trying to make some custom action when PaymentInterface::STATE_APPROVED was reached.
I am logging all status changes:
Payment status changed from 6 to 2
Payment status changed from 2 to 8
And it is over transition form 8 to 1 is missing i thing.
The last state that is caught by listener is 8 - STATE_DEPOSITED
Also payment ends with this status. On the other hand in paypal dev accounts payment is verified and completed on both sides - client and store.
My code for the last step is very typical and based on doc.
The listener looks like this:
The text was updated successfully, but these errors were encountered: