function __construct($sLangue = "FR") { // contr�le de l'existence des constantes de param�trages. $aRequiredConstants = array('CMCIC_CLE', 'CMCIC_VERSION', 'CMCIC_TPE', 'CMCIC_CODESOCIETE'); $this->_checkTpeParams($aRequiredConstants); $this->sVersion = CMCIC_VERSION; $this->_sCle = CMCIC_CLE; $this->sNumero = CMCIC_TPE; $this->sUrlPaiement = CMCIC_SERVEUR . CMCIC_URLPAIEMENT; $this->sCodeSociete = CMCIC_CODESOCIETE; $this->sLangue = $sLangue; $this->sUrlOK = wpshop_payment::get_success_payment_url(); $this->sUrlKO = wpshop_payment::get_cancel_payment_url(); }
/** * Display the paypal form in order to redirect correctly to paypal */ public static function display_form($oid) { global $wpdb; $order = get_post_meta($oid, '_order_postmeta', true); // If the order exist if (!empty($order)) { $paypalBusinessEmail = get_option('wpshop_paypalEmail', null); // Si l'email Paypal n'est pas vide if (!empty($paypalBusinessEmail)) { $paypalMode = get_option('wpshop_paypalMode', null); if ($paypalMode == 'sandbox') { $paypal = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; } else { $paypal = 'https://www.paypal.com/cgi-bin/webscr'; } $current_currency = get_option('wpshop_shop_default_currency'); $query = $wpdb->prepare('SELECT code_iso FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency); $currency = $wpdb->get_var($query); $output = '<script type="text/javascript">jQuery(document).ready(function(){ jQuery("#paypalForm").submit(); });</script>'; $output .= '<div class="paypalPaymentLoading"><span>' . __('Redirecting to paypal. Please wait', 'wpshop') . '</span></div>'; $output .= ' <form action="' . $paypal . '" id="paypalForm" method="post"> <input id="cmd" name="cmd" type="hidden" value="_cart" /> <input id="upload" name="upload" type="hidden" value="1" /> <input id="charset" name="charset" type="hidden" value="utf-8" /> <input id="no_shipping" name="no_shipping" type="hidden" value="1" /> <input id="no_note" name="no_note" type="hidden" value="0" /> <input id="rm" name="rm" type="hidden" value="0" /> <input id="custom" name="custom" type="hidden" value="' . $order['customer_id'] . '" /> <input id="invoice" name="invoice" type="hidden" value="' . $oid . '" /> <!-- Invoice number --> <input id="business" name="business" type="hidden" value="' . $paypalBusinessEmail . '" /> <!-- Paypal business account --> <input id="cbt" name="cbt" type="hidden" value="' . __('Back to shop', 'wpshop') . '" /> <input id="lc" name="lc" type="hidden" value="FR" /> <input id="currency_code" name="currency_code" type="hidden" value="' . $currency . '" /> <input id="return" name="return" type="hidden" value="' . wpshop_payment::get_success_payment_url() . '" /> <input id="cancel_return" name="cancel_return" type="hidden" value="' . wpshop_payment::get_cancel_payment_url() . '" /> <input id="notify_url" name="notify_url" type="hidden" value="' . wpshop_payment::construct_url_parameters(trailingslashit(home_url()), 'paymentListener', 'paypal') . '" /> '; $i = 1; if (!empty($order['order_partial_payment']) && !empty($order['order_partial_payment']['amount_of_partial_payment'])) { $output .= ' <input id="item_number_' . $i . '" name="item_number_' . $i . '" type="hidden" value="' . $oid . '_partial_payment" /> <input id="item_name_' . $i . '" name="item_name_' . $i . '" type="hidden" value="' . __('Partial payment', 'wpshop') . ' (' . __('Order number', 'wpshop') . ' : ' . $order['order_key'] . ')" /> <input id="quantity_' . $i . '" name="quantity_' . $i . '" type="hidden" value="1" /> <input id="amount_' . $i . '" name="amount_' . $i . '" type="hidden" value="' . number_format($order['order_amount_to_pay_now'], 2, '.', '') . '" /> '; } else { $output .= ' <input id="item_number_' . $i . '" name="item_number_' . $i . '" type="hidden" value="' . $order['order_key'] . '" /> <input id="item_name_' . $i . '" name="item_name_' . $i . '" type="hidden" value="' . __('Current order', 'wpshop') . ' : ' . $order['order_key'] . '" /> <input id="quantity_' . $i . '" name="quantity_' . $i . '" type="hidden" value="1" /> <input id="amount_' . $i . '" name="amount_' . $i . '" type="hidden" value="' . number_format($order['order_amount_to_pay_now'], 2, '.', '') . '" /> '; } $output .= '<noscript><input type="submit" value="' . __('Checkout', 'wpshop') . '" /></noscript></form>'; } } echo $output; }