payum/omnipay-v3-bridge
Payum bridge for Omnipay v3 gateways. Use Omnipay’s 25+ payment providers through Payum’s capture/status workflow with built-in return/cancel URL handling, consistent gateway configuration, and Payum-style requests and models.
Omnipay created by Adrian Macneil. The lib provides unified api for 25+ gateway gateways. Plus, it simple, has unified, consistent API and fully covered with tests. This bridge allows you to use omnipay gateways but in payum like way.
Here's an example from omnipay's repository:
<?php
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();
}
and this is same code but done with the bridge:
<?php
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
}
Well more or less same amount of code but with the bridge you get more out of the box:
purchase or purchaseComplete methods should be used.Forma-Pro is a full stack development company which interests also spread to open source development. Being a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker & microservice oriented architecture where we have accumulated a huge many-years experience. Our main specialization is Symfony framework based solution, but we are always looking to the technologies that allow us to do our job the best way. We are committed to creating solutions that revolutionize the way how things are developed in aspects of architecture & scalability.
If you have any questions and inquires about our open source development, this product particularly or any other matter feel free to contact at opensource@forma-pro.com
OmnipayBridge is released under the MIT License.
How can I help you explore Laravel packages today?