Moldova Agroindbank Payment PHP SDK

Related tags

API maibapi
Overview

#Moldova Agroindbank Payment PHP SDK

maib-api

N|Solid

CONTENTS OF THIS FILE

  • Introduction
  • Requirements
  • Recommended modules
  • Installation
  • Before usage
  • Usage
  • Troubleshoting
  • Maintainers

INTRODUCTION

The Moldova Agroindbank Payment PHP SDK is used to easily integrate the MAIB Payment into your project. Based on the Guzzle Libraries to connect and process the requests with the Bank server and the Monolog library to log the requests responses.

The Moldova Agroindbank Payment PHP SDK has 2 ways of payment.

  • One way is SMS Transaction (registerSmsTransaction). When the client's money transfers on the merchant account instantly when the user do the payment. This way is recommended use.
  • Another way is DMS Transaction (registerDmsAuthorization). When the client's money has been blocked on their account before you confirm that transaction. This way is mostly used in the case of the long shipping time.

That Payment PHP SDK includes 6 methods to process the payments:

  • Registering transactions.
  • Registering DMS authorization.
  • Executing a DMS transaction.
  • Get transaction result.
  • Transaction reversal.
  • Close the work day.

REQUIREMENTS

  • PHP: >=8.1.0
  • guzzlehttp/guzzle: ~7.0
  • guzzlehttp/guzzle-services: ~1.0
  • monolog/monolog: ^2.7

INSTALLATION

  • Run composer require maib/maibapi ^3.0

BEFORE USAGE

To initiate an payment transaction you need to obtain the SSL certificate, to get the access by IP and to set the callback URL.

  • Need to write an email to maib commerce support: [email protected] with the request including The Merchant IP and callback URL, to receive access and certificate for testing.
  • When you get the certificate, you need to generate the private and the public keys, using the terminal package OpenSSL
    • openssl pkcs12 -in 0149583.pfx -nocerts -out key.pem
    • openssl pkcs12 -in 0149583.pfx -clcerts -nokeys -out pcert.pem
    • openssl pkcs12 -in 0149583.pfx -cacerts -nokeys -out cacert.pem
  • Need to save the generated keys into map on server to usage in the requests.

USAGE

  • Need to include all libraries
  <?php

  namespace MyProject;

  require_once(__DIR__ . '/vendor/autoload.php');

  use Monolog\Handler\StreamHandler;
  use Monolog\Logger;
  use GuzzleHttp\Client;
  use GuzzleHttp\HandlerStack;
  use GuzzleHttp\Middleware;
  use GuzzleHttp\MessageFormatter;
  use Maib\MaibApi\MaibClient;
  • Setup the log stack
  if ((isset($log_is_required) && $log_is_required)) {
      $log = new Logger('maib_guzzle_request');
      $log->pushHandler(new StreamHandler(__DIR__.'/logs/maib_guzzle_request.log', Logger::DEBUG));
      $stack = HandlerStack::create();
      $stack->push(
          Middleware::log($log, new MessageFormatter(MessageFormatter::DEBUG))
      );
  }
  • Init the MaibCLient
  $options = [
    'base_uri' => MaibClient::MAIB_TEST_BASE_URI,
    'debug'  => false,
    'verify' => true,
    'cert'    => [MaibClient::MAIB_TEST_CERT_URL, MaibClient::MAIB_TEST_CERT_PASS],
    'ssl_key' => MaibClient::MAIB_TEST_CERT_KEY_URL,
    'config'  => [
      'curl'  =>  [
        CURLOPT_SSL_VERIFYHOST => 2,
        CURLOPT_SSL_VERIFYPEER => true,
      ]
    ]
  ];
  if (isset($stack)) {
      $options['handler'] = $stack;
  }
  $guzzleClient = new Client($options);
  $client = new MaibClient($guzzleClient);
  • Prepare the payment parameters
  // The Parameters required to use MaibClient methods
  $amount = 1; // The amount of the transaction
  $currency = 978; // The currency of the transaction - is the 3 digits code of currency from ISO 4217
  $clientIpAddr = '127.0.0.1'; // The client IP address
  $description = 'testing'; // The description of the transaction
  $lang = 'en'; // The language for the payment gateway

  // Other parameters
  $sms_transaction_id = null;
  $dms_transaction_id = null;
  $redirect_url = MaibClient::MAIB_TEST_REDIRECT_URL . '?trans_id=';
  $sms_redirect_url = '';
  $dms_redirect_url = '';
  • Registering SMS transactions The SMS transaction has 2 steps.

    • The first step is to register the transaction on the Maib Server and obtain the TRANSACTION_ID using the registerSmsTransaction Method.
    • The second step is the redirected user to the Maib Payment Gateway URL using the TRANSACTION_ID.
    • When the transaction has been finalised, the Maib Payment Gateway redirects the user to your callback URL where you get the transaction status. ! The TRANSACTION_ID has a timeout of 10 minutes.
    • Required parameters:
      • $amount = 1; // The amount of the transaction
      • $currency = 978; // The currency of the transaction - is the 3 digits code of currency from ISO 4217
      • $clientIpAddr = '127.0.0.1'; // The client IP address
      • $description = 'testing'; // The description of the transaction
      • $lang = 'en'; // The language for the payment gateway
    • Response: return array TRANSACTION_ID
      • TRANSACTION_ID - transaction identifier (28 characters in base64 encoding)
      • error - in case of an error
  // The register sms transaction method
  $registerSmsTransaction = $client->registerSmsTransaction($amount, $currency, $clientIpAddr, $description, $lang);
  $sms_transaction_id = $registerSmsTransaction["TRANSACTION_ID"];
  $sms_redirect_url = $redirect_url . $sms_transaction_id;
  • Registering DMS authorization The DMS transaction has 3 steps.
    • The first step is to register the transaction on the Maib Server and obtain the TRANSACTION_ID using the registerDmsAuthorization Method.
    • The second step is the redirected user to the Maib Payment Gateway URL using the TRANSACTION_ID.
    • When the transaction has been applied, the Maib Payment Gateway redirects the user to your callback URL where you get the transaction status.
    • The third step is to confirm transactions using the makeDMSTrans method.

    • Required parameters:

      • $amount = 1; // The amount of the transaction.
      • $currency = 978; // The currency of the transaction - is the 3 digits code of currency from ISO 4217.
      • $clientIpAddr = '127.0.0.1'; // The client IP address.
      • $description = 'testing'; // The description of the transaction.
      • $lang = 'en'; // The language for the payment gateway.
    • Response: return array TRANSACTION_ID

      • TRANSACTION_ID - transaction identifier (28 characters in base64 encoding)
      • error - in case of an error
  // The register dms authorization method
  $registerDmsAuthorization = $client->registerDmsAuthorization($amount, $currency, $clientIpAddr, $description, $lang);
  $dms_transaction_id = $registerDmsAuthorization["TRANSACTION_ID"];
  $dms_redirect_url = $redirect_url . $dms_transaction_id;
  • Executing a DMS transaction
    • Required parameters:
      • $dms_transaction_id;// The transaction ID from registerDmsAuthorization.
      • $amount = 1; // The amount of the transaction.
      • $currency = 978; // The currency of the transaction - is the 3 digits code of currency from ISO 4217.
      • $clientIpAddr = '127.0.0.1'; // The client IP address.
      • $description = 'testing'; // The description of the transaction.
      • $lang = 'en'; // The language for the payment gateway.
    • Response: return array RESULT, RESULT_CODE, BRN, APPROVAL_CODE, CARD_NUMBER, error
      • RESULT - transaction results: OK - successful transaction, FAILED - failed transaction
      • RESULT_CODE - transaction result code returned from Card Suite Processing RTPS (3 digits)
      • BRN - retrieval reference number returned from Card Suite Processing RTPS (12 characters)
      • APPROVAL_CODE - approval code returned from Card Suite Processing RTPS (max 6 characters)
      • CARD_NUMBER - masked card number
      • error - in case of an error
  // The execute dms transaction method
  $makeDMSTrans = $client->makeDMSTrans($dms_transaction_id, $amount, $currency, $clientIpAddr, $description, $language);
  • Get transaction result You can get the transaction status yourself using the getTransactionResult method. But do not forget, the transaction ID has a timeout of 10 minutes.
    • Required parameters:
      • $transaction_id;// The transaction ID from registerSmsTransaction or registerDmsAuthorization.
      • $clientIpAddr = '127.0.0.1'; // The client IP address.
    • Response: return array RESULT, RESULT_PS, RESULT_CODE, 3DSECURE, RRN, APPROVAL_CODE, CARD_NUMBER, AAV, RECC_PMNT_ID, RECC_PMNT_EXPIRY, MRCH_TRANSACTION_ID
      • RESULT
        • OK - successfully completed transaction,
        • FAILED - transaction has failed,
        • CREATED - transaction just registered in the system,
        • PENDING - transaction is not accomplished yet,
        • DECLINED - transaction declined by ECOMM,
        • REVERSED - transaction is reversed,
        • AUTOREVERSED - transaction is reversed by autoreversal,
        • TIMEOUT - transaction was timed out
      • RESULT_PS - transaction result, Payment Server interpretation (shown only if configured to return ECOMM2 specific details
        • FINISHED - successfully completed payment,
        • CANCELLED - cancelled payment,
        • RETURNED - returned payment,
        • ACTIVE - registered and not yet completed payment.
      • RESULT_CODE - transaction result code returned from Card Suite Processing RTPS (3 digits)
      • 3DSECURE
        • AUTHENTICATED - successful 3D Secure authorization
        • DECLINED - failed 3D Secure authorization
        • NOTPARTICIPATED - cardholder is not a member of 3D Secure scheme
        • NO_RANGE - card is not in 3D secure card range defined by issuer
        • ATTEMPTED - cardholder 3D secure authorization using attempts ACS server
        • UNAVAILABLE - cardholder 3D secure authorization is unavailable
        • ERROR - error message received from ACS server
        • SYSERROR - 3D secure authorization ended with system error
        • UNKNOWNSCHEME - 3D secure authorization was attempted by wrong card scheme (Dinners club, American Express)
      • RRN - retrieval reference number returned from Card Suite Processing RTPS
      • APPROVAL_CODE - approval code returned from Card Suite Processing RTPS (max 6 characters)
      • CARD_NUMBER - Masked card number
      • AAV - FAILED the results of the verification of hash value in AAV merchant name (only if failed)
      • RECC_PMNT_ID - Reoccurring payment (if available) identification in Payment Server.
      • RECC_PMNT_EXPIRY - Reoccurring payment (if available) expiry date in Payment Server in form of YYMM
      • MRCH_TRANSACTION_ID - Merchant Transaction Identifier (if available) for Payment - shown if it was sent as additional parameter on Payment registration.
      • The RESULT_CODE and 3DSECURE fields are informative only and can be not shown.
      • The fields RRN and APPROVAL_CODE appear for successful transactions only, for informative purposes,
      • and they facilitate tracking the transactions in Card Suite Processing RTPS system.
      • error - In case of an error
      • warning - In case of warning (reserved for future use).
  // The get transaction result method
  $getTransactionResult = $client->getTransactionResult($transaction_id, $clientIpAddr);
  • Transaction reversal The ability to perform a return operation, partially or completely.
    • Required parameters:
      • $transaction_id;// The transaction ID from registerSmsTransaction or registerDmsAuthorization.
      • $amount = 1; // The amount of the transaction.
    • Response: return array RESULT, RESULT_CODE
      • RESULT
        • OK - successful reversal transaction
        • REVERSED - transaction has already been reversed
        • FAILED - failed to reverse transaction (transaction status remains as it was)
      • RESULT_CODE - reversal result code returned from Card Suite Processing RTPS (3 digits)
      • error - In case of an error
      • warning - In case of warning (reserved for future use).
  // The revert transaction method
  $revertTransaction = $client->revertTransaction($transaction_id, $amount);
  • Close the work day Execute automatic closing of the day, recommended use time: 23:59:00.
    • Required parameters:
      • No parameters Required.
    • Response: return array RESULT, RESULT_CODE, FLD_075, FLD_076, FLD_087, FLD_088
      • RESULT - OK - successful end of business day FAILED - failed end of business day
      • RESULT_CODE - end-of-business-day code returned from Card Suite Processing RTPS (3 digits)
      • FLD_075 - the number of credit reversals (up to 10 digits), shown only if result_code begins with 5
      • FLD_076 - the number of debit transactions (up to 10 digits), shown only if result_code begins with 5
      • FLD_087 - total amount of credit reversals (up to 16 digits), shown only if result_code begins with 5
      • FLD_088 - total amount of debit transactions (up to 16 digits), shown only if result_code begins with 5
  //close business day
  $closeDay = $client->closeDay();

TROUBLESHOTING

All transactions are considered successful it's only if you receive a predictable response from the maib server in the format you know. If you receive any other result (NO RESPONSE, Connection Refused, something else) there is a problem. In this case it is necessary to collect all logs and sending them to maib by email: [email protected], in order to provide operational support. The following information should be indicated in the letter:

  • Merchant name,
  • Web site name,
  • Date and time of the transaction made with errors
  • Responses received from the server

MAINTAINERS

Current maintainers:

You might also like...
A complete Notion SDK for PHP developers.

notion-sdk-php A complete Notion SDK for PHP developers. Installation composer require mariosimao/notion-php Getting started A Notion token will be n

SDK of the LINE Login API for PHP

LINE Login for PHP SDK of the LINE Login API for PHP Documentation See the official API documentation for more information. Installation Use the packa

PHP SDK - Flexie CRM fiskalizimi solution

PHP SDK - Flexie CRM fiskalizimi solution Fiskalizimi PHP SDK allows you to talk and generate your e-invoices programmatically from your own solution

PHP Digital Green Certificate SDK

Digital Green Certificate SDK PHP Indice Contesto Installazione Uso Licenza Dettaglio licenza Contesto Attenzione, questo repository è derivato dalle

Esse SDK em PHP foi desenvolvido no intuito de tornar mais prático a integração com nossa API.

Sobre Beedoo SDK Acessar documentação completa da Beedoo API. A API é organizada seguindo a arquitetura REST, boas práticas, convenções e padrões como

A PHP SDK for accessing the OpenAI GPT-3 API
A PHP SDK for accessing the OpenAI GPT-3 API

OpenAI GPT-3 Api Client in PHP Installation You can install the package via composer: composer require orhanerday/open-ai Usage use Orhanerday\OpenAi\

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login

Facebook SDK for PHP (v5) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

PHP SDK for the Sellix Developers API (developers.sellix.io)

PHP SDK for the Sellix Developers API (developers.sellix.io). Quickly get started and create products, payments and more using PHP.

Alibaba Cloud SDK for PHP

English | 简体中文 Alibaba Cloud SDK for PHP Alibaba Cloud SDK for PHP is a development kit that supports quick access to products, dependency on Alibaba

Owner
MAIB Moldova
MAIB Moldova
Zoho CRM API SDK is a wrapper to Zoho CRM APIs. By using this sdk, user can build the application with ease

Archival Notice: This SDK is archived. You can continue to use it, but no new features or support requests will be accepted. For the new version, refe

null 81 Nov 4, 2022
A Ping++ driver for the Omnipay PHP payment processing library

Omnipay: Pingpp Introduction Ping++ driver for the Omnipay PHP payment processing library Ping++ is a Chinese leading payment integration service prov

Phx 241 Dec 14, 2022
The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructure and leverage the power of 1Password Secrets Automation

1Password Connect PHP SDK The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructu

Michelangelo van Dam 12 Dec 26, 2022
Facebook SDK for PHP (v6) - allows you to access the Facebook Platform from your PHP app

Facebook SDK for PHP (v6) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

null 0 Aug 10, 2022
Unofficial Firebase Admin SDK for PHP

Firebase Admin PHP SDK Table of Contents Overview Installation Documentation Support License Overview Firebase provides the tools and infrastructure y

kreait 1.9k Jan 3, 2023
Notion PHP SDK

Notion PHP SDK This is an unofficial PHP SDK for the new public Notion API. It's work in progress as we didn't get the change to be included to the pr

Codecycler 43 Nov 29, 2022
爱发电非官方简易 PHP SDK

afdian-php-sdk 爱发电非官方简易 PHP SDK by Akkariin 这是一个简单的 SDK,可以用于查询爱发电的订单和赞助者信息 Installation 将项目 clone 到本地即可 git clone https://github.com/ZeroDream-CN/afdi

ZeroDream-CN 17 Nov 7, 2022
AWS Cognito package using the AWS SDK for PHP/Laravel

Laravel Package to manage Web and API authentication with AWS Cognito AWS Cognito package using the AWS SDK for PHP This package provides a simple way

EllaiSys 74 Nov 15, 2022
PHP SDK to interact with the Casper Network nodes via RPC

casper-php-sdk PHP SDK to interact with Casper Network nodes via RPC Install composer require make-software/casper-php-sdk Examples RPC Client: $node

MAKE Technology LLC 7 May 8, 2022
A Laravel 5+ (and 4) service provider for the AWS SDK for PHP

AWS Service Provider for Laravel 5/6/7/8 This is a simple Laravel service provider for making it easy to include the official AWS SDK for PHP in your

Amazon Web Services 1.5k Dec 28, 2022