9951 explained code solutions for 126 technologies

php-omnipayHow do I set up and use the Omnipay PHP package?

The Omnipay PHP package is a payment processing library for PHP. It provides an abstracted interface for various payment gateways, allowing developers to quickly and easily integrate payment processing into their applications.

To set up and use the Omnipay PHP package, first install it via Composer:

composer require league/omnipay

Once installed, you can create an Omnipay gateway instance:

$gateway = Omnipay::create('Stripe');

You can then configure the gateway with your API credentials:


You can then use the gateway to process payments:

$response = $gateway->purchase(array(
    'amount' => '10.00',
    'currency' => 'USD',
    'card' => $cardDetails

if ($response->isSuccessful()) {
    echo "Payment was successful!\n";
} else {
    echo "Payment failed: " . $response->getMessage() . "\n";

For more details, see the Omnipay documentation.

Edit this code on GitHub