Plugin Directory

Changeset 2457199


Ignore:
Timestamp:
01/15/2021 10:21:37 PM (5 years ago)
Author:
girosolution
Message:
  1. 4.1.2 Sources, 3DS2 support
Location:
girocheckout/trunk
Files:
3 added
15 edited

Legend:

Unmodified
Added
Removed
  • girocheckout/trunk/girocheckout.php

    r2435416 r2457199  
    1010 * Plugin Name: GiroCheckout
    1111 * Description: Plugin to integrate the GiroCheckout payment methods into WooCommerce.
    12  * Version:     4.1.1
     12 * Version:     4.1.2
    1313 * Author:      GiroSolution GmbH
    1414 * Author URI:  http://www.girosolution.de
  • girocheckout/trunk/library/GiroCheckout_SDK.php

    r2346265 r2457199  
    77 *
    88 * @package GiroCheckout
    9  * @version $Revision: 274 $ / $Date: 2019-09-06 14:04:44 -0400 (Fri, 06 Sep 2019) $
     9 * @version $Revision: 321 $ / $Date: 2020-12-11 14:09:33 -0300 (Fri, 11 Dec 2020) $
    1010 */
    11 define('__GIROCHECKOUT_SDK_VERSION__', '2.1.28');
     11define('__GIROCHECKOUT_SDK_VERSION__', '2.3.1.4');
    1212
    1313if( version_compare( phpversion(), '5.3.0', '<' ) ) {
     
    2525class GiroCheckout_SDK_Autoloader {
    2626    public static function load($classname) {
     27    if( strpos($classname, 'GiroCheckout_SDK') === FALSE ) {
     28       // move to next autoloader if prefix does not belong to plugin
     29      return true;
     30    }
     31
    2732        $filename = $classname . '.php';
    2833        $pathsArray = array ('api',
     
    4752            if($path == './') {
    4853                $pathToFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . $filename;
    49             } else {
     54            }
     55            else {
    5056                $pathToFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $filename;
    5157            }
     
    5460                require_once $pathToFile;
    5561                return true;
    56             } else {
     62            }
     63            else {
    5764                continue;
    5865            }
  • girocheckout/trunk/library/GiroCheckout_SDK_Request.php

    r2346265 r2457199  
    1010 *
    1111 * @package GiroCheckout
    12  * @version $Revision: 274 $ / $Date: 2019-09-06 14:04:44 -0400 (Fri, 06 Sep 2019) $
     12 * @version $Revision: 320 $ / $Date: 2020-11-24 12:58:51 -0300 (Tue, 24 Nov 2020) $
    1313 */
    1414class GiroCheckout_SDK_Request
     
    3434  private $secret = '';
    3535
    36   /*
    37    * stores the api call request method object
     36  /**
     37   * Stores the api call request method object
     38   * @var  GiroCheckout_SDK_AbstractApi $requestMethod
    3839   */
    3940  private $requestMethod;
     
    4344   * instantiates request
    4445   *
    45    * a request method instance has to be passed (see examples section)
    46    *
    47    * @param InterfaceApi /String $apiCallMethod
     46   * A request method instance has to be passed (see examples section)
     47   *
     48   * @param GiroCheckout_SDK_AbstractApi/String $apiCallMethod
     49   * @param integer $iUseServer Server to use, 0=default, 1=Prod, 2=Dev, 3=custom URL for local use (specified in 2nd parameter)
     50   * @param string $strCustServer Optional custom server to use, mostly for local testing (only if $p_iServer is 3).
    4851   * @throws GiroCheckout_SDK_Exception_helper
    4952   */
    50   function __construct($apiCallMethod) {
     53  public function __construct($apiCallMethod, $iUseServer = 0, $strCustServer = '') {
    5154    $Config = GiroCheckout_SDK_Config::getInstance();
    5255
     
    7275        throw new GiroCheckout_SDK_Exception_helper('Failure: API call method unknown');
    7376      }
     77
     78      if( $iUseServer > 0 ) {
     79        $this->requestMethod->setServer( $iUseServer, $strCustServer );
     80      }
    7481    }
    7582
     
    93100  }
    94101
     102  public function setTransactionType( $p_strTrxType ) {
     103    $this->requestMethod = GiroCheckout_SDK_TransactionType_helper::getTransactionTypeByName($p_strTrxType);
     104  }
     105
    95106  /*
    96107   * Adds a key value pair to the params variable. Used to fill the request with data.
     
    165176   * Returns the raw response of the request.
    166177   *
    167    * @return array Response values
     178   * @return string Response values
    168179   */
    169180  public function getResponseRaw() {
     
    176187   * @param String $secret
    177188   * @return String $this own instance
     189   * @throws GiroCheckout_SDK_Exception_helper
    178190   */
    179191  public function setSecret($secret) {
     
    183195    $this->secret = $secret;
    184196    return $this;
     197  }
     198
     199  /**
     200   * Set URL to post requests to dev.girosolution.de.
     201   * This can be used when the method of changing the apache environment variable
     202   * GIROCHECKOUT_SERVER isn't applicable.
     203   * Call before submit.
     204   * @param integer $p_iServer Server to use, 0=default, 1=Prod, 2=Dev, 3=custom URL for local use (specified in 2nd parameter)
     205   * @param string $p_strCustServer Optional custom server to use, mostly for local testing (only if $p_iServer is 3).
     206   */
     207  public function setServer( $p_iServer, $p_strCustServer = '' ) {
     208    $this->requestMethod->setServer($p_iServer, $p_strCustServer);
    185209  }
    186210
     
    269293
    270294    return TRUE;
     295  }
     296
     297  /**
     298   * Validates the passed API credentials against the host using the transaction type of the current object.
     299   *
     300   * @param string $p_strMerchantId Merchant ID to test
     301   * @param string $p_strProjectId Project ID to test
     302   * @param string $p_strProjectPass Project password to test
     303   * @param string $p_strErrorDetails [OUT] Optionally pass variable here that is filled with the readon in case of return FALSE.
     304   * @return bool TRUE on successful validation, FALSE on failed validation (=wrong credentials)
     305   */
     306  public function testCredentials( $p_strMerchantId, $p_strProjectId, $p_strProjectPass, &$p_strErrorDetails = NULL ) {
     307    if( !is_null($p_strErrorDetails) ) {
     308      $p_strErrorDetails = '';
     309    }
     310
     311    $Config = GiroCheckout_SDK_Config::getInstance();
     312
     313    try {
     314      $this->setSecret($p_strProjectPass);
     315
     316      // Set some default parameters
     317      $this->addParam('merchantId', $p_strMerchantId)
     318           ->addParam('projectId', $p_strProjectId)
     319           ->addParam('merchantTxId',123456330)
     320           ->addParam('amount',-1)  // provoke validation error
     321           ->addParam('currency','EUR')
     322           ->addParam('purpose','Credential validation')
     323           ->addParam('urlRedirect','http://dummy')
     324           ->addParam('urlNotify','http://dummy');
     325
     326      if( $this->requestMethod->getPayMethod() == GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_PAYDIREKT ) {
     327        $this->addParam( 'orderId', 12345 );
     328      }
     329
     330      if ($Config->getConfig('DEBUG_MODE')) {
     331        GiroCheckout_SDK_Debug_helper::getInstance()->logParamsSet($this->params);
     332      }
     333
     334      $submitParams = $this->requestMethod->getSubmitParams($this->params);
     335
     336      if ($this->requestMethod->needsHash()) {
     337        $submitParams['hash'] = GiroCheckout_SDK_Hash_helper::getHMACMD5Hash($this->secret, $submitParams);
     338      }
     339
     340      $submitParams['sourceId'] = $this->getHostSourceId() . ';' . $this->getSDKSourceId() . ';';
     341
     342      if (isset($this->params['sourceId'])) {
     343        $submitParams['sourceId'] .= $this->params['sourceId'];
     344      }
     345      else {
     346        $submitParams['sourceId'] .= ';';
     347      }
     348
     349      // Send additional info fields for support reasons
     350      if (isset($_SERVER['HTTP_USER_AGENT'])) {
     351        $submitParams['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
     352      }
     353
     354      list($header, $body) = GiroCheckout_SDK_Curl_helper::submit($this->requestMethod->getRequestURL(), $submitParams);
     355      $this->responseRaw = print_r($header, TRUE) . "\n$body";
     356
     357      //error_log( "Response Raw: ". $this->responseRaw );
     358
     359      $response = GiroCheckout_SDK_Curl_helper::getJSONResponseToArray($body);
     360
     361      if ($response['rc'] == 5000 || $response['rc'] == 5001) {
     362        if( !is_null($p_strErrorDetails) ) {
     363          $p_strErrorDetails = 'Authentication failure, please double-check your project settings, rc=' . $response['rc'];
     364        }
     365        return FALSE;
     366      }
     367      else {
     368        return TRUE;
     369      }
     370    }
     371    catch (Exception $e) {
     372      if( !is_null($p_strErrorDetails) ) {
     373        $p_strErrorDetails = 'Exception, Failure: ' . $e->getMessage();
     374      }
     375      return FALSE;
     376    }
    271377  }
    272378
  • girocheckout/trunk/library/GiroCheckout_SDK_Request_Cart.php

    r2082698 r2457199  
    1919   * @param integer $p_iGrossAmt Gross amount (value) of the item
    2020   * @param string $p_strEAN (optional) Item id number
     21   * @throws GiroCheckout_SDK_Exception_helper
    2122   */
    2223  public function addItem( $p_strName, $p_iQuantity, $p_iGrossAmt, $p_strEAN = "" ) {
     
    4950    }
    5051    else {
    51       return json_encode($this->m_aItems, JSON_UNESCAPED_UNICODE);
     52      return json_encode($this->m_aItems, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK);
    5253    }
    5354  }
  • girocheckout/trunk/library/GiroCheckout_SDK_Tools.php

    r1801157 r2457199  
    4545    return $logoName;
    4646  }
     47
     48 /**
     49  * Build filename for logo for the specified payment method.
     50  *
     51  * @param integer $p_iPaymentMethod Payment method ID (see constants in GiroCheckout_SDK_Config)
     52  * @param integer $p_iSize Image size (height in pixels, may be 40, 50 or 60)
     53  * @return string Filename of logo file, prepend its folder path before use.
     54  */
     55 public static function getPaymentLogoFilename( $p_iPaymentMethod, $p_iSize ) {
     56    if( !in_array( $p_iSize, array(40, 50, 60) ) ) {
     57      return "";
     58    }
     59
     60    switch( $p_iPaymentMethod ) {
     61      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIROPAY:
     62      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIROPAY_AVS_PAYMENT:
     63      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIROPAY_AVS:
     64      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIROPAY_KVS:
     65      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIROPAY_INVOICE:
     66      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIROPAY_DONATE:
     67        return "Logo_giropay_{$p_iSize}_px.jpg";
     68
     69      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_EPS:
     70        return "Logo_eps_{$p_iSize}_px.jpg";
     71
     72      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIRODIRECTDEBIT:
     73      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIRODIRECTDEBIT_CHECKED:
     74      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIRODIRECTDEBIT_GUARANTEE:
     75        return "Logo_EC_{$p_iSize}_px.png";
     76
     77      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_GIROCREDITCARD:
     78        return "visa_msc_amex_{$p_iSize}px.png";  // Usually better obtained through GiroCheckout_SDK_Tools::getCreditCardLogoName()
     79
     80      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_IDEAL:
     81        return "Logo_iDeal_{$p_iSize}_px.jpg";
     82      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_PAYPAL:
     83        return "Logo_paypal_{$p_iSize}_px.png";
     84      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_PAYDIREKT:
     85        return "Logo_paydirekt_{$p_iSize}_px.jpg";
     86      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_BLUECODE:
     87        return "Logo_bluecode_{$p_iSize}_px.png";
     88      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_SOFORTUW:
     89        return "Logo_sofort_{$p_iSize}_px.png";
     90      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_MAESTRO:
     91        return "Logo_maestro_{$p_iSize}_px.png";
     92      default:
     93        return "";
     94    }
     95  }
     96
     97  /**
     98   * Validates the passed API credentials against the host.
     99   *
     100   * @param string $p_strTransactionType Type of transaction to test (is match project)
     101   * @param string $p_strMerchantId Merchant ID to test
     102   * @param string $p_strProjectId Project ID to test
     103   * @param string $p_strProjectPassword Project password to test
     104   * @param string $p_strErrorInfo [OUT] Optionally pass variable here that is filled with the readon in case of return FALSE.
     105   * @return bool TRUE on successful validation, FALSE on failed validation (=wrong credentials)
     106   */
     107  public static function testApiCredentials( $p_strTransactionType, $p_strMerchantId, $p_strProjectId, $p_strProjectPassword, &$p_strErrorInfo = NULL ) {
     108    try {
     109      $testRequest = new GiroCheckout_SDK_Request( $p_strTransactionType );
     110    }
     111    catch( Exception $e ) {
     112      if( !is_null($p_strErrorInfo) ) {
     113        $p_strErrorInfo = "Exception on creating Request object, msg=" . $e->getMessage();
     114      }
     115      return FALSE;
     116    }
     117
     118    return $testRequest->testCredentials( $p_strMerchantId, $p_strProjectId, $p_strProjectPassword, $p_strErrorInfo );
     119  }
    47120}
  • girocheckout/trunk/library/GiroCheckout_Utility.php

    r2435416 r2457199  
    1919   */
    2020  public static function getVersion() {
    21     return '4.1.1';
     21    return '4.1.2';
    2222  }
    2323
  • girocheckout/trunk/library/api/GiroCheckout_SDK_AbstractApi.php

    r2346265 r2457199  
    66 *
    77 * @package GiroCheckout
    8  * @version $Revision: 274 $ / $Date: 2019-09-06 14:04:44 -0400 (Fri, 06 Sep 2019) $
     8 * @version $Revision: 318 $ / $Date: 2020-11-18 19:18:48 -0300 (Wed, 18 Nov 2020) $
    99 */
    1010class GiroCheckout_SDK_AbstractApi implements GiroCheckout_SDK_InterfaceApi
     
    1515
    1616  /*
    17    * for developent use only
     17   * for development use only
    1818   */
    1919  function __construct() {
     
    149149  public function getRequestURL() {
    150150    return $this->requestURL;
     151  }
     152
     153  /**
     154   * Set URL to post requests to dev.girosolution.de.
     155   * This can be used when the method of changing the apache environment variable
     156   * GIROCHECKOUT_SERVER isn't applicable.
     157   * Call before submit.
     158   * @param integer $p_iServer Server to use, 0=default, 1=Prod, 2=Dev, 3=custom URL for local use (specified in 2nd parameter)
     159   * @param string $p_strCustServer Optional custom server to use, mostly for local testing (only if $p_iServer is 3).
     160   */
     161  public function setServer($p_iServer, $p_strCustServer = '') {
     162    $url = parse_url($this->requestURL);
     163    if ($p_iServer == 1) {
     164      $strSrvUrl = "https://payment.girosolution.de/";
     165    }
     166    elseif ($p_iServer == 3) {
     167      $strSrvUrl = $p_strCustServer;
     168    }
     169    else {
     170      $strSrvUrl = "https://dev.girosolution.de/";
     171    }
     172
     173    $this->requestURL = rtrim($strSrvUrl, "/") . $url['path'];
    151174  }
    152175
     
    260283
    261284      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_IDEAL:
    262         return "Logo_iDeal_{$p_iSize}_px.png";
     285        return "Logo_iDeal_{$p_iSize}_px.jpg";
     286      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_PAYPAL:
     287        return "Logo_paypal_{$p_iSize}_px.png";
    263288      case GiroCheckout_SDK_Config::FTG_SERVICES_PAYMENT_METHOD_PAYDIREKT:
    264289        return "Logo_paydirekt_{$p_iSize}_px.jpg";
     
    274299  }
    275300
     301  public function getPayMethod() {
     302    return $this->m_iPayMethod;
     303  }
    276304}
  • girocheckout/trunk/library/api/creditcard/GiroCheckout_SDK_CreditCardTransaction.php

    r2346265 r2457199  
    1616     */
    1717    protected $paramFields = array(
    18         'merchantId' => TRUE,
    19         'projectId' => TRUE,
    20         'merchantTxId' => TRUE,
    21         'amount' => TRUE,
    22         'currency' => TRUE,
    23         'purpose' => TRUE,
    24         'type' => FALSE,
    25         'locale' => FALSE,
    26         'mobile' => FALSE,
    27         'pkn' => FALSE,
    28         'recurring' => FALSE,
    29         'indicator' => FALSE,
    30         'urlRedirect' => TRUE,
    31         'urlNotify' => TRUE,
    32         'pptoken' => FALSE,
     18        'merchantId'      => TRUE,
     19        'projectId'       => TRUE,
     20        'merchantTxId'    => TRUE,
     21        'amount'          => TRUE,
     22        'currency'        => TRUE,
     23        'purpose'         => TRUE,
     24        'type'            => FALSE,
     25        'locale'          => FALSE,
     26        'mobile'          => FALSE,
     27        'pkn'             => FALSE,
     28        'recurring'       => FALSE,
     29        'indicator'       => FALSE,
     30        'urlRedirect'     => TRUE,
     31        'urlNotify'       => TRUE,
     32        'tds2Address'     => FALSE,
     33        'tds2Postcode'    => FALSE,
     34        'tds2City'        => FALSE,
     35        'tds2Country'     => FALSE,
     36        'tds2Optional'    => FALSE,
     37        'pptoken'         => FALSE,
    3338    );
    3439
  • girocheckout/trunk/library/api/directdebit/GiroCheckout_SDK_DirectDebitTransaction.php

    r2346265 r2457199  
    44 *
    55 * @package GiroCheckout
    6  * @version $Revision: 274 $ / $Date: 2019-09-06 14:04:44 -0400 (Fri, 06 Sep 2019) $
     6 * @version $Revision: 303 $ / $Date: 2020-04-02 14:13:33 -0300 (Thu, 02 Apr 2020) $
    77 */
    88
     
    3333    'mandateSequence' => FALSE,
    3434    'pkn' => FALSE,
     35    'urlRedirect' => FALSE,
    3536    'urlNotify' => FALSE,
    3637    'pptoken' => FALSE,
     
    4748    'backendTxId' => FALSE,
    4849    'mandateReference' => FALSE,
    49     'resultPayment' => FALSE
     50    'resultPayment' => FALSE,
     51    'ppredirect' => FALSE
    5052  );
    5153
  • girocheckout/trunk/library/api/giropay/GiroCheckout_SDK_GiropayIDCheck.php

    r2346265 r2457199  
    44 *
    55 * @package GiroCheckout
    6  * @version $Revision: 274 $ / $Date: 2019-09-06 14:04:44 -0400 (Fri, 06 Sep 2019) $
     6 * @version $Revision: 315 $ / $Date: 2020-11-10 01:20:46 -0300 (Tue, 10 Nov 2020) $
    77 */
    88
     
    2020        'projectId' => TRUE,
    2121        'merchantTxId' => TRUE,
    22         'bic' => TRUE,
     22        'bic' => FALSE,
    2323        'iban' => FALSE,
    2424        'info1Label' => FALSE,
  • girocheckout/trunk/library/api/paypage/GiroCheckout_SDK_PaypageTransaction.php

    r2346265 r2457199  
    2020        'projectId' => TRUE,
    2121        'merchantTxId' => TRUE,
    22         'amount' => TRUE,
     22        'amount' => FALSE,
    2323        'currency' => TRUE,
    2424        'purpose' => TRUE,
     
    2727        'expirydate' => FALSE,
    2828        'single' => FALSE,
     29        'timeout' => FALSE,
    2930        'type' => FALSE,
    3031        'locale' => 'de',
     
    4142        'test' => TRUE,
    4243        'certdata' => FALSE,
     44        'otherpayments' => FALSE,
    4345        'paydirektShippingFirstName' => FALSE,
    4446        'paydirektShippingLastName' => FALSE,
     
    5052        'failUrl' => FALSE,
    5153        'notifyUrl' => FALSE,
     54        'tds2Address'     => FALSE,
     55        'tds2Postcode'    => FALSE,
     56        'tds2City'        => FALSE,
     57        'tds2Country'     => FALSE,
     58        'tds2Optional'    => FALSE,
    5259    );
    5360
  • girocheckout/trunk/library/helper/GiroCheckout_SDK_ResponseCode_helper.php

    r2346265 r2457199  
    55 *
    66 * @package GiroCheckout
    7  * @version $Revision: 265 $ / $Date: 2019-06-13 15:31:39 -0400 (Thu, 13 Jun 2019) $
     7 * @version $Revision: 321 $ / $Date: 2020-12-11 14:09:33 -0300 (Fri, 11 Dec 2020) $
    88 */
    99class GiroCheckout_SDK_ResponseCode_helper {
     
    117117      5101 => 'Verbindungsproblem zum Zahlungsabwickler',
    118118      5102 => 'Pseudo-Kartennummer nicht vorhanden',
     119      5103 => 'Ungültige giropay-MerchantId',
     120      5104 => 'Ungültiger Paypage-Timeout',
     121      5105 => 'TDS20: Ungültige Adresse',
     122      5106 => 'TDS20: Ungültige PLZ',
     123      5107 => 'TDS20: Ungültige Stadt',
     124      5108 => 'TDS20: Ungültiges Land',
     125      5109 => 'TDS20: Ungültige E-Mail',
     126      5110 => 'TDS20: Optional-Feld ungültig',
     127      5111 => 'TDS20: Geben Sie bitte mindestens alle Felder außer Optional an',
     128      5112 => 'TDS20: Sie müssen zu Optional auch die anderen Felder angeben',
    119129      5200 => 'Transaktion nicht akzeptiert',
    120130      5201 => 'giropay Bank offline',
     
    188198      5024 => 'invalid bankcode',
    189199      5025 => 'invalid bankaccount',
    190       5026 => 'invalid bic',
    191       5027 => 'invalid iban',
     200      5026 => 'invalid BIC',
     201      5027 => 'invalid IBAN',
    192202      5028 => 'invalid mobile',
    193203      5029 => 'invalid pkn',
     
    243253      5101 => 'connection problem to payment processor',
    244254      5102 => 'pseudo-cardnumber does not exist',
     255      5103 => 'invalid giropay merchantId',
     256      5104 => 'invalid paypage timeout',
     257      5105 => 'TDS20: Invalid address',
     258      5106 => 'TDS20: Invalid post code',
     259      5107 => 'TDS20: Invalid city',
     260      5108 => 'TDS20: Invalid country',
     261      5109 => 'TDS20: Invalid email',
     262      5110 => 'TDS20: Invalid optional field',
     263      5111 => 'TDS20: Please provide at least all fields except Optional',
     264      5112 => 'TDS20: You must provide the other fields along with Optional',
    245265      5200 => 'not accepted transaction',
    246266      5201 => 'giropay bank offline',
  • girocheckout/trunk/library/helper/GiroCheckout_SDK_TransactionType_helper.php

    r2346265 r2457199  
    44 *
    55 * @package GiroCheckout
    6  * @version $Revision: 274 $ / $Date: 2019-09-06 14:04:44 -0400 (Fri, 06 Sep 2019) $
     6 * @version $Revision: 281 $ / $Date: 2019-10-18 12:19:18 +0200 (Fri, 18 Oct 2019) $
    77 */
    88class GiroCheckout_SDK_TransactionType_helper {
     
    1414  const TRANS_TYPE_CREDITCARD_RECURRING    = "creditCardRecurringTransaction";
    1515  const TRANS_TYPE_CREDITCARD_VOID         = "creditCardVoid";
     16  const TRANS_TYPE_CREDITCARD_INITFORM     = "creditCardInitform";
     17  const TRANS_TYPE_CREDITCARD_FINALIZEFORM = "creditCardFinalizeform";
    1618
    1719  const TRANS_TYPE_DIRECTDEBIT_TRANSACTION = "directDebitTransaction";
     
    8284      case self::TRANS_TYPE_CREDITCARD_VOID:
    8385        return new GiroCheckout_SDK_CreditCardVoid();
     86      case self::TRANS_TYPE_CREDITCARD_INITFORM:
     87        return new GiroCheckout_SDK_CreditCardInitform();
     88      case self::TRANS_TYPE_CREDITCARD_FINALIZEFORM:
     89        return new GiroCheckout_SDK_CreditCardFinalizeform();
    8490
    8591      //direct debit apis
  • girocheckout/trunk/payments/gc_creditcard.php

    r2435416 r2457199  
    326326      }
    327327
     328      // Adding fields for 3-D Secure 2.0
     329      $aTdsOptionalInfo = new stdClass();
     330      $tds2Address = "";
     331      $tds2Postcode = "";
     332      $tds2City = "";
     333      $tds2Country = "";
     334      $shipAddressAddress = "";
     335      $shipAddressPostcode = "";
     336      $shipAddressCity = "";
     337      $shipAddressCountry = "";
     338
     339      if (method_exists($order, 'get_billing_address_1')) {
     340        $tds2Address = $order->get_billing_address_1();
     341      } else {
     342        $tds2Address = $order->billing_address_1;
     343      }
     344
     345      if (method_exists($order, 'get_billing_postcode')) {
     346        $tds2Postcode = $order->get_billing_postcode();
     347      } else {
     348        $tds2Postcode = $order->billing_postcode;
     349      }
     350
     351      if (method_exists($order, 'get_billing_city')) {
     352        $tds2City = $order->get_billing_city();
     353      } else {
     354        $tds2City = $order->billing_city;
     355      }
     356
     357      if (method_exists($order, 'get_billing_country')) {
     358        $tds2Country = $order->get_billing_country();
     359      } else {
     360        $tds2Country = $order->billing_country;
     361      }
     362
     363      if (method_exists($order, 'get_billing_email')) {
     364        $strEmail = $order->get_billing_email();
     365      } else {
     366        $strEmail = $order->billing_email;
     367      }
     368
     369      if (method_exists($order, 'get_shipping_address_1')) {
     370        $shipAddressAddress = $order->get_shipping_address_1();
     371      } else {
     372        $shipAddressAddress = $order->shipping_address_1;
     373      }
     374
     375      if (method_exists($order, 'get_shipping_postcode')) {
     376        $shipAddressPostcode = $order->get_shipping_postcode();
     377      } else {
     378        $shipAddressPostcode = $order->shipping_postcode;
     379      }
     380
     381      if (method_exists($order, 'get_shipping_city')) {
     382        $shipAddressCity = $order->get_shipping_city();
     383      } else {
     384        $shipAddressCity = $order->shipping_city;
     385      }
     386
     387      if (method_exists($order, 'get_shipping_country')) {
     388        $shipAddressCountry = $order->get_shipping_country();
     389      } else {
     390        $shipAddressCountry = $order->shipping_country;
     391      }
     392
     393      $aTdsOptionalInfo->email = $strEmail; // Optional email address
     394
     395      if ($tds2Address != $shipAddressAddress || $tds2City != $shipAddressCity ||
     396          $tds2Postcode != $shipAddressPostcode || $tds2Country != $shipAddressCountry) {
     397        $aTdsOptionalInfo->shippingAddress = new stdClass();
     398        $aTdsOptionalInfo->shippingAddress->country = $shipAddressCountry;
     399        $aTdsOptionalInfo->shippingAddress->line1 = $shipAddressAddress;
     400        $aTdsOptionalInfo->shippingAddress->city = $shipAddressCity;
     401        $aTdsOptionalInfo->shippingAddress->postcode = $shipAddressPostcode;
     402      }
     403
     404      // Shipping address matches billing address, array( "true", "false" );
     405      if ($tds2Address == $shipAddressAddress && $tds2City == $shipAddressCity &&
     406          $tds2Postcode == $shipAddressPostcode && $tds2Country == $shipAddressCountry) {
     407        $aTdsOptionalInfo->addressesMatch = "true";
     408      } else {
     409        $aTdsOptionalInfo->addressesMatch = "false";
     410      }
     411
    328412      $request = new GiroCheckout_SDK_Request('creditCardTransaction');
    329413      $request->setSecret($password);
    330414      $request->addParam('merchantId', $merchantId)
    331         ->addParam('projectId', $projectId)
    332         ->addParam('merchantTxId', $transaction_id)
    333         ->addParam('amount', round($amount * 100))
    334         ->addParam('currency', $currency)
    335         ->addParam('purpose', GiroCheckout_Utility::getPurpose($this->purpose, $order))
    336         ->addParam('locale', $this->lang)
    337         ->addParam('urlRedirect', $urlRedirect)
    338         ->addParam('urlNotify', $urlNotify)
    339         ->addParam('sourceId', GiroCheckout_Utility::getGcSource())
    340         ->addParam('orderId', $transaction_id)
    341         ->addParam('customerId', get_current_user_id())
    342         ->addParam('type', $strTransType)
    343         ->submit();
     415              ->addParam('projectId', $projectId)
     416              ->addParam('merchantTxId', $transaction_id)
     417              ->addParam('amount', round($amount * 100))
     418              ->addParam('currency', $currency)
     419              ->addParam('purpose', GiroCheckout_Utility::getPurpose($this->purpose, $order))
     420              ->addParam('locale', $this->lang)
     421              ->addParam('urlRedirect', $urlRedirect)
     422              ->addParam('urlNotify', $urlNotify)
     423              ->addParam('sourceId', GiroCheckout_Utility::getGcSource())
     424              ->addParam('orderId', $transaction_id)
     425              ->addParam('customerId', get_current_user_id())
     426              ->addParam('type', $strTransType);
     427
     428      if (!empty($tds2Address) && !empty($tds2Postcode) && !empty($tds2City) && !empty($tds2Country)) {
     429        $request->addParam('tds2Address', $tds2Address)
     430                ->addParam('tds2Postcode',$tds2Postcode)
     431                ->addParam('tds2City',$tds2City)
     432                ->addParam('tds2Country',$tds2Country);
     433      }
     434
     435      $request->addParam('tds2Optional',json_encode($aTdsOptionalInfo));
     436      $request->submit();
    344437
    345438      if ($request->requestHasSucceeded()) {
  • girocheckout/trunk/readme.txt

    r2435416 r2457199  
    5454
    5555== Changelog ==
     56
     57= 4.1.2 =
     58* Added support for the mandatory 3-D Secure 2.0 address fields.
    5659
    5760= 4.1.1 =
Note: See TracChangeset for help on using the changeset viewer.