示例#1
0
 /**
  * sync.
  *
  * @method sync
  *
  * @param string    $gatewayName
  * @param callable  $closure
  */
 public function sync($gatewayName, callable $closure)
 {
     $payum = $this->getPayum();
     $gateway = $this->getGateway($gatewayName);
     $storage = $payum->getStorage($this->getPaymentModelName($payum));
     $payment = $storage->create();
     $closure($payment, $gatewayName, $storage, $this->payum);
     $request = new Sync($payment);
     $convert = new Convert($payment, 'array', $request->getToken());
     $gateway->execute($convert);
     $payment->setDetails($convert->getResult());
     $gateway->execute($request);
     return $request->getModel();
 }
 /**
  * @Extra\Route(
  *   "/recurring_payment_details/{gatewayName}/agreement/{agreementId}/payment/{paymentId}",
  *   name="acme_payex_recurring_payment_details"
  * )
  *
  * @Extra\Template
  */
 public function viewRecurringPaymentDetailsAction(Request $request, $gatewayName, $agreementId, $paymentId)
 {
     $payment = $this->getPayum()->getGateway($gatewayName);
     $payment->execute($syncAgreement = new Sync(new Identificator($agreementId, 'Acme\\PaymentBundle\\Model\\AgreementDetails')));
     $payment->execute($agreementStatus = new GetBinaryStatus($syncAgreement->getModel()));
     $paymentStatus = new GetBinaryStatus(new Identificator($paymentId, 'Acme\\PaymentBundle\\Model\\PaymentDetails'));
     $payment->execute($paymentStatus);
     $cancelToken = null;
     if ($paymentStatus->isCaptured()) {
         $cancelToken = $this->getTokenFactory()->createToken($gatewayName, $paymentStatus->getModel(), 'acme_payex_cancel_recurring_payment', array(), $request->attributes->get('_route'), $request->attributes->get('_route_params'));
     }
     return array('cancelToken' => $cancelToken, 'agreementStatus' => $agreementStatus, 'paymentStatus' => $paymentStatus);
 }