PHP code example of worldstream-labs / omnipay-paysafecard
1. Go to this page and download the library: Download worldstream-labs/omnipay-paysafecard 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/ */
worldstream-labs / omnipay-paysafecard example snippets
mnipay\Omnipay;
$gateway = Omnipay::create('Paysafecard');
$gateway->setApiKey('yourApiKey');
// When deploying to production, don't forget to set test mode to false
$gateway->setTestMode(false);
mnipay\Omnipay;
$gateway = Omnipay::create('Paysafecard');
$gateway->setApiKey('yourApiKey');
$response = $gateway->authorize([
'amount' => 10.00,
'currency' => 'EUR',
'success_url' => 'https://website/success/{payment_id}',
'failure_url' => 'https://website/failure/{payment_id}',
'notification_url' => 'https://website/notification/{payment_id}',
])->send();
if (!$response->isSuccessful()) {
throw new \RuntimeException('Error with payment');
}
$paymentId = $response->getPaymentId(); // use this for the next call
redirect($response->getRedirectUrl());