daily pastebin goal
41%
SHARE
TWEET

Cardinity

a guest Jan 29th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include 'cardinity/vendor/autoload.php';
  2.  
  3. use Cardinity\Client;
  4. use Cardinity\Method\Payment;
  5. use Cardinity\Exception;
  6.  
  7. $client = Client::create([
  8.     'consumerKey' => '  test_xxx',
  9.     'consumerSecret' => 'xxx',
  10. ]);
  11. $method = new Payment\Create([
  12.     'amount' => 50.00,
  13.     'currency' => 'EUR',
  14.     'settle' => true,
  15.     'description' => 'some description',
  16.     'order_id' => '12345678',
  17.     'country' => 'LT',
  18.     'payment_method' => Payment\Create::CARD,
  19.     'payment_instrument' => [
  20.         'pan' => '4111111111111111',
  21.         'exp_year' => 2018,
  22.         'exp_month' => 12,
  23.         'cvc' => '456',
  24.         'holder' => 'Mike Dough'
  25.     ],
  26. ]);
  27.  
  28. /**
  29. * In case payment could not be processed exception will be thrown.
  30. * In this example only Declined exception is handled. However there is more of them.
  31. * See Error Codes section for detailed list.
  32. */
  33. try {
  34.     /** @type Cardinity\Method\Payment\Payment */
  35.     $payment = $client->call($method);
  36.     echo "<pre>";
  37.     var_dump($payment);
  38.     echo "</pre>";
  39. } catch (Exception\Declined $exception) {
  40.     /** @type Cardinity\Method\Payment\Payment */
  41.     $payment = $exception->getResult();
  42.     $status = $payment->getStatus(); // value will be 'declined'
  43.     $errors = $exception->getErrors(); // list of errors occured
  44. }
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top