PHP code example of payum / omnipay-bridge
1. Go to this page and download the library: Download payum/omnipay-bridge 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/ */
payum / omnipay-bridge example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('Stripe');
$gateway->setApiKey('abc123');
$formData = ['number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123'];
$response = $gateway->purchase(['amount' => '10.00', 'currency' => 'USD', 'card' => $formData])->send();
if ($response->isSuccessful()) {
// payment was successful: update database
print_r($response);
} elseif ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
use Payum\Core\PayumBuilder;
use Payum\Core\Request\Capture;
use Payum\Core\Request\GetHumanStatus;
use Payum\Core\Model\ArrayObject;
$payum = (new PayumBuilder())
->addDefaultStorages()
->addGateway('stripe', ['factory' => 'omnipay_stripe', 'apiKey' => 'abc123'])
->getPayum()
;
$card = ['number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2016', 'cvv' => '123'];
$payment = new ArrayObject(['amount' => '10.00', 'currency' => 'USD', 'card' => $card]);
if ($reply = $payum->getGateway('stripe')->execute(new Capture($payment), true)) {
// convert reply to http response
}
$payum->getGateway('stripe')->execute($status = new GetHumanStatus($payment));
if ($status->isCaptured()) {
// success
}