PHP code example of sylapi / omnipay-paylane
1. Go to this page and download the library: Download sylapi/omnipay-paylane 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/ */
sylapi / omnipay-paylane example snippets
$gateway = Omnipay\Omnipay::create('Paylane');
$gateway->setApiKey('--API Login--');
$gateway->setApiPassword('--API Password--');
$gateway->setIp('--IP--');
$response = $gateway->purchase(
[
"amount" => "100.00",
"currency" => "PLN",
"description" => "My Payment",
"transactionId" => "12345",
"email" => "[email protected] ",
"name" => "Fisrtname Lastname",
"payMethod" => "m",
"items" => [
[
"name" => "Product name",
"price" => "100.00",
"quantity" => 1
]
],
"card" => [
"firstName" => "Fisrtname",
"lastName" => "Lastname",
"number" => "4111111111111111",
"cvv" => "123",
"expiryMonth" => "12",
"expiryYear" => "2025",
"email" => "[email protected] "
],
"returnUrl" => "https://example.org/paylane-success.php",
"cancelUrl" => "https://example.org/paylane-error.php",
"notifyUrl" => "https://example.org/paylane-callback.php",
]
)->send();
// Process response
if ($response->isSuccessful()) {
$result = $response->getData();
if ($response->isRedirect()) {
$response->redirect();
}
}
else {
// Payment failed
echo $response->getMessage();
echo $response->getCode();
}
$response = $gateway->completePurchase($_POST);
if ($response->isSuccessful()) {
$message = $response->getMessage();
$status = $response->getStatus();
}
else {
$error = $response->getMessage();
$code = $response->getCode();
}