예제 #1
0
 public static function makePayment($data)
 {
     $client = Client::create(['consumerKey' => Config::get('cardinity.customer_key'), 'consumerSecret' => Config::get('cardinity.customer_secret')]);
     $method = new Create(['amount' => floatval(isset($data['amount']) ? $data['amount'] : 0), 'currency' => Config::get('cardinity.currency'), 'settle' => Config::get('cardinity.settle'), 'description' => isset($data['description']) ? $data['description'] : '', 'order_id' => isset($data['order_id']) ? (string) $data['order_id'] : '', 'country' => Config::get('cardinity.country'), 'payment_method' => Create::CARD, 'payment_instrument' => ['pan' => isset($data['pan']) ? $data['pan'] : '', 'exp_year' => isset($data['exp_year']) ? (int) $data['exp_year'] : 0, 'exp_month' => isset($data['exp_month']) ? (int) $data['exp_month'] : 0, 'cvc' => isset($data['cvc']) ? $data['cvc'] : '', 'holder' => isset($data['holder']) ? $data['holder'] : '']]);
     try {
         $payment = $client->call($method);
     } catch (Declined $exception) {
         $payment = $exception->getResult();
     }
     return ['payment_id' => $payment->getId(), 'order_id' => isset($data['order_id']) ? (string) $data['order_id'] : '', 'status' => Config::get('cardinity.statuses.' . $payment->getStatus()), 'error' => $payment->getErrors()];
 }
예제 #2
0
 public static function makePayment($data)
 {
     $client = Client::create(['consumerKey' => Config::get('cardinity.customer_key'), 'consumerSecret' => Config::get('cardinity.customer_secret')]);
     $method = new Create(['amount' => 50.0, 'currency' => 'EUR', 'settle' => false, 'description' => 'some description', 'order_id' => '12345678', 'country' => 'LT', 'payment_method' => Create::CARD, 'payment_instrument' => ['pan' => '4111111111111111', 'exp_year' => 2016, 'exp_month' => 12, 'cvc' => '456', 'holder' => 'Mike Dough']]);
     try {
         $payment = $client->call($method);
     } catch (Declined $exception) {
         $payment = $exception->getResult();
     }
     return ['payment_id' => $payment->getId(), 'order_id' => isset($data['order_id']) ? (string) $data['order_id'] : '', 'status' => Config::get('cardinity.statuses.' . $payment->getStatus()), 'error' => $payment->getErrors()];
 }
예제 #3
0
파일: cardinity.php 프로젝트: web3d/mincart
 public function finalizePayment($key, $secret, $payment_id, $pares)
 {
     $client = Client::create(array('consumerKey' => $key, 'consumerSecret' => $secret));
     $method = new Payment\Finalize($payment_id, $pares);
     try {
         $payment = $client->call($method);
         return $payment;
     } catch (Exception $exception) {
         $this->exception($exception);
         return false;
     }
 }
예제 #4
0
 public function setUp()
 {
     $log = Client::LOG_NONE;
     // @NOTE uncomment if request/response debugging is needed
     // Use 'null' value for printing request to console
     // $log = Client::LOG_DEBUG;
     // Use monolog logger to log requests into the file
     // $log = new Logger('requests');
     // $log->pushHandler(new StreamHandler(__DIR__ . '/info.log', Logger::INFO));
     $this->client = Client::create($this->getConfig(), $log);
     $this->assertInstanceOf('Cardinity\\Client', $this->client);
 }
예제 #5
0
 /**
  * 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');
 }
예제 #6
0
파일: ErrorTest.php 프로젝트: web3d/mincart
 /**
  * @expectedException Cardinity\Exception\Unauthorized
  */
 public function testUnauthorizedResponse()
 {
     $client = Client::create(['consumerKey' => 'no', 'consumerSecret' => 'yes']);
     $method = new Payment\Get('xxxyyy');
     $client->call($method);
 }
예제 #7
0
 public function createClient($credentials)
 {
     return Client::create(array('consumerKey' => $credentials['key'], 'consumerSecret' => $credentials['secret']));
 }