2017 © Pedro Peláez
 

library omnipay-sberbank

Omnipay driver for Sberbank

image

andrewnovikof/omnipay-sberbank

Omnipay driver for Sberbank

  • Monday, April 16, 2018
  • by AndrewNovikoff
  • Repository
  • 4 Watchers
  • 8 Stars
  • 248 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 5 Versions
  • 71 % Grown

The README.md

Sberbank acquiring for PHP

Build Status Latest Stable Version Total Downloads License, (*1)

Introduction

This library implements the work with Sberbank acquiring api via theleague Omnipay processing library for PHP. It has a clear and consistent API, is fully unit tested., (*2)

The package release 3.2.2 version supports PHP 7.1 and higher and omnipay/common v3.0.3 The package release 3.3.0 version supports PHP 8.0 and higher and omnipay/common v3.2, (*3)

Download

Composer

// This assumes that you have composer installed globally
composer require andrewnovikof/omnipay-sberbank

Solving problems with minimal stability

Add to your composer.json, (*4)

{
  "minimum-stability":"dev",
  "prefer-stable": true
}

Simple Example

use Omnipay\Omnipay;

// Setup payment gateway
$gateway = Omnipay::create('Sberbank');

// Set params for authorize request
$gateway->authorize(
    [
       'orderNumber' => $localOrderNumber, // local order number
       'amount' => $order_amount, // The amount of payment (you can use decimal with 2 precisions for copecs or string equal to decimal)
       'returnUrl' => $callback_url // succesfull callback url
    ]
);

// Enable test mode
$gateway->setTestMode(true);

// You can set parameters via setters, for example:
$gateway->setUserName('merchant_login')
        ->setPassword('merchant_password')
        ->setOrderNumber($localOrderNumber)
        ->setLanguage('en');

// Send request
$response = $gateway->send();

// Process response
if ($response->isSuccessful()) {

    // Payment was successful
    print_r($response);

    // Get gateway orderId
    $gatewayOrderId = $response->getOrderId();

    // Get manualy get redirect url to offsite payment gateway
    $offsiteGateway = $response->getRedirectUrl();
} else {

     // Payment failed
     echo $response->getMessage();
}

// Work with redirect
if ($response->isRedirect()) {

    // Redirect to offsite payment gateway
    $response->redirect();

} 

Payment Methods

Order registration without pre-authorization

Order registration with pre-authorization

Order completion after pre-authorization

Orders status

Extended order status

Void order

Refund for an order payment

Verify the involvement of the map in 3DS

Statistics on payments for the period

Add a card to the list of SSL-cards

, (*5)

Order registration without pre-authorization

More about this request you'll see in Sberbank official documentation -> item 1 or in our source code, (*6)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->authorize(
    [
       'orderNumber' => $localOrderNumber, // local order number
       'amount' => $order_amount, // The amount of payment (you can use decimal with 2 precisions for copecs or string equal to decimal)
       'returnUrl' => $callback_url, // succesfull callback url
       'description' => 'Order Description'
    ]
)->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Payment was successful
    print_r($response);

    // Get gateway orderId
    $gatewayOrderId = $response->getOrderId();

    // Get manualy get redirect url to offsite payment gateway
    $offsiteGateway = $response->getRedirectUrl();
} else {

     // Payment failed
     echo $response->getMessage();
}

// Work with redirect
if ($response->isRedirect()) {

    // Redirect to offsite payment gateway
    $response->redirect();

} 

, (*7)

Order registration with pre-authorization

More about this request you'll see in Sberbank official documentation -> item 1 or in our source code, (*8)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->authorize(
    [
       'orderNumber' => $localOrderNumber, // local order number
       'amount' => $order_amount, // The amount of payment (you can use decimal with 2 precisions for copecs or string equal to decimal)
       'returnUrl' => $callback_url, // succesfull callback url
       'description' => 'Order Description'
    ]
)->setTwoStage(true)
 ->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Payment was successful
    print_r($response);

    // Get gateway orderId
    $gatewayOrderId = $response->getOrderId();

    // Get manualy get redirect url to offsite payment gateway
    $offsiteGateway = $response->getRedirectUrl();
} else {

     // Payment failed
     echo $response->getMessage();
}

// Work with redirect
if ($response->isRedirect()) {

    // Redirect to offsite payment gateway
    $response->redirect();

} 

, (*9)

Order completion after pre-authorization

More about this request you'll see in Sberbank official documentation -> item 2 or in our source code, (*10)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->capture(
    [
       'orderId' => $localOrderNumber, // gateway order number
       'amount' => $order_amount, // The amount of payment (you can use decimal with 2 precisions for copecs or string equal to decimal)
    ]
)->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Get response code
    $code = $response->getCode();
} else {

     // Payment failed
     echo $response->getMessage();
}

, (*11)

Orders status

More about this request you'll see in Sberbank official documentation -> item 5 or in our source code, (*12)

This method work for completeAuthorize() and completePurchase() requests of Omnipay., (*13)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->orderStatus( // It will be similar to calling methods `completeAuthorize()` and `completePurchase()`
    [
       'orderId' => $localOrderNumber, // gateway order number
       'language' => 'en'
    ]
)->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Get response code
    $code = $response->getCode();

    // Get paid amount 
    $paid_amount = $response->getAmount();

    // Get other data
    $order_status = $response->getOrderStatus();
    $order_number = $response->getOrderNumber();
    $order_pan = $response->getPan();
    $order_expiration = $response->getExpiration();
    $order_cardholder_name = $response->getCardHolderName();
    $order_currency = $response->getCurrency();
    $order_approval_code = $response->getApprovalCode();
    $order_ip = $response->getIp();
    $order_client_id = $response->getClientId();
    $order_binding_id = $response->getBindingId();
} else {

     // Payment failed
     echo $response->getMessage();
}

, (*14)

Extended order status

More about this request you'll see in Sberbank official documentation -> item 6 or in our source code, (*15)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->extendedOrderStatus(
    [
       'orderId' => $localOrderNumber, // gateway order number
       'language' => 'en'
    ]
)->setOrderNumber($localORderNumber) // You can set local orderNumber Instead of an orderId of gateway system
 ->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Get response code
    $code = $response->getCode();

    // Get paid amount 
    $paid_amount = $response->getAmount();

    // Get other data
    $order_status = $response->getOrderStatus();
    $order_number = $response->getOrderNumber();
    $order_pan = $response->getPan();
    $order_expiration = $response->getExpiration();
    $order_cardholder_name = $response->getCardHolderName();
    $order_currency = $response->getCurrency();
    $order_approval_code = $response->getApprovalCode();
    $order_ip = $response->getIp();
    $order_client_id = $response->getClientId();
    $order_binding_id = $response->getBindingId();
    $order_merchant_order_params = $response->getMerchantOrderParams();
    $order_eci = $response->getEci();
    $order_cavv = $response->getCavv();
    $order_xid = $response->getXid();
    $order_auth_date_time = $response->getAuthDateTime();
    $order_auth_ref_num = $response->getAuthRefNum();
    $order_terminal_id = $response->getTerminalId();
    $order_approved_amount = $response->getApprovedAmount();
    $order_deposited_amount = $response->getDepositedAmount();
    $order_refunded_amount = $response->getRefundedAmount();
    $order_payment_state = $response->getPaymentState();
    $order_bank_name = $response->getBankName();
    $order_bank_country_code = $response->getBankCountryCode();
    $order_band_country_name = $response->getBankCountryName();
} else {

     // Payment failed
     echo $response->getMessage();
}

, (*16)

Void order

More about this request you'll see in Sberbank official documentation -> item 3 or in our source code, (*17)

To request cancellation of payment for an order, use the request reverse.do. The cancellation function is available for a limited time after payment, the exact terms should be specified in the Bank., (*18)

The cancellation operation can only be performed once. If it ends with an error, then the repeated cancellation operation will fail., (*19)

This function is available to stores in consultation with the Bank. To perform the cancellation operation, the user must have the appropriate rights., (*20)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->void(
    [
       'orderId' => $localOrderNumber, // gateway order number
       'language' => 'en'
    ]
)->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Get response code
    $code = $response->getCode();
} else {

     // Payment failed
     echo $response->getMessage();
}

, (*21)

Refund for an order payment

More about this request you'll see in Sberbank official documentation -> item 4 or in our source code, (*22)

For this request, the funds will be returned to the payer on the specified order. The request will end with an error if the funds for this order were not written off. The system allows you to return funds more than once, but in total no more than the original amount of write-off., (*23)

To perform a return operation, you must have the appropriate rights in the system., (*24)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->refund(
    [
       'orderId' => $localOrderNumber, // gateway order number
       'language' => 'en',
       'amount' => $oder_amount // // The amount of payment (you can use decimal with 2 precisions for copecs or string equal to decimal)
    ]
)->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Get response code
    $code = $response->getCode();
} else {

     // Payment failed
     echo $response->getMessage();
}

, (*25)

Verify the involvement of the map in 3DS

More about this request you'll see in Sberbank official documentation -> item 7 or in our source code, (*26)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->verifyEnrollment(
    [
       'pan' => $cardPan
    ]
)->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Get response code
    $code = $response->getCode();

    $emitter_country_name = $response->getEmitterName();
    $emitter_country_code = $response->getEmitterCountryCode();
    $enrolled = $response->getEnrolled();
} else {

     // Payment failed
     echo $response->getMessage();
}

, (*27)

Statistics on payments for the period

More about this request you'll see in Sberbank official documentation -> item 8 or in our source code, (*28)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->getLastOrdersForMerchants(
    [
       'size' => $size,
       'from' => $from,
       'to' => $to,
       'transactionStates' => $transactionStates,
       'merchants' => $merchants
    ]
)->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Get response code
    $code = $response->getCode();

    $total_count = $response->getTotalCount();
    $page = $response->getPage();
    $page_size = $response->getPageSize();

    // Available getters
    $response->getOrderErrorCode($orderIndex);
    $response->getOrderNumber($orderIndex);
    $response->getOrderStatus($orderIndex);
    $response->getActionCode($orderIndex);
    $response->getActionCodeDescription($orderIndex);
    $response->getAmount($orderIndex);
    $response->getCurrency($orderIndex);
    $response->getDate($orderIndex);
    $response->getOrderDescription($orderIndex);
    $response->getIp($orderIndex);
    $response->getMerchantOrderParamName($orderIndex, $paramIndex);
    $response->getMerchantOrderParamValue($orderIndex, $paramIndex);
    $response->getAttributesName($orderIndex, $attributeIndex);
    $response->getAttributesValue($orderIndex, $attributeIndex);
    $response->getExpiration($orderIndex);
    $response->getCardholderName($orderIndex);
    $response->getApprovalCode($orderIndex);
    $response->getPan($orderIndex);
    $response->getClientId($orderIndex);
    $response->getBindingId($orderIndex);
    $response->getAuthDateTime($orderIndex);
    $response->getTerminalId($orderIndex);
    $response->getAuthRefNum($orderIndex);
    $response->getPaymentState($orderIndex);
    $response->getApprovedAmount($orderIndex);
    $response->getDepositedAmount($orderIndex);
    $response->getRefundedAmount($orderIndex);
    $response->getBankName($orderIndex);
    $response->getBankCountryName($orderIndex);
    $response->getBankCountryCode($orderIndex);
} else {

     // Payment failed
     echo $response->getMessage();
}

, (*29)

Add a card to the list of SSL-cards

More about this request you'll see in Sberbank official documentation -> item 9 or in our source code, (*30)

use Omnipay\Omnipay;

$gateway = Omnipay::create('Sberbank');
$response = $gateway->verifyEnrollment(
    [
       'mdorder' => $mdorder
    ]
)->setUserName('merchant_login')
 ->setPassword('merchant_password')
 ->send();

// Process response
if ($response->isSuccessful()) {

    // Get response code
    $code = $response->getCode();
} else {

     // Payment failed
     echo $response->getMessage();
}

The Versions

16/04 2018

dev-master

9999999-dev

Omnipay driver for Sberbank

  Sources   Download

MIT

The Requires

 

The Development Requires

by AndrewNovikof

api rest payment sberbank acquiring

16/04 2018

3.1.alpha.2

3.1.0.0-alpha2

Omnipay driver for Sberbank

  Sources   Download

MIT

The Requires

 

The Development Requires

by AndrewNovikof

api rest payment sberbank acquiring

21/12 2017

3.0.3

3.0.3.0

Omnipay driver for Sberbank

  Sources   Download

MIT

The Requires

 

The Development Requires

by AndrewNovikof

api rest payment sberbank acquiring

20/12 2017

3.0.2

3.0.2.0

Omnipay driver for Sberbank

  Sources   Download

MIT

The Requires

 

The Development Requires

by AndrewNovikof

api rest payment sberbank acquiring

19/12 2017

3.0.1

3.0.1.0

Omnipay driver for Sberbank

  Sources   Download

MIT

The Requires

 

The Development Requires

by AndrewNovikof

api rest payment sberbank acquiring