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

Source for file AMI_PaymentSystemDriver.php

Documentation is available at AMI_PaymentSystemDriver.php

  • <?php
  • /**
  •  * @copyright  Amiro.CMS. All rights reserved. The changes are undesirable and dangerous.
  •  * @category   AMI
  •  * @package    Driver_PaymentSystem
  •  * @version    $Id: AMI_PaymentSystemDriver.php 47361 2014-02-03 05:48:50Z Leontiev Anton $
  •  * @since      5.10.0
  •  * @filesource
  •  */
  •  
  • /**
  •  * Payment system driver.
  •  *
  •  * @package Driver_PaymentSystem
  •  * @since   5.10.0
  •  */
  • abstract class AMI_PaymentSystemDriver extends BILL_driver_base{
  •  
  •     /**
  •      * Driver path relative to pay_drivers/
  •      *
  •      * @var string 
  •      */
  •     protected $driverName = '';
  •  
  •     /**
  •      * Initializing driver.
  •      *
  •      * @param GUI_Template $vGui  GUI_Template object, required for process templates data
  •      * @amidev
  •      */
  •     final public function __construct(GUI_Template $vGui){
  •         $this->driverName = AMI::getModId(get_class($this));
  •         parent::__construct($vGui);
  •     }
  •  
  •     /**
  •      * Get checkout button HTML form.
  •      *
  •      * @param array &$aRes  Will contain "error" (error description, 'Success by default') and "errno" (error code, 0 by default). "forms" will contain a created form
  •      * @param array $aData  The data list for button generation
  •      * @param bool $bAutoRedirect  If form autosubmit required (directly from checkout page)
  •      * @return bool true if form is generated, false otherwise
  •      */
  •     public function getPayButton(array &$aResarray $aData$bAutoRedirect false){
  •         if(!isset($aRes['error'])){
  •             $aRes["error""Success";
  •         }
  •         if(!isset($aRes['errno'])){
  •             $aRes["errno""0";
  •         }
  •  
  •         return parent::getPayButton($aRes$aData$bAutoRedirect);
  •     }
  •  
  •     /**
  •      * Get the form that will be autosubmitted to payment system. This step is required for some shooping cart actions.
  •      *
  •      * @param array $aData  The data list for button generation
  •      * @param array &$aRes  Will contain "error" (error description, 'Success by default') and "errno" (error code, 0 by default). "forms" will contain a created form
  •      * @return bool true if form is generated, false otherwise
  •      */
  •     public function getPayButtonParams(array $aDataarray &$aRes){
  •         if(!isset($aRes['error'])){
  •             $aRes["error""Success";
  •         }
  •         if(!isset($aRes['errno'])){
  •             $aRes["errno""0";
  •         }
  •  
  •         return parent::getPayButtonParams($aData$aRes);
  •     }
  •  
  •     /**
  •      * Verify the order from user back link. In success case 'accepted' status will be setup for order.
  •      *
  •      * @param array $aGet  HTTP GET variables
  •      * @param array $aPost  HTTP POST variables
  •      * @param array &$aRes  Reserved array reference
  •      * @param array $aCheckData  Data that provided in driver configuration
  •      * @param array $aOrderData  Order data that contains such fields as id, total, order_date, status
  •      * @return bool true if order is correct and false otherwise
  •      */
  •     public function payProcess(array $aGetarray $aPostarray &$aResarray $aCheckDataarray $aOrderData){
  •         $status 'fail';
  •  
  •         // Merge Get and Post
  •         if(!@is_array($aGet)){
  •             $aGet Array();
  •         }
  •         if(!@is_array($aPost)){
  •             $aPost Array();
  •         }
  •         $aParams array_merge($aGet$aPost);
  •  
  •         // Base check
  •         if(!empty($aParams['status'])){
  •             $status $aParams['status'];
  •         }
  •  
  •         // Do your return url checking here
  •  
  •         return $status == 'ok';
  •     }
  •  
  •     /**
  •      * Verify the order by payment system background responce. In success case 'confirmed' status will be setup for order.
  •      *
  •      * @param array $aGet  HTTP GET variables
  •      * @param array $aPost  HTTP POST variables
  •      * @param array &$aRes  Reserved array reference
  •      * @param array $aCheckData  Data that provided in driver configuration
  •      * @param array $aOrderData  Order data that contains such fields as id, total, order_date, status
  •      * @return int -1 - ignore post, 0 - reject(cancel) order, 1 - confirm order
  •      */
  •     public function payCallback(array $aGetarray $aPostarray &$aResarray $aCheckDataarray $aOrderData){
  •         // Merge Get and Post
  •         if(!@is_array($aGet)){
  •             $aGet Array();
  •         }
  •         if(!@is_array($aPost)){
  •             $aPost Array();
  •         }
  •         $aParams array_merge($aGet$aPost);
  •  
  •         // Do your parameters checking here
  •         $status = -1;
  •  
  •         return $status;
  •     }
  •  
  •     /**
  •      * Return real system order id from data that provided by payment system.
  •      *
  •      * @param array $aGet  HTTP GET variables
  •      * @param array $aPost  HTTP POST variables
  •      * @param array &$aRes  Reserved array reference
  •      * @param array $aAdditionalParams  Reserved array
  •      * @return int order Id
  •      */
  •     public function getProcessOrder(array $aGetarray $aPostarray &$aResarray $aAdditionalParams){
  •         $orderId 0;
  •  
  •         $aData (is_array($aGet$aGet array())(is_array($aPost$aPost array());
  •         if(isset($aAdditionalParams['aPossibleVarNames'])){
  •             $aPossibleVarNames $aAdditionalParams['aPossibleVarNames'];
  •         }else{
  •             $aPossibleVarNames array('order_id''item_number''InvId''inv_id''shopping-cart.items.item-1.item-name''shopping-cart_items_item-1_item-name''transaction_id');
  •         }
  •         foreach($aPossibleVarNames as $varName){
  •             if(isset($aData[$varName])){
  •                 $orderId intval($aData[$varName]);
  •                 break;
  •             }
  •         }
  •  
  •         return $orderId;
  •     }
  •  
  •     /**
  •      * Do required operations after the payment is confirmed with payment system call.
  •      *
  •      * @param int $orderId  Id of order in the system will be passed to this function
  •      * @return void 
  •      */
  •     public function onPaymentConfirmed($orderId){
  •     }
  •  
  •     /**
  •      * Returns scope as HTML form hidden fields.
  •      *
  •      * @param  array $aScope  Varisbles
  •      * @return string 
  •      * @since  6.0.4
  •      */
  •     protected function getScopeAsFormHiddenFields(array $aScope){
  •         $hiddens '';
  •         foreach($aScope as $name => $value){
  •             $hiddens .= '<input type="hidden" name="' $name '" value="' $value '" />' "\n";
  •         }
  •  
  •         return $hiddens;
  •     }
  • }