コード例 #1
0
 /**
  * Reimplementation of vmPaymentPlugin::plgVmOnConfirmedOrder()
  *
  * @link http://www.authorize.net/support/AIM_guide.pdf
  * Credit Cards Test Numbers
  * Visa Test Account           4007000000027
  * Amex Test Account           370000000000002
  * Master Card Test Account    6011000000000012
  * Discover Test Account       5424000000000015
  * @author Valerie Isaksen
  */
 function plgVmConfirmedOrder(VirtueMartCart $cart, $order)
 {
     if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
     }
     $this->setInConfirmOrder($cart);
     $usrBT = $order['details']['BT'];
     $usrST = isset($order['details']['ST']) ? $order['details']['ST'] : '';
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $payment_currency_id = shopFunctions::getCurrencyIDByName(self::AUTHORIZE_DEFAULT_PAYMENT_CURRENCY);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $payment_currency_id);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     // Set up data
     $formdata = array();
     $formdata = array_merge($this->_setHeader(), $formdata);
     $formdata = array_merge($this->_setResponseConfiguration(), $formdata);
     $formdata = array_merge($this->_setBillingInformation($usrBT), $formdata);
     if (!empty($usrST)) {
         $formdata = array_merge($this->_setShippingInformation($usrST), $formdata);
     }
     $formdata = array_merge($this->_setTransactionData($order['details']['BT'], $totalInPaymentCurrency['value']), $formdata);
     $formdata = array_merge($this->_setMerchantData(), $formdata);
     // prepare the array to post
     $poststring = '';
     foreach ($formdata as $key => $val) {
         $poststring .= urlencode($key) . "=" . urlencode($val) . "&";
     }
     $poststring = rtrim($poststring, "& ");
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     $dbValues['payment_method_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['return_context'] = $return_context;
     $dbValues['payment_name'] = parent::renderPluginName($this->_currentMethod);
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['payment_currency'] = $payment_currency_id;
     $this->debugLog("before store", "plgVmConfirmedOrder", 'debug');
     $this->storePSPluginInternalData($dbValues);
     // send a request
     $response = $this->_sendRequest($poststring);
     $this->debugLog($response, "plgVmConfirmedOrder", 'debug');
     $authnet_values = array();
     // to check the values???
     // evaluate the response
     $html = $this->_handleResponse($response, $authnet_values, $order, $dbValues['payment_name']);
     if ($this->error) {
         $new_status = $this->_currentMethod->payment_declined_status;
         $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $html);
         return;
         // will not process the order
     } else {
         if ($this->approved) {
             $this->_clearAuthorizeNetSession();
             $new_status = $this->_currentMethod->payment_approved_status;
         } else {
             if ($this->declined) {
                 vRequest::setVar('html', $html);
                 $new_status = $this->_currentMethod->payment_declined_status;
                 $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $html);
                 return;
             } else {
                 if ($this->held) {
                     $this->_clearAuthorizeNetSession();
                     $new_status = $this->_currentMethod->payment_held_status;
                 }
             }
         }
     }
     $modelOrder = VmModel::getModel('orders');
     $order['order_status'] = $new_status;
     $order['customer_notified'] = 1;
     $order['comments'] = '';
     $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
     //We delete the old stuff
     $cart->emptyCart();
     vRequest::setVar('html', $html);
 }
コード例 #2
0
ファイル: klarna.php プロジェクト: joselapria/virtuemart
 function getKlarnaPaymentCurrency(&$method)
 {
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $this->_getCartAddressCountryCode($cart, $country, $countrId);
     $cData = KlarnaHandler::countryData($method, $country);
     return shopFunctions::getCurrencyIDByName($cData['currency_code']);
 }
コード例 #3
0
ファイル: amazon.php プロジェクト: kosmosby/medicine-prof
	/**
	 * @param $client
	 * @return int
	 */
	private function getCurrencyId ($client) {
		$currencyCode3 = $this->getCurrencyCode3($client);
		$virtuemart_currency_id = shopFunctions::getCurrencyIDByName($currencyCode3);
		return $virtuemart_currency_id;
	}
コード例 #4
0
ファイル: sofort_ideal.php プロジェクト: proyectoseb/Matrix
 /**
  * @param $cart
  * @param $order
  * @return bool','null
  */
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return FALSE;
     }
     $this->setInConfirmOrder($cart);
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $this->_debug = $method->debug;
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     vmdebug('SOFORT plgVmConfirmedOrder');
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     if (!class_exists('TableVendors')) {
         require VMPATH_ADMIN . DS . 'tables' . DS . 'vendors.php';
     }
     $currency_code_3 = self::PAYMENT_CURRENCY_CODE_3;
     //
     $currency_id = shopFunctions::getCurrencyIDByName($currency_code_3);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $currency_id);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     if ($totalInPaymentCurrency <= 0) {
         vmInfo(vmText::sprintf('VMPAYMENT_SOFORT_AMOUNT_INCORRECT', $order['details']['BT']->order_total, $totalInPaymentCurrency['value'], $currency_code_3));
         return FALSE;
     }
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, 'order');
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $currency_id;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $dbValues['sofort_custom'] = $return_context;
     $this->storePSPluginInternalData($dbValues);
     if (!class_exists('SofortLib')) {
         require VMPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'sofort' . DS . 'sofort' . DS . 'library' . DS . 'sofortLib.php';
     }
     if (!class_exists('SofortLib_iDealClassic')) {
         require VMPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'sofort' . DS . 'sofort' . DS . 'library' . DS . 'sofortLib_ideal_classic.php';
     }
     $sofort_ideal = new SofortLib_iDealClassic($method->configuration_key, $method->project_password);
     $sofort_ideal->setVersion(self::RELEASE);
     $sofort_ideal->setAmount($totalInPaymentCurrency['value'], $currency_code_3);
     $sofort_ideal->setSenderCountryId(ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'));
     $sofort_ideal->setReason($order['details']['BT']->order_number);
     $sofort_ideal->addUserVariable($order['details']['BT']->virtuemart_paymentmethod_id);
     //$sofort_ideal->setSuccessUrl(self::getSuccessUrl($order)); //user_variable_3
     //$sofort_ideal->setAbortUrl(self::getCancelUrl($order)); //user_variable_4
     //$sofort_ideal->setNotificationUrl(self::getNotificationUrl( $order['details']['BT']->order_number)); //user_variable_5
     $sofort_ideal->setSenderCountryId(ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'));
     //sender_country_id
     $sofort_ideal->setSenderBankCode(self::_getSelectedBankCode($order['details']['BT']->virtuemart_paymentmethod_id));
     $url = $sofort_ideal->getPaymentUrl();
     //$this->storePSPluginInternalData($dbValues);
     $mainframe = JFactory::getApplication();
     $mainframe->redirect($url);
 }
コード例 #5
0
 /**
  * Reimplementation of vmPaymentPlugin::plgVmOnConfirmedOrder()
  *
  * @link http://nabvelocity.com/
  * Credit Cards Test Numbers
  * Visa Test Account           4007000000027
  * Amex Test Account           370000000000002
  * Master Card Test Account    6011000000000012
  * Discover Test Account       5424000000000015
  * @author Velocity Team
  */
 function plgVmConfirmedOrder(VirtueMartCart $cart, $order)
 {
     if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
     }
     $this->setInConfirmOrder($cart);
     $usrBT = $order['details']['BT'];
     $usrST = isset($order['details']['ST']) ? $order['details']['ST'] : '';
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $payment_currency_id = shopFunctions::getCurrencyIDByName(self::VELOCITY_DEFAULT_PAYMENT_CURRENCY);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $payment_currency_id);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     if (!class_exists('ShopFunctions')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $statecode = self::get2cStateByID($usrBT->virtuemart_state_id);
     $countrycode = self::get3cCountryByID($usrBT->virtuemart_country_id) == 'USA' ? self::get3cCountryByID($usrBT->virtuemart_country_id) : 'USA';
     $avsData = array('Street' => $usrBT->address_1 . ' ' . $usrBT->address_2, 'City' => $usrBT->city, 'StateProvince' => $statecode, 'PostalCode' => $usrBT->zip, 'Country' => $countrycode);
     $cardData = array('cardtype' => str_replace(' ', '', $this->_cc_type), 'pan' => $this->_cc_number, 'expire' => sprintf("%02d", $this->_cc_expire_month) . substr($this->_cc_expire_year, -2), 'cvv' => $this->_cc_cvv, 'track1data' => '', 'track2data' => '');
     $identitytoken = $this->_vmpCtable->identitytoken;
     $workflowid = $this->_vmpCtable->workflowid;
     $applicationprofileid = $this->_vmpCtable->applicationprofileid;
     $merchantprofileid = $this->_vmpCtable->merchantprofileid;
     if ($this->_vmpCtable->payment_mode) {
         $isTestAccount = TRUE;
     } else {
         $isTestAccount = FALSE;
     }
     include_once 'sdk' . DS . 'configuration.php';
     include_once 'sdk' . DS . 'Velocity.php';
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     $dbValues['payment_method_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['return_context'] = $return_context;
     $dbValues['payment_name'] = parent::renderPluginName($this->_currentMethod);
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['payment_currency'] = $payment_currency_id;
     $this->debugLog("before store", "plgVmConfirmedOrder", 'debug');
     $this->storePSPluginInternalData($dbValues);
     $errMsg = '';
     try {
         $velocityProcessor = new VelocityProcessor($applicationprofileid, $merchantprofileid, $workflowid, $isTestAccount, $identitytoken);
     } catch (Exception $e) {
         $this->error = TRUE;
         $errMsg .= '<br>' . vmText::_($e->getMessage());
     }
     /* Request for the verify avsdata and card data*/
     try {
         $response = $velocityProcessor->verify(array('amount' => $totalInPaymentCurrency['value'], 'avsdata' => $avsData, 'carddata' => $cardData, 'entry_mode' => 'Keyed', 'IndustryType' => 'Ecommerce', 'Reference' => 'xyz', 'EmployeeId' => '11'));
     } catch (Exception $e) {
         $this->error = TRUE;
         $errMsg .= '<br>' . vmText::_($e->getMessage());
     }
     if (is_array($response) && isset($response['Status']) && $response['Status'] == 'Successful') {
         /* Request for the authrizeandcapture transaction */
         try {
             $xml = VelocityXmlCreator::authorizeandcaptureXML(array('amount' => $totalInPaymentCurrency['value'], 'avsdata' => $avsData, 'token' => $response['PaymentAccountDataToken'], 'order_id' => $order['details']['BT']->order_number, 'entry_mode' => 'Keyed', 'IndustryType' => 'Ecommerce', 'Reference' => 'xyz', 'EmployeeId' => '11'));
             // got authorizeandcapture xml object.
             $req = $xml->saveXML();
             $obj_req = serialize($req);
             $cap_response = $velocityProcessor->authorizeAndCapture(array('amount' => $totalInPaymentCurrency['value'], 'avsdata' => $avsData, 'token' => $response['PaymentAccountDataToken'], 'order_id' => $order['details']['BT']->order_number, 'entry_mode' => 'Keyed', 'IndustryType' => 'Ecommerce', 'Reference' => 'xyz', 'EmployeeId' => '11'));
             if (is_array($cap_response) && !empty($cap_response) && isset($cap_response['Status']) && $cap_response['Status'] == 'Successful') {
                 /* save the authandcap response into 'virtuemart_payment_plg_velocity' custom table.*/
                 $response_fields['transaction_id'] = $cap_response['TransactionId'];
                 $response_fields['transaction_status'] = $cap_response['TransactionState'];
                 $response_fields['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
                 $response_fields['request_obj'] = $obj_req;
                 $response_fields['response_obj'] = serialize($cap_response);
                 $this->storePSPluginInternalData($response_fields, 'virtuemart_order_id', TRUE);
                 $html = '<table class="adminlist table">' . "\n";
                 $html .= $this->getHtmlRow('VELOCITY_PAYMENT_NAME', $this->_vmpCtable->payment_name);
                 $html .= $this->getHtmlRow('VELOCITY_ORDER_NUMBER', $order['details']['BT']->order_number);
                 $html .= $this->getHtmlRow('VELOCITY_AMOUNT', $cap_response['Amount']);
                 $html .= $this->getHtmlRow('VMPAYMENT_VELOCITY_APPROVAL_CODE', $cap_response['ApprovalCode']);
                 if ($cap_response['TransactionId']) {
                     $html .= $this->getHtmlRow('VELOCITY_RESPONSE_TRANSACTION_ID', $cap_response['TransactionId']);
                 }
                 $html .= '</table>' . "\n";
                 $this->debugLog(vmText::_('VMPAYMENT_VELOCITY_ORDER_NUMBER') . " " . $order['details']['BT']->order_number . ' payment approved', '_handleResponse', 'debug');
                 $comment = 'ApprovalCode: ' . $cap_response['ApprovalCode'] . '<br>Transaction_Id: ' . $cap_response['TransactionId'];
                 $this->_clearVelocitySession();
                 $new_status = 'U';
             } else {
                 if (is_array($cap_response) && !empty($cap_response)) {
                     $this->error = TRUE;
                     $errMsg .= vmText::_($cap_response['StatusMessage']);
                 } else {
                     if (is_string($cap_response)) {
                         $this->error = TRUE;
                         $errMsg .= '<br>' . vmText::_($cap_response);
                     } else {
                         $this->error = TRUE;
                         $errMsg .= '<br>' . vmText::_('VMPAYMENT_VELOCITY_UNKNOWN_ERROR');
                     }
                 }
             }
         } catch (Exception $e) {
             $errMsg .= '<br>' . vmText::_($e->getMessage());
         }
     } else {
         if (is_array($response) && (isset($response['Status']) && $response['Status'] != 'Successful')) {
             $this->error = TRUE;
             $errMsg .= '<br>' . vmText::_($response['StatusMessage']);
         } else {
             if (is_string($response)) {
                 $this->error = TRUE;
                 $errMsg .= '<br>' . vmText::_($response);
             } else {
                 $this->error = TRUE;
                 $errMsg .= '<br>' . vmText::_('VMPAYMENT_VELOCITY_UNKNOWN_ERROR');
             }
         }
     }
     $this->debugLog($response, "plgVmConfirmedOrder", 'debug');
     $modelOrder = VmModel::getModel('orders');
     if ($this->error) {
         $this->debugLog($errMsg, 'getOrderIdByOrderNumber', 'message');
         $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $errMsg);
         return;
     }
     $order['order_status'] = $new_status;
     $order['customer_notified'] = 1;
     $order['comments'] = $comment;
     $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
     //We delete the old stuff
     $cart->emptyCart();
     vRequest::setVar('html', $html);
 }