コード例 #1
0
 public function processTransaction(Engine_Payment_Transaction $transaction)
 {
     $data = array();
     $rawData = $transaction->getRawData();
     // HACK
     if (!empty($rawData['return_url'])) {
         $this->_gatewayUrl = $rawData['return_url'];
     }
     $data = $rawData;
     return $data;
 }
コード例 #2
0
 public function processTransaction(Engine_Payment_Transaction $transaction)
 {
     $data = array();
     $rawData = $transaction->getRawData();
     // Driver-specific params
     if (isset($rawData['driverSpecificParams'])) {
         if (isset($rawData['driverSpecificParams'][$this->getDriver()])) {
             $data = array_merge($data, $rawData['driverSpecificParams'][$this->getDriver()]);
         }
         unset($rawData['driverSpecificParams']);
     }
     // Add default region?
     if (empty($rawData['region']) && ($region = $this->getRegion())) {
         $rawData['region'] = $region;
     }
     // Add default currency
     if (empty($rawData['currency']) && ($currency = $this->getCurrency())) {
         $rawData['currency'] = $currency;
     }
     // Process abtract translation map
     $tmp = array();
     $data = array_merge($data, $this->_translateTransactionData($rawData, $tmp));
     $rawData = $tmp;
     // Call setExpressCheckout
     $token = $this->getService()->setExpressCheckout($data);
     $data = array();
     $data['cmd'] = '_express-checkout';
     $data['token'] = $token;
     return $data;
 }
コード例 #3
0
 public function processTransaction(Engine_Payment_Transaction $transaction)
 {
     $data = array();
     $rawData = $transaction->getRawData();
     // Driver-specific params
     if (isset($rawData['driverSpecificParams'])) {
         if (isset($rawData['driverSpecificParams'][$this->getDriver()])) {
             $data = array_merge($data, $rawData['driverSpecificParams'][$this->getDriver()]);
         }
         unset($rawData['driverSpecificParams']);
     }
     // Process data ------------------------------------------------------------
     // Add vendor identity
     // Note: we can get this from the product info
     $data['sid'] = $this->getVendorIdentity();
     // Add product_id
     if (isset($rawData['vendor_product_id'])) {
         $productInfo = $this->detailVendorProduct($rawData['vendor_product_id']);
         $data['product_id'] = $productInfo['assigned_product_id'];
         //$data['sid'] = $productInfo['vendor_id'];
     } else {
         if (isset($rawData['product_id'])) {
             $productInfo = $this->detailProduct($rawData['product_id']);
             $data['product_id'] = $productInfo['assigned_product_id'];
             //$data['sid'] = $productInfo['vendor_id'];
         }
     }
     // Add quantity
     if (!isset($rawData['quantity']) || !is_numeric($rawData['quantity']) || $rawData['quantity'] <= 0) {
         $data['quantity'] = 1;
     } else {
         if (isset($data['quantity']) && $data['quantity'] > 99) {
             throw new Engine_Payment_Gateway_Exception('Quantity must be less than or equal to 99.');
         }
         $data['quantity'] = $rawData['quantity'];
     }
     // Add test mode
     if ($this->getTestMode()) {
         $data['demo'] = 'Y';
     }
     // Add fixed
     if (!empty($rawData['fixed'])) {
         $data['fixed'] = 'Y';
     }
     // Add language
     if (isset($rawData['language']) && ($language = $this->isSupportedLanguage($rawData['language'])) || ($language = $this->getLanguage())) {
         $data['language'] = $language;
     }
     // Add currency - oh nevermind they don't support it
     //    if( !empty($rawData['currency']) &&
     //        ($currency = $this->isSupportedCurrency($rawData['currency'])) ||
     //        ($currency = $this->getCurrency()) ) {
     //
     //    }
     // Add return_url
     if (isset($rawData['return_url'])) {
         $data['x_receipt_link_url'] = $rawData['return_url'];
         //$data['return_url'] = $rawData['return_url'];
     }
     // Add merchant_order_id
     if (isset($rawData['merchant_order_id'])) {
         if (strlen($rawData['merchant_order_id']) > 50) {
             throw new Engine_Payment_Gateway_Exception('Merchant Order ID cannot be longer than 50 character.');
         }
         $data['merchant_order_id'] = $rawData['merchant_order_id'];
     } else {
         if (isset($rawData['vendor_order_id'])) {
             if (strlen($rawData['vendor_order_id']) > 50) {
                 throw new Engine_Payment_Gateway_Exception('Merchant Order ID cannot be longer than 50 character.');
             }
             $data['merchant_order_id'] = $rawData['vendor_order_id'];
         }
     }
     // Add pay_method
     if (isset($rawData['pay_method'])) {
         if (in_array($rawData['pay_method'], array('CC', 'AL', 'PPI'))) {
             $data['pay_method'] = $rawData['pay_method'];
         }
     }
     // Add skip_landing
     if (!empty($rawData['skip_landing'])) {
         $data['skip_landing'] = 1;
     }
     // @todo add x_receipt_link_url ?
     // @todo process the rest of $rawData
     // Validate data -----------------------------------------------------------
     if (empty($data['product_id'])) {
         $this->_throw(sprintf('Missing parameter: %1$s', 'product_id'));
         $this->_throw('No product identity provided');
         return false;
     }
     if (empty($data['sid'])) {
         $this->_throw(sprintf('Missing parameter: %1$s', 'sid'));
         return false;
     }
     if (empty($data['quantity'])) {
         $this->_throw(sprintf('Missing parameter: %1$s', 'quantity'));
         return false;
     }
     return $data;
 }
コード例 #4
0
 public function processTransaction(Engine_Payment_Transaction $transaction)
 {
     $data = array();
     $rawData = $transaction->getRawData();
     // Add vendor id
     $data['x_Login'] = $this->getVendorIdentity();
     // Add version
     $data['x_Version'] = $this->getGatewayVersion();
     // Add test mode
     if ($this->getTestMode()) {
         $data['x_Test_Request'] = 'TRUE';
     }
     // Add timestamp
     $data['x_fp_timestamp'] = time();
     // No idea what this is
     $data['x_Show_Form'] = 'PAYMENT_FORM';
     // No idea what this is either
     $data['x_Relay_Response'] = 'TRUE';
     // @todo the other stuff
     // @todo esp x_Invoice_num + x_Amount
     $data['x_fp_sequence'] = $data['x_Invoice_num'];
     // Make hash
     $data['x_fp_hash'] = self::hmac($this->getVendorSecret(), $data['x_Login'] . '^' . $data['x_Invoice_num'] . '^' . $data['x_fp_timestamp'] . '^' . $data['x_Amount'] . '^');
     return $data;
 }