PHP code example of tshalif / omnipay-webpay
1. Go to this page and download the library: Download tshalif/omnipay-webpay library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tshalif / omnipay-webpay example snippets
$gateway = Omnipay\Omnipay::create('Webpay');
$gateway->setAuthToken('test_secret_xxxxxxxxxxxxxxxxxxxxxxxx');
$card = new Omnipay\Common\CreditCard();
$card->setNumber("4242424242424242");
$card->setExpiryMonth("10");
$card->setExpiryYear("2020");
$card->setCvv("123");
$card->setName("ZAPHOD BEEBLEBROX");
try {
$params = array(
'amount' => 4200,
'card' => $card,
);
$response = $gateway->authorize($params)->send();
if ($response->isSuccessful()) {
// successful
} else {
throw new ApplicationException($response->getMessage());
}
} catch (ApplicationException $e) {
throw new ApplicationException($e->getMessage());
}