PHP code example of misato-tremor / omnipay-wirecard
1. Go to this page and download the library: Download misato-tremor/omnipay-wirecard 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/ */
misato-tremor / omnipay-wirecard example snippets
$gateway = Omnipay::create('Wirecard');
$gateway->setUsername($apiUsername);
$gateway->setPassword($apiPassword);
$gateway->setEndpoint('https://api%s.wirecard.com/engine/rest/payments/');
$gateway->setTestMode(true);
$data = [
'merchantAccountId' => $maid,
'amount' => number_format($total, 2, '.', ''),
'currency' => 'EUR',
'card' => [
'firstName' => $firstName,
'lastName' => $lastName,
'number' => $cardNumber,
'cvv' => $cardCvv,
'expiryMonth' => $cardMonth,
'expiryYear' => $cardYear,
],
'returnUrl' => '/wirecard/creditcard', // Your API endpoint for processing after 3-D-Secure
];
$response = $gateway->enrollmentCheck($data)->send();
if ($response->isSuccessful() && $response->isRedirect()) {
$response->redirect(); // Redirect to 3-D-Secure processing, this will redirect to your endpoint upon completion
} elseif ($response->isLiabilityShiftGranted()) {
$data = [
'merchantAccountId' => $maid,
'transactionReference' => $response->getTransactionReference(),
];
$response = $gateway->purchase($data)->send();
if ($response->isSuccessful()) {
// Complete order
}
}