PHP code example of ptuchik / omnipay-yandex
1. Go to this page and download the library: Download ptuchik/omnipay-yandex 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/ */
ptuchik / omnipay-yandex example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('Yandex');
$gateway->setShopId(env('SHOP_ID'));
$gateway->setSecretKey(env('SECRET_KEY'));
$gateway->setReturnUrl(env('RETURN_URL'));
$gateway->setAmount(10); // Amount to charge
$gateway->setCurrency('RUB'); // Currency
$purchase = $gateway->purchase()->send();
if ($purchase->isSuccessful()) {
// Do your logic
} else {
throw new Exception($purchase->getMessage());
}
$gateway = Omnipay::create('Yandex');
$gateway->setShopId(env('SHOP_ID'));
$gateway->setSecretKey(env('SECRET_KEY'));
$gateway->setReturnUrl(env('RETURN_URL'));
$gateway->setAmount(10); // Amount to refund
$gateway->setTransactionReference(10); // Payment ID
$refund = $gateway->refund()->send();
if ($refund->isSuccessful()) {
// Do your logic
} else {
throw new Exception($refund->getMessage());
}