示例#1
0
 /**
  * @depends testCreatePayment
  */
 public function testCreate(Payment\Payment $payment)
 {
     $method = new Void\Create($payment->getId(), 'my description');
     $result = $this->client->call($method);
     $this->assertInstanceOf('Cardinity\\Method\\Void\\Void', $result);
     return $result;
 }
示例#2
0
 /**
  * @depends testCreatePayment
  */
 public function testCreate(Payment\Payment $payment)
 {
     $method = new Settlement\Create($payment->getId(), 10.0, 'my description');
     $result = $this->client->call($method);
     $this->assertInstanceOf('Cardinity\\Method\\Settlement\\Settlement', $result);
     $this->assertSame('10.00', $result->getAmount());
     return $result;
 }
 /**
  * 3-D secure callback action
  * @param Request $request
  * @return Response
  */
 public function processAuthorizationAction(Request $request)
 {
     $message = null;
     $identifier = $request->request->get('MD');
     $pares = $request->request->get('PaRes');
     $payment = new Payment\Payment();
     $payment->unserialize($this->session->get('cardinity_payment'));
     if ($payment->getOrderId() != $identifier || $pares != $payment->getDescription()) {
         return $this->errorResponse('Invalid callback data');
     }
     try {
         if ($payment->isPending()) {
             $method = new Payment\Finalize($payment->getId(), $pares);
             /** @var Cardinity\Method\Payment\Payment */
             $payment = $this->payment->call($method);
         }
         if ($payment->isApproved()) {
             return new RedirectResponse($this->router->generate('cardinity_client.payment_success'));
         }
     } catch (Exception\Runtime $e) {
         return $this->errorResponse('Unexpected error occured. ' . $e->getMessage() . ': ' . print_r($e->getErrors(), true));
     }
     return $this->errorResponse('Unexpected response while finalizing payment');
 }