Skip to content

receiver1/omnipay-antilopay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Omnipay: Antilopay

Antilopay online acquiring support for Omnipay

Total Downloads Latest Version Software License

Already Implemented

  • Payment creation
  • Payment notifications

To Be Implemented

  • Payment information
  • Payment cancellation
  • Withdraw creation
  • Withdraw information
  • Refund creation
  • Refund information
  • Project balance
  • Error codes

Installation

composer require league/omnipay receiver/omnipay-antilopay

Usage

Gateway Initialization

// Create a new payment gateway
$gateway = Omnipay::create('Antilopay');

// Set the secret code
$gateway->setProjectId('PROJECT ID');
$gateway->setSecretId('SECRET ID');
// Antilopay uses RSA keys, so you need to make PEM inserts so that OpenSSL can distinguish it. It will be more efficient to load the key from a file.
$gateway->setSecretKey("-----BEGIN RSA PRIVATE KEY-----\nSECRET KEY\n-----END RSA PRIVATE KEY-----");
$gateway->setCallbackKey("-----BEGIN PUBLIC KEY-----\nCALLBACK KEY\n-----END PUBLIC KEY-----");

Payment Creation

// Create a new payment for 100 rubles 00 kopecks
$purchaseRequest = $gateway->purchase([
  'amount' => 100,
  'orderId' => '1',
  'product_name' => 'Balance top-up',
  'product_type' => 'goods',
  'product_quantity' => 100,
  'vat' => 10,
  'description' => 'Balance top-up 1337 Cheats',
  'returnUrl' => 'https://leet-cheats.ru/payment/success',  // success_url
  'cancelUrl' => 'https://leet-cheats.ru/payment/fail',     // fail_url
  'customer' => new CustomerReference(
    email: 'customer-email@example.com', 
    phone: '1234567890', 
    address: '123 Customer Street', 
    ip: '192.168.0.1', 
    fullname: 'Customerov Customer Customerovich'
  ),
  'prefer_methods' => ['SBP', 'SBER_PAY', 'CARD_RU'],
]);
// alternative way to set data
$purchaseRequest->setAmount(100);
$purchaseRequest->setOrderId('1');
$purchaseRequest->setProductName('Balance top-up');
$purchaseRequest->setProductType('goods');
$purchaseRequest->setProductQuantity(100);
$purchaseRequest->setVat(10);
$purchaseRequest->setDescription('Balance top-up 1337 Cheats');
$purchaseRequest->setReturnUrl('https://leet-cheats.ru/payment/success');
$purchaseRequest->setCancelUrl('https://leet-cheats.ru/payment/fail');
$purchaseRequest->setCustomer(new CustomerReference(
  email: 'customer-email@example.com', 
  phone: '1234567890', 
  address: '123 Customer Street', 
  ip: '192.168.0.1', 
  fullname: 'Customerov Customer Customerovich'
));
$purchaseRequest->setPreferMethods(['SBP', 'SBER_PAY', 'CARD_RU']);

$purchaseResponse = $purchaseRequest->send();
if (!$purchaseResponse->isSuccessful()) {
  throw new Error($response->getMessage(), $response->getCode());
}

// Get the payment identifier in Antilopay
$invoiceId = $purchaseResponse->getTransactionId();
// Get the link to the Antilopay payment form
$redirectUrl = $purchaseResponse->getRedirectUrl();

Payment Verification

$notification = $gateway->acceptNotification($data);
if (
  $notification->isValid() && 
  $notification->getTransactionStatus() 
    === NotificationInterface::STATUS_COMPLETED
) {
  /** @var TransactionReference $transaction */
  $transaction = $notification->getTransactionReference();
  var_dump([
    $transaction->getOrderId(),
    $transaction->getAmount(),
    $transaction->getOriginalAmount(),
    $transaction->getFee(),
    $transaction->getCurrency(),
    $transaction->getProductName(),
    $transaction->getDescription(),
    $transaction->getPayMethod(),
    $transaction->getPayData(),
    $transaction->getCustomerIp(),
    $transaction->getCustomerUserAgent(),
  ]);

  $customer = $transaction->getCustomer();
  var_dump([
    $customer->getEmail(),
    $customer->getPhone(),
    $customer->getAddress(),
    $customer->getIp(),
    $customer->getFullname(),
  ]);
}

About

Antilopay driver for the Omnipay PHP payment processing library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages