PHP code example of academe / omnipay-girocheckout
1. Go to this page and download the library: Download academe/omnipay-girocheckout 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/ */
academe / omnipay-girocheckout example snippets
use Omnipay\GiroCheckout\Gateway;
use Omnipay\Omnipay;
// The backward slashes are needed to make the driver base class absolute.
// An issue will be raised against Omnipay Common to fix this.
$gateway = Omnipay::create('\\' . Gateway::class);
// or
$gateway = Omnipay::create('GiroCheckout/Gateway';
// The IDs can be given as integers in strings.
$gateway->setMerchantID('3610000');
$gateway->setProjectID('37000');
$gateway->setProjectPassphrase('ZFXDMpXDMpVV9Z');
// Other payment types are supported.
$gateway->setPaymentType(Gateway::PAYMENT_TYPE_CREDIT_CARD);
// or
$gateway->initialize([
'merchantId' => 3610000,
'projectId' => 37000,
'projectPassphrase' => 'ZFXDMpXDMpVV9Z',
'paymentType' => Gateway::PAYMENT_TYPE_CREDIT_PAYPAL,
]);
use Money\Money;
use Money\Currency;
$gateway->setPaymentType(Gateway::PAYMENT_TYPE_CREDIT_CARD);
$authRequest = $gateway->authorize([
'transactionId' => $yourMerchantTransactionId,
//
// Several ways to supply the amount:
'amount' => '4.56',
'amount' => new Money(456, new Currency('EUR')),
'amount' => Money::EUR(456),
//
'currency' => 'EUR',
'description' => 'Mandatory reason for the transaction',
'language' => 'en',
'returnUrl' => 'url to bring the user back to the merchant site',
'notifyUrl' => 'url for the gateway to send direct notifications',
'mobile' => false,
]);
$completeRequest = $gateway->completeAuthorize();
$completeResponse = $completeRequest->send();
// Available standard Omnipay details:
$completeResponse->getCode();
$completeResponse->getMessage();
$completeResponse->isSuccessful();
$completeResponse->isCancelled();
$completeResponse->getTransactionStatus();
$completeResponse->getTransactionReference();
$getCardRequest = $gateway->getCard([
'transactionReference' => 'otiginal transaction reference',
]);
$getCardResponse = $getCardRequest->send();
// The reusable `cardReference` is available here:
$cardReference = $getCardResponse->getTransactionReference();
// Other details about the card that may be useful:
$getCardResponse->getNumberMasked();
$getCardResponse->getExpiryYear();
$getCardResponse->getExpiryMonth();
$gateway->setPaymentType(Gateway::PAYMENT_TYPE_DIRECTDEBIT);
$authRequest = $gateway->authorize([
'transactionId' => $yourMerchantTransactionId,
'amount' => Money::EUR(456),
'currency' => 'EUR', // Optional if the amount is Money
'description' => 'Mandatory reason for the transaction',
'language' => 'en',
'returnUrl' => 'url to bring the user back to the merchant site',
'notifyUrl' => 'url for the gateway to send direct notifications',
'mobile' => false,
// Parameters specific to Direct Debit, all optional:
'mandateReference' => '...',
'mandateSignedOn' => '...',
'mandateReceiverName' => '...',
'mandateSequence' => '...',
]);
$gateway->setPaymentType(Gateway::PAYMENT_TYPE_PAYPAL);
$authRequest = $gateway->purchase([
'transactionId' => $yourMerchantTransactionId,
'amount' => Money::EUR(789),
'currency' => 'EUR',
'description' => 'Mandatory reason for the transaction',
'returnUrl' => 'url to bring the user back to the merchant site',
'notifyUrl' => 'url for the gateway to send direct notifications',
]);
$gateway->setPaymentType(Gateway::PAYMENT_TYPE_GIROPAY);
$request = $gateway->getIssuers();
$response = $request->send();
// The list of named banks is indexed by their BIC.
if ($response->isSuccessful()) {
$bankList = $response->getIssuerArray();
var_dump($bankList);
}
// array(1407) {
// ["BELADEBEXXX"]=>
// string(38) "Landesbank Berlin - Berliner Sparkasse"
// ["BEVODEBBXXX"]=>
// string(18) "Berliner Volksbank"
// ["GENODEF1P01"]=>
// string(27) "PSD Bank Berlin-Brandenburg"
// ["WELADED1WBB"]=>
// string(9) "Weberbank"
// ...
// }
$gateway->setPaymentType(Gateway::PAYMENT_TYPE_BLUECODE);
$purchaseRequest = $gateway->purchase([
'transactionId' => $yourMerchantTransactionId,
'amount' => 4.56,
'currency' => 'EUR', // or any other valid currency code
'description' => 'Reason for the transaction',
'returnUrl' => 'url to bring the user back to the marchant site',
'notifyUrl' => 'url for the gateway to send direct notifications',
]);
$gateway->setPaymentType(Gateway::PAYMENT_TYPE_BLUECODE);
$refundRequest = $gateway->refund([
'transactionId' => $yourMerchantTransactionId,
'amount' => 4.56,
'currency' => 'EUR', // or any other valid currency code
'description' => 'Reason for the transaction',
'transactionReference' => 'original purchase transaction reference'
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.