SHARE
TWEET
Cardinity
a guest
Jan 29th, 2018
61
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- include 'cardinity/vendor/autoload.php';
- use Cardinity\Client;
- use Cardinity\Method\Payment;
- use Cardinity\Exception;
- $client = Client::create([
- 'consumerKey' => ' test_xxx',
- 'consumerSecret' => 'xxx',
- ]);
- $method = new Payment\Create([
- 'amount' => 50.00,
- 'currency' => 'EUR',
- 'settle' => true,
- 'description' => 'some description',
- 'order_id' => '12345678',
- 'country' => 'LT',
- 'payment_method' => Payment\Create::CARD,
- 'payment_instrument' => [
- 'pan' => '4111111111111111',
- 'exp_year' => 2018,
- 'exp_month' => 12,
- 'cvc' => '456',
- 'holder' => 'Mike Dough'
- ],
- ]);
- /**
- * In case payment could not be processed exception will be thrown.
- * In this example only Declined exception is handled. However there is more of them.
- * See Error Codes section for detailed list.
- */
- try {
- /** @type Cardinity\Method\Payment\Payment */
- $payment = $client->call($method);
- echo "<pre>";
- var_dump($payment);
- echo "</pre>";
- } catch (Exception\Declined $exception) {
- /** @type Cardinity\Method\Payment\Payment */
- $payment = $exception->getResult();
- $status = $payment->getStatus(); // value will be 'declined'
- $errors = $exception->getErrors(); // list of errors occured
- }
RAW Paste Data

