public function Handle_GetPaymentMethod($order)
 {
     $method = array();
     $method['Title'] = 'PayPal';
     $method['Description'] = 'Pay with your PayPal account';
     $method['ThumbnailUrl'] = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/icon.png';
     // config the handling module in the mobile engine
     $method['Module'] = 'WebPaymentActivity';
     $params = array();
     // new paypal module (3.4.5)
     if (defined('WPS') && defined('HSS') && defined('ECS')) {
         $paypal_method = (int) Configuration::get('PAYPAL_PAYMENT_METHOD');
         if ($paypal_method == WPS || $paypal_method == ECS) {
             $cancel_url = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/express_checkout/cancel.php';
             $params['Url'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/express_checkout/payment.php?express_checkout=payment_cart&current_shop_url=' . urlencode($cancel_url) . '&';
             $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl();
             $params['CancelTrigger'] = $cancel_url;
         }
     }
     // old paypal module (2.8.6)
     if (defined('_PAYPAL_INTEGRAL_EVOLUTION_') && defined('_PAYPAL_INTEGRAL_EVOLUTION_') && defined('_PAYPAL_INTEGRAL_EVOLUTION_')) {
         if (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_EVOLUTION_) {
             // integral_evolution/paypal.tpl
             $params['Url'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/integral_evolution/redirect.php';
             $params['CompleteTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__ . 'order-confirmation.php';
             $params['CancelTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__;
         } elseif (Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_INTEGRAL_ or Configuration::get('PAYPAL_PAYMENT_METHOD') == _PAYPAL_OPTION_PLUS_) {
             if ($this->_isPayPalAPIAvailable()) {
                 // payment/payment.tpl
                 $params['Url'] = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/payment/submit.php';
                 $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'order-confirmation.php';
                 $params['CancelTrigger'] = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order';
                 // either order.php or order-opc.php
                 $params['RedirectTrigger'] = array('Trigger' => CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/payment/submit.php', 'Redirect' => CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/payment/error.php');
             } else {
                 // standard/paypal.tpl
                 $params['Url'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'modules/paypal/standard/redirect.php';
                 $params['CompleteTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__ . 'order-confirmation.php';
                 $params['CancelTrigger'] = PayPal::getShopDomain(true, true) . __PS_BASE_URI__;
             }
         }
     }
     // very old paypal (2.0 and below)
     if (empty($params)) {
         $params['Url'] = CartAPI_Handlers_Helpers::getCartApiHomeUrl() . 'modules/paypal/old/hookpayment.php';
         $params['CompleteTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl() . 'order-confirmation.php';
         $params['CancelTrigger'] = CartAPI_Handlers_Helpers::getShopBaseUrl();
     }
     $method['ModuleParameters'] = $params;
     return $method;
 }
Beispiel #2
0
$paypal = new Paypal();
$cart = new Cart((int) $cookie->id_cart);
$address = new Address((int) $cart->id_address_delivery);
$country = new Country((int) $address->id_country);
$state = NULL;
if ($address->id_state) {
    $state = new State((int) $address->id_state);
}
$customer = new Customer((int) $cart->id_customer);
$business = Configuration::get('PAYPAL_BUSINESS');
$header = Configuration::get('PAYPAL_HEADER');
$currency_order = new Currency((int) $cart->id_currency);
$currency_module = $paypal->getCurrency((int) $cart->id_currency);
if (empty($business) or !Validate::isEmail($business)) {
    die($paypal->getL('Paypal error: (invalid or undefined business account email)'));
}
if (!Validate::isLoadedObject($address) or !Validate::isLoadedObject($customer) or !Validate::isLoadedObject($currency_module)) {
    die($paypal->getL('Paypal error: (invalid address or customer)'));
}
// check currency of payment
if ($currency_order->id != $currency_module->id) {
    $cookie->id_currency = $currency_module->id;
    $cart->id_currency = $currency_module->id;
    $cart->update();
}
$smarty->assign(array('redirect_text' => $paypal->getL('Please wait, redirecting to Paypal... Thanks.'), 'cancel_text' => $paypal->getL('Cancel'), 'cart_text' => $paypal->getL('My cart'), 'return_text' => $paypal->getL('Return to shop'), 'paypal_url' => $paypal->getPaypalStandardUrl(), 'address' => $address, 'country' => $country, 'state' => $state, 'amount' => (double) $cart->getOrderTotal(true, PayPal::BOTH_WITHOUT_SHIPPING), 'customer' => $customer, 'total' => (double) $cart->getOrderTotal(true, PayPal::BOTH), 'shipping' => Tools::ps_round((double) $cart->getOrderShippingCost() + (double) $cart->getOrderTotal(true, PayPal::ONLY_WRAPPING), 2), 'discount' => $cart->getOrderTotal(true, PayPal::ONLY_DISCOUNTS), 'business' => $business, 'currency_module' => $currency_module, 'cart_id' => (int) $cart->id . '_' . pSQL($cart->secure_key), 'products' => $cart->getProducts(), 'paypal_id' => (int) $paypal->id, 'header' => $header, 'url' => PayPal::getShopDomain(true, true) . __PS_BASE_URI__));
if (is_file(_PS_THEME_DIR_ . 'modules/paypal/standard/redirect.tpl')) {
    $smarty->display(_PS_THEME_DIR_ . 'modules/' . $paypal->name . '/standard/redirect.tpl');
} else {
    $smarty->display(_PS_MODULE_DIR_ . $paypal->name . '/standard/redirect.tpl');
}
Beispiel #3
0
        $shippingState = new State((int) $shippingAddress->id_state);
    }
}
$customer = new Customer((int) $cart->id_customer);
$business = Configuration::get('PAYPAL_BUSINESS');
$header = Configuration::get('PAYPAL_HEADER');
$currency_order = new Currency((int) $cart->id_currency);
$currency_module = $paypal->getCurrency((int) $cart->id_currency);
if (empty($business) or !Validate::isEmail($business)) {
    die($paypal->getL('Paypal error: (invalid or undefined business account email)'));
}
if (!Validate::isLoadedObject($billingAddress) or !Validate::isLoadedObject($shippingAddress) or !Validate::isLoadedObject($customer) or !Validate::isLoadedObject($currency_module)) {
    die($paypal->getL('Paypal error: (invalid address or customer)'));
}
// check currency of payment
if ($currency_order->id != $currency_module->id) {
    $cookie->id_currency = $currency_module->id;
    $cart->id_currency = $currency_module->id;
    $cart->update();
}
$smarty->assign(array('redirect_text' => $paypal->getL('Please wait, redirecting to Paypal... Thanks.'), 'cancel_text' => $paypal->getL('Cancel'), 'cart_text' => $paypal->getL('My cart'), 'return_text' => $paypal->getL('Return to shop'), 'paypal_url' => $paypal->getPaypalIntegralEvolutionUrl(), 'billing_address' => $billingAddress, 'billing_country' => $billingCountry, 'billing_state' => $billingState, 'shipping_address' => $shippingAddress, 'shipping_country' => $shippingCountry, 'shipping_state' => $shippingState, 'amount' => (double) $cart->getOrderTotal(true, PayPal::BOTH_WITHOUT_SHIPPING), 'customer' => $customer, 'total' => (double) $cart->getOrderTotal(true, PayPal::BOTH), 'shipping' => Tools::ps_round((double) $cart->getOrderShippingCost() + (double) $cart->getOrderTotal(true, PayPal::ONLY_WRAPPING), 2), 'discount' => $cart->getOrderTotal(true, PayPal::ONLY_DISCOUNTS), 'business' => $business, 'currency_module' => $currency_module, 'cart_id' => (int) $cart->id . '_' . pSQL($cart->secure_key), 'products' => $cart->getProducts(), 'paypal_id' => (int) $paypal->id, 'header' => $header, 'template' => 'Template' . Configuration::get('PAYPAL_TEMPLATE'), 'url' => PayPal::getShopDomain(true, true) . __PS_BASE_URI__, 'paymentaction' => Configuration::get('PAYPAL_CAPTURE') ? 'authorization' : 'sale'));
if (substr(_PS_VERSION_, 0, 3) == '1.3') {
    $smarty->assign('jquery', 'jquery-1.2.6.pack.js');
} else {
    $smarty->assign('jquery', 'jquery-1.4.4.min.js');
}
if (is_file(_PS_THEME_DIR_ . 'modules/paypal/integral_evolution/redirect.tpl')) {
    $smarty->display(_PS_THEME_DIR_ . 'modules/' . $paypal->name . '/integral_evolution/redirect.tpl');
} else {
    $smarty->display(_PS_MODULE_DIR_ . $paypal->name . '/integral_evolution/redirect.tpl');
}