Laravel - Payone

531 Views Asked by At

Is there an easy wrapper for the payone(https://www.payone.de/) API for Laravel? I only found one company who sells a package but nothing that is open source. I would appreciate any help.

1

There are 1 best solutions below

0
On

You should consider Omnipay: http://omnipay.thephpleague.com/

Because:

  • It is gateway independent.
  • It is framework independent. It works well with Laravel but also Symfony, Yii, etc.

There is an Omnipay plugin for PayOne: https://github.com/academe/OmniPay-Payone

The code to make a purchase via Omnipay is pretty much the same regardless of the gateway. Here is some sample code that should work, although you should check the details of the Payone classes for other information that you need to send. The Payone gateway can work in multiple different ways depending on how your account is set up.

$gateway = Omnipay::create('Payone_ShopServer');
$card = new CreditCard(array(
            'firstName' => 'Example',
            'lastName' => 'User',
            'number' => '4111111111111111',
            // ... etc
        ));

$transaction = $gateway->purchase(array(
    'amount'        => '10.00',
    'currency'      => 'USD',
    'description'   => 'This is a test purchase transaction.',
    'card'          => $card,
));

$response = $transaction->send();
if ($response->isSuccessful()) {
    echo "Purchase transaction was successful!\n";
}
// At this point you should get $response->getTransactionReference()
// and store that or something similar.