Amiro.CMS API Reference
Amiro.Ru / Manual
Loading search...

The Example_PaymentSystemDriver class

BILL_driver_base
   |
   --AMI_PaymentSystemDriver
      |
      --Example_PaymentSystemDriver

• Introduction

Example pay driver.

• Class synopsis

Example_PaymentSystemDriver extends AMI_PaymentSystemDriver {
/* Inherited Properties */
// Flag specifying to clear cart on pay process
// Currencies.
// Iniitial currencies.
// Driver name
/* Methods */
// Get checkout button HTML form
public getPayButton ( &$aRes, $aData, [ bool $bAutoRedirect = false ], array $aRes ) returns bool;
// Get the form that will be autosubmitted to payment system. This step is required for some shooping cart actions.
public getPayButtonParams ( $aData, &$aRes, array $aRes ) returns bool;
// Return real system order id from data that provided by payment system.
public getProcessOrder ( $aGet, $aPost, &$aRes, $aAdditionalParams, array $aRes ) returns int;
// Verify the order by payment system background responce. In success case 'confirmed' status will be setup for order.
public payCallback ( $aGet, $aPost, &$aRes, $aCheckData, $aOrderData, array $aRes ) returns int;
// Verify the order from user back link. In success case 'accepted' status will be setup for order.
public payProcess ( $aGet, $aPost, &$aRes, $aCheckData, $aOrderData, array $aRes ) returns bool;
/* Inherited Methods */
// Get checkout button HTML form.
public AMI_PaymentSystemDriver::getPayButton ( &$aRes, $aData, [ bool $bAutoRedirect = false ] ) returns bool;
// Get the form that will be autosubmitted to payment system. This step is required for some shooping cart actions.
public AMI_PaymentSystemDriver::getPayButtonParams ( $aData, &$aRes ) returns bool;
// Return real system order id from data that provided by payment system.
public AMI_PaymentSystemDriver::getProcessOrder ( $aGet, $aPost, &$aRes, $aAdditionalParams ) returns int;
// Do required operations after the payment is confirmed with payment system call.
public AMI_PaymentSystemDriver::onPaymentConfirmed ( int $orderId ) returns void;
// Verify the order by payment system background responce. In success case 'confirmed' status will be setup for order.
public AMI_PaymentSystemDriver::payCallback ( $aGet, $aPost, &$aRes, $aCheckData, $aOrderData ) returns int;
// Verify the order from user back link. In success case 'accepted' status will be setup for order.
public AMI_PaymentSystemDriver::payProcess ( $aGet, $aPost, &$aRes, $aCheckData, $aOrderData ) returns bool;
// Cleanups user cart by passed order Id.
protected AMI_PaymentSystemDriver::cleanupCartByOrderId ( int $orderId, [ $sessionVarName $sessionVarName = '' ] ) returns void;
// Set debug flag.
protected AMI_PaymentSystemDriver::debug ( [ bool $debug = NULL ] ) returns bool;
// Returns scope as HTML form hidden fields.
protected AMI_PaymentSystemDriver::getScopeAsFormHiddenFields ( $aScope ) returns string;
// Returns driver settings.
protected AMI_PaymentSystemDriver::getSettings ( ) returns array;
// Logs message.
protected AMI_PaymentSystemDriver::log ( string $message, [ int $level = E_USER_NOTICE ] ) returns void;
// Parses the string like "crn1 crn2 #crn3 crn4" to the array(crn3, crn1, crn2, crn4).
protected AMI_PaymentSystemDriver::parseCurrencies ( string $currencies ) returns array;
}

• Class Details

How to create your own pay driver:
  • Copy the directory "_local/eshop/pay_drivers/example" to another, i.e. "_local/eshop/pay_drivers/my_driver"
  • Open driver.php in your path and:
    • Rename driver class name to your name (MyDriver_PaymentSystemDriver). Naming rule: all words delimeted by _ should be started from uppercase letter. Not _ allowed in driver name.
    • In some cases you should to check or add some fields when printing payment button on checkout page. You can manipulate with $aData array in getPayButton method for it. The same for pay system button with autoredirect but the method is getPayButtonParams
    • User will come back to the site from payment system by special URL and system already has the checks for setting correct order status. If you want to make your manual checking do it in payProcess method.
    • For payment system background requests for order approving there is payCallback method. You need to override this method with you own check of payment data.
    • If get or post field are differ from order_id, id or item_number you need to override getProcessOrder method that will return valid order id from POST and GET request.
  • Open driver.tpl and modify sets:
    • settings_form - part of form that will be insertted to driver form when you open your driver for editing.
    • checkout_form - button that will be shown on checkout page after the list of items. ##hiddens## field is required.
    • pay_form - form that will be submitted to payment system. In most cases this form is made with autoredirect.
    • Also modify path to driver.lng.
  • Captions for drivers you can set in driver.lng.
  • After all these steps install your driver in Settings/Pay drivers page of admin panel and edit parameters. Then include your diver for the payment in option "Allowed payment drivers" of Catalog : Orders setting.

• Class Methods

// Get checkout button HTML form
public getPayButton ( &$aRes, $aData, [ bool $bAutoRedirect = false ], array $aRes ) returns bool;
  • array $aRes
    Will contain "error" (error description, 'Success by default') and "errno" (error code, 0 by default). "forms" will contain a created form
  • array $aData
    The data list for button generation
  • bool $bAutoRedirect
    If form autosubmit required (directly from checkout page)
  • array &$aRes
// Get the form that will be autosubmitted to payment system. This step is required for some shooping cart actions.
public getPayButtonParams ( $aData, &$aRes, array $aRes ) returns bool;
  • array $aData
    The data list for button generation
  • array $aRes
    Will contain "error" (error description, 'Success by default') and "errno" (error code, 0 by default). "forms" will contain a created form
  • array &$aRes
// Return real system order id from data that provided by payment system.
public getProcessOrder ( $aGet, $aPost, &$aRes, $aAdditionalParams, array $aRes ) returns int;
  • array $aGet
    $_GET data
  • array $aPost
    $_POST data
  • array $aRes
    reserved array reference
  • array $aAdditionalParams
    reserved array
  • array &$aRes

Overrides: AMI_PaymentSystemDriver::getProcessOrder().

Tags:
see AMI_PaymentSystemDriver::getProcessOrder(...)
// Verify the order by payment system background responce. In success case 'confirmed' status will be setup for order.
public payCallback ( $aGet, $aPost, &$aRes, $aCheckData, $aOrderData, array $aRes ) returns int;
  • array $aGet
    $_GET data
  • array $aPost
    $_POST data
  • array $aRes
    reserved array reference
  • array $aCheckData
    Data that provided in driver configuration
  • array $aOrderData
    order data that contains such fields as id, total, order_date, status
  • array &$aRes

Overrides: AMI_PaymentSystemDriver::payCallback().

Tags:
see AMI_PaymentSystemDriver::payCallback(...)
// Verify the order from user back link. In success case 'accepted' status will be setup for order.
public payProcess ( $aGet, $aPost, &$aRes, $aCheckData, $aOrderData, array $aRes ) returns bool;
  • array $aGet
    $_GET data
  • array $aPost
    $_POST data
  • array $aRes
    reserved array reference
  • array $aCheckData
    Data that provided in driver configuration
  • array $aOrderData
    order data that contains such fields as id, total, order_date, status
  • array &$aRes

Overrides: AMI_PaymentSystemDriver::payProcess().

Tags:
see AMI_PaymentSystemDriver::payProcess(...)