本文整理汇总了PHP中PayPal::getShopDomainSsl方法的典型用法代码示例。如果您正苦于以下问题:PHP PayPal::getShopDomainSsl方法的具体用法?PHP PayPal::getShopDomainSsl怎么用?PHP PayPal::getShopDomainSsl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal
的用法示例。
在下文中一共展示了PayPal::getShopDomainSsl方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAuthorisation
public function getAuthorisation()
{
global $cookie;
// Getting cart informations
$cart = new Cart((int) $cookie->id_cart);
if (!Validate::isLoadedObject($cart)) {
$this->_logs[] = $this->l('Not a valid cart');
}
$currency = new Currency((int) $cart->id_currency);
if (!Validate::isLoadedObject($currency)) {
$this->_logs[] = $this->l('Not a valid currency');
}
if (sizeof($this->_logs)) {
return false;
}
// Making request
$returnURL = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/paypal/express/submit.php';
$cancelURL = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order.php';
$paymentAmount = (double) $cart->getOrderTotal();
$currencyCodeType = strval($currency->iso_code);
$paymentType = Configuration::get('PAYPAL_CAPTURE') == 1 ? 'Authorization' : 'Sale';
$request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType);
if ($this->_pp_integral) {
$request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing';
} else {
$request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login';
}
$request .= '&LOCALECODE=' . strtoupper($this->getCountryCode());
if ($this->_header) {
$request .= '&HDRIMG=' . urlencode($this->_header);
}
// Customer informations
$customer = new Customer((int) $cart->id_customer);
$request .= '&EMAIL=' . urlencode($customer->email);
//customer
// address of delivery
$address = new Address((int) $cart->id_address_delivery);
$country = new Country((int) $address->id_country);
if ($address->id_state) {
$state = new State((int) $address->id_state);
}
$request .= '&SHIPTONAME=' . urlencode($address->firstname . ' ' . $address->lastname);
$request .= '&SHIPTOSTREET=' . urlencode($address->address1);
$request .= '&SHIPTOSTREET2=' . urlencode($address->address2);
$request .= '&SHIPTOCITY=' . urlencode($address->city);
$request .= '&SHIPTOSTATE=' . ($address->id_state ? $state->iso_code : $country->iso_code);
$request .= '&SHIPTOZIP=' . urlencode($address->postcode);
$request .= '&SHIPTOCOUNTRY=' . urlencode($country->iso_code);
$request .= '&SHIPTOPHONENUM=' . urlencode($address->phone);
// Calling PayPal API
include _PS_MODULE_DIR_ . 'paypal/api/paypallib.php';
$ppAPI = new PaypalLib();
$result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request);
$this->_logs = array_merge($this->_logs, $ppAPI->getLogs());
return $result;
}
示例2: initContent
public function initContent()
{
if (!$this->context->customer->isLogged() || empty($this->context->cart)) {
Tools::redirect('index.php');
}
parent::initContent();
$this->paypal = new PayPal();
$this->context = Context::getContext();
$this->id_module = (int) Tools::getValue('id_module');
$currency = new Currency((int) $this->context->cart->id_currency);
$this->context->smarty->assign(array('form_action' => PayPal::getShopDomainSsl(true, true) . _MODULE_DIR_ . $this->paypal->name . '/express_checkout/payment.php', 'total' => Tools::displayPrice($this->context->cart->getOrderTotal(true), $currency), 'logos' => $this->paypal->paypal_logos->getLogos(), 'use_mobile' => (bool) $this->paypal->useMobile()));
$this->setTemplate('order-summary.tpl');
}
示例3: Handle_GetPaymentMethod
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¤t_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;
}
示例4: displayConfirm
function displayConfirm()
{
global $cookie, $smarty, $ppPayment, $cart;
if (!$cookie->isLogged(true)) {
header('location:../../../');
exit;
die('Not logged');
}
unset($cookie->paypal_token);
if ($cart->id_currency != $ppPayment->getCurrency((int) $cart->id_currency)->id) {
$cart->id_currency = (int) $ppPayment->getCurrency((int) $cart->id_currency)->id;
$cookie->id_currency = (int) $cart->id_currency;
$cart->update();
Tools::redirect('modules/' . $ppPayment->name . '/payment/submit.php');
}
// Display all and exit
include _PS_ROOT_DIR_ . '/header.php';
$smarty->assign(array('logo' => $ppPayment->getLogo(), 'cust_currency' => $cart->id_currency, 'currency' => $ppPayment->getCurrency((int) $cart->id_currency), 'total' => $cart->getOrderTotal(true, PayPal::BOTH), 'this_path_ssl' => PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $ppPayment->name . '/', 'mode' => 'payment/'));
echo $ppPayment->display('paypal.php', 'confirm.tpl');
include _PS_ROOT_DIR_ . '/footer.php';
die;
}
示例5: FrontController
Tools::redirectLink(__PS_BASE_URI__ . '/modules/paypal/express_checkout/submit.php?' . $query);
} else {
$controller = new FrontController();
$controller->init();
Tools::redirect(Context::getContext()->link->getModuleLink('paypal', 'submit', $values));
}
}
} else {
// If Cart changed, no need to keep the paypal data
unset(Context::getContext()->cookie->{PaypalExpressCheckout::$COOKIE_NAME});
$ppec->logs[] = $ppec->l('Cart changed since the last checkout express, please make a new Paypal checkout payment');
}
}
if (_PS_VERSION_ < '1.5') {
$display = new BWDisplay();
} else {
$display = new FrontController();
}
// Display payment confirmation
if ($ppec->ready && Tools::getValue('get_confirmation')) {
if (_PS_VERSION_ < '1.5') {
$currency = new Currency((int) $ppec->getContext()->cart->id_currency);
$ppec->getContext()->smarty->assign(array('form_action' => PayPal::getShopDomainSsl(true, true) . _MODULE_DIR_ . $ppec->name . '/express_checkout/submit.php', 'total' => Tools::displayPrice($ppec->getContext()->cart->getOrderTotal(true), $currency), 'logos' => $ppec->paypal_logos->getLogos(), 'use_mobile' => (bool) $ppec->getContext()->getMobileDevice()));
$display->setTemplate(_PS_MODULE_DIR_ . 'paypal/views/templates/front/order-summary.tpl');
}
} else {
$ppec->getContext()->smarty->assign(array('message' => $ppec->l('Error occurred:'), 'logs' => $ppec->logs, 'use_mobile' => $ppec->getContext()->getMobileDevice()));
$display->setTemplate(_PS_MODULE_DIR_ . 'paypal/views/templates/front/error.tpl');
}
$display->run();
}
示例6: displayConfirm
function displayConfirm()
{
global $cookie, $smarty, $ppExpress, $cart, $payerID;
if (!$cookie->isLogged(true)) {
die('Not logged');
}
if (!$payerID and !($payerID = Tools::htmlentitiesUTF8(strval(Tools::getValue('payerID'))))) {
die('No payer ID');
}
// Display all and exit
include _PS_ROOT_DIR_ . '/header.php';
$smarty->assign(array('back' => 'paypal', 'logo' => $ppExpress->getLogo(), 'ppToken' => strval($cookie->paypal_token), 'cust_currency' => $cart->id_currency, 'currencies' => $ppExpress->getCurrency((int) $cart->id_currency), 'total' => $cart->getOrderTotal(true, PayPal::BOTH), 'this_path_ssl' => PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $ppExpress->name . '/', 'payerID' => $payerID, 'mode' => 'express/'));
echo $ppExpress->display('paypal.php', 'confirm.tpl');
include _PS_ROOT_DIR_ . '/footer.php';
die;
}
示例7: _setPaymentDetails
private function _setPaymentDetails(&$fields)
{
// Required field
$fields['RETURNURL'] = PayPal::getShopDomainSsl(true, true) . _MODULE_DIR_ . $this->name . '/express_checkout/payment.php';
$fields['NOSHIPPING'] = '1';
$fields['BUTTONSOURCE'] = $this->getTrackingCode((int) Configuration::get('PAYPAL_PAYMENT_METHOD'));
// Products
$taxes = $total = 0;
$index = -1;
// Set cart products list
$this->setProductsList($fields, $index, $total, $taxes);
$this->setDiscountsList($fields, $index, $total, $taxes);
$this->setGiftWrapping($fields, $index, $total);
// Payment values
$this->setPaymentValues($fields, $index, $total, $taxes);
$id_address = (int) $this->context->cart->id_address_delivery;
if ($id_address == 0 && $this->context->customer) {
$id_address = Address::getFirstCustomerAddressId($this->context->customer->id);
}
if ($id_address && method_exists($this->context->cart, 'isVirtualCart') && !$this->context->cart->isVirtualCart()) {
$this->setShippingAddress($fields, $id_address);
} else {
$fields['NOSHIPPING'] = '0';
}
foreach ($fields as &$field) {
if (is_numeric($field)) {
$field = str_replace(',', '.', $field);
}
}
}
示例8: makePayPalAPIValidation
public function makePayPalAPIValidation($cookie, $cart, $id_currency, $payerID, $type)
{
global $cookie;
if (!$this->active) {
return;
}
if (!$this->_isPayPalAPIAvailable()) {
return;
}
// Filling-in vars
$id_cart = (int) $cart->id;
$currency = new Currency((int) $id_currency);
$iso_currency = $currency->iso_code;
$token = $cookie->paypal_token;
$total = (double) $cart->getOrderTotal(true, PayPal::BOTH);
$paymentType = Configuration::get('PAYPAL_CAPTURE') == 1 ? 'Authorization' : 'Sale';
$serverName = urlencode($_SERVER['SERVER_NAME']);
$bn = $type == 'express' ? 'ECS' : 'ECM';
$notifyURL = urlencode(PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/paypal/ipn.php');
// Getting address
if (isset($cookie->id_cart) and $cookie->id_cart) {
$cart = new Cart((int) $cookie->id_cart);
}
if (isset($cart->id_address_delivery) and $cart->id_address_delivery) {
$address = new Address((int) $cart->id_address_delivery);
}
$requestAddress = '';
if (Validate::isLoadedObject($address)) {
$country = new Country((int) $address->id_country);
$state = new State((int) $address->id_state);
$requestAddress = '&SHIPTONAME=' . urlencode($address->company . ' ' . $address->firstname . ' ' . $address->lastname) . '&SHIPTOSTREET=' . urlencode($address->address1 . ' ' . $address->address2) . '&SHIPTOCITY=' . urlencode($address->city) . '&SHIPTOSTATE=' . urlencode($address->id_state ? $state->iso_code : $country->iso_code) . '&SHIPTOCOUNTRYCODE=' . urlencode($country->iso_code) . '&SHIPTOZIP=' . urlencode($address->postcode);
}
// Making request
$request = '&TOKEN=' . urlencode($token) . '&PAYERID=' . urlencode($payerID) . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $total . '&CURRENCYCODE=' . $iso_currency . '&IPADDRESS=' . $serverName . '&NOTIFYURL=' . $notifyURL . '&BUTTONSOURCE=PRESTASHOP_' . $bn . $requestAddress;
$discounts = (double) $cart->getOrderTotal(true, PayPal::ONLY_DISCOUNTS);
if ($discounts == 0) {
$products = $cart->getProducts();
$amt = 0;
for ($i = 0; $i < sizeof($products); $i++) {
$request .= '&L_NAME' . $i . '=' . substr(urlencode($products[$i]['name'] . (isset($products[$i]['attributes']) ? ' - ' . $products[$i]['attributes'] : '') . (isset($products[$i]['instructions']) ? ' - ' . $products[$i]['instructions'] : '')), 0, 127);
$request .= '&L_AMT' . $i . '=' . urlencode($this->PayPalRound($products[$i]['price']));
$request .= '&L_QTY' . $i . '=' . urlencode($products[$i]['cart_quantity']);
$amt += $this->PayPalRound($products[$i]['price']) * $products[$i]['cart_quantity'];
}
$shipping = $this->PayPalRound($cart->getOrderShippingCost($cart->id_carrier, false));
$request .= '&ITEMAMT=' . urlencode($amt);
$request .= '&SHIPPINGAMT=' . urlencode($shipping);
$request .= '&TAXAMT=' . urlencode((double) max($this->PayPalRound($total - $amt - $shipping), 0));
} else {
$products = $cart->getProducts();
$description = 0;
for ($i = 0; $i < sizeof($products); $i++) {
$description .= ($description == '' ? '' : ', ') . $products[$i]['cart_quantity'] . " x " . $products[$i]['name'] . (isset($products[$i]['attributes']) ? ' - ' . $products[$i]['attributes'] : '') . (isset($products[$i]['instructions']) ? ' - ' . $products[$i]['instructions'] : '');
}
$request .= '&ORDERDESCRIPTION=' . urlencode(substr($description, 0, 120));
}
// Calling PayPal API
include_once _PS_MODULE_DIR_ . 'paypal/api/paypallib.php';
$ppAPI = new PaypalLib();
$result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'DoExpressCheckoutPayment', $request);
$this->_logs = array_merge($this->_logs, $ppAPI->getLogs());
// Checking PayPal result
if (!is_array($result) or !sizeof($result)) {
$this->displayPayPalAPIError($this->l('Authorization to PayPal failed.'), $this->_logs);
} elseif (!isset($result['ACK']) or strtoupper($result['ACK']) != 'SUCCESS') {
$this->displayPayPalAPIError($this->l('PayPal return error.'), $this->_logs);
} elseif (!isset($result['TOKEN']) or $result['TOKEN'] != $cookie->paypal_token) {
$logs[] = '<b>' . $ppExpress->l('Token given by PayPal is not the same as the cookie token', 'submit') . '</b>';
$ppExpress->displayPayPalAPIError($ppExpress->l('PayPal return error.', 'submit'), $logs);
}
// Making log
$id_transaction = $result['TRANSACTIONID'];
if (Configuration::get('PAYPAL_CAPTURE')) {
$this->_logs[] = $this->l('Authorization for deferred payment granted by PayPal.');
} else {
$this->_logs[] = $this->l('Order finished with PayPal!');
}
$message = Tools::htmlentitiesUTF8(strip_tags(implode("\n", $this->_logs)));
// Order status
switch ($result['PAYMENTSTATUS']) {
case 'Completed':
$id_order_state = Configuration::get('PS_OS_PAYMENT');
break;
case 'Pending':
if ($result['PENDINGREASON'] != 'authorization') {
$id_order_state = Configuration::get('PS_OS_PAYPAL');
} else {
$id_order_state = (int) Configuration::get('PAYPAL_OS_AUTHORIZATION');
}
break;
default:
$id_order_state = Configuration::get('PS_OS_ERROR');
}
// Call payment validation method
$this->validateOrder($id_cart, $id_order_state, (double) $cart->getOrderTotal(true, PayPal::BOTH), $this->displayName, $message, array('transaction_id' => $id_transaction, 'payment_status' => $result['PAYMENTSTATUS'], 'pending_reason' => $result['PENDINGREASON']), $id_currency, false, $cart->secure_key);
// Clean cookie
unset($cookie->paypal_token);
// Displaying output
$order = new Order((int) $this->currentOrder);
Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . (int) $id_cart . '&id_module=' . (int) $this->id . '&id_order=' . (int) $this->currentOrder . '&key=' . $order->secure_key);
//.........这里部分代码省略.........
示例9: elseif
}
} elseif ($ppec->result['ACK'] != 'Failure') {
$ppec->context->smarty->assign(array('logs' => $ppec->logs, 'message' => $ppec->l('Error occurred:')));
$template = 'error.tpl';
}
} else {
/* If Cart changed, no need to keep the paypal data */
unset($ppec->context->cookie->{PaypalExpressCheckout::$cookie_name});
$ppec->logs[] = $ppec->l('Cart changed since the last checkout express, please make a new Paypal checkout payment');
}
}
$display = _PS_VERSION_ < '1.5' ? new BWDisplay() : new FrontController();
$payment_confirmation = Tools::getValue('get_confirmation');
/* Display payment confirmation */
if ($ppec->ready && $payment_confirmation && _PS_VERSION_ < '1.5') {
$shop_domain = PayPal::getShopDomainSsl(true, true);
$form_action = $shop_domain . _MODULE_DIR_ . $ppec->name . '/express_checkout/payment.php';
$order_total = $ppec->context->cart->getOrderTotal(true);
$currency = new Currency((int) $ppec->context->cart->id_currency);
$ppec->context->smarty->assign(array('form_action' => $form_action, 'total' => Tools::displayPrice($order_total, $currency), 'logos' => $ppec->paypal_logos->getLogos()));
$template = 'order-summary.tpl';
} else {
if (!$ppec->context->cart->id) {
$ppec->context->cart->delete();
$ppec->logs[] = $ppec->l('Your cart is empty.');
}
$ppec->context->smarty->assign(array('logs' => $ppec->logs, 'message' => $ppec->l('Error occurred:')));
$template = 'error.tpl';
}
/**
* Detect if we are using mobile or not
示例10: redirectToConfirmation
public function redirectToConfirmation()
{
$shop_url = PayPal::getShopDomainSsl(true, true);
// Check if user went through the payment preparation detail and completed it
$detail = unserialize($this->context->cookie->express_checkout);
if (!empty($detail['payer_id']) && !empty($detail['token'])) {
$values = array('get_confirmation' => true);
$link = $shop_url . _MODULE_DIR_ . $this->name . '/express_checkout/payment.php';
if (version_compare(_PS_VERSION_, '1.5', '<')) {
Tools::redirectLink($link . '?' . http_build_query($values, '', '&'));
} else {
Tools::redirect(Context::getContext()->link->getModuleLink('paypal', 'confirm', $values));
}
}
}
示例11: getReturnLink
public static function getReturnLink()
{
return PayPal::getShopDomainSsl(true, true) . _MODULE_DIR_ . 'paypal/paypal_login/paypal_login_token.php';
}
示例12: getAuthorisation
public function getAuthorisation()
{
global $cookie, $cart;
// Getting cart informations
$currency = new Currency((int) $cart->id_currency);
if (!Validate::isLoadedObject($currency)) {
$this->_logs[] = $this->l('Not a valid currency');
}
if (sizeof($this->_logs)) {
return false;
}
// Making request
$vars = '?fromPayPal=1';
$returnURL = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/paypal/payment/submit.php' . $vars;
$cancelURL = PayPal::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'order.php';
$paymentAmount = (double) $cart->getOrderTotal();
$currencyCodeType = strval($currency->iso_code);
$paymentType = Configuration::get('PAYPAL_CAPTURE') == 1 ? 'Authorization' : 'Sale';
$request = '&Amt=' . urlencode($paymentAmount) . '&PAYMENTACTION=' . urlencode($paymentType) . '&ReturnUrl=' . urlencode($returnURL) . '&CANCELURL=' . urlencode($cancelURL) . '&CURRENCYCODE=' . urlencode($currencyCodeType) . '&NOSHIPPING=1';
if (Configuration::get('PAYPAL_PAYMENT_METHOD') == 0) {
$request .= '&SOLUTIONTYPE=Sole&LANDINGPAGE=Billing';
} else {
$request .= '&SOLUTIONTYPE=Mark&LANDINGPAGE=Login';
}
$request .= '&LOCALECODE=' . strtoupper(Language::getIsoById($cart->id_lang));
if (Configuration::get('PAYPAL_HEADER')) {
$request .= '&HDRIMG=' . urlencode(Configuration::get('PAYPAL_HEADER'));
}
// Customer informations
$customer = new Customer((int) $cart->id_customer);
$request .= '&EMAIL=' . urlencode($customer->email);
//customer
// address of delivery
$id_address = $cart->id_address_delivery;
$address = new Address((int) $id_address);
$country = new Country((int) $address->id_country);
if ($address->id_state) {
$state = new State((int) $address->id_state);
}
$discounts = (double) $cart->getOrderTotal(true, PayPal::ONLY_DISCOUNTS);
if ($discounts == 0) {
if ($cart->id_customer) {
$customer = new Customer((int) $cart->id_customer);
$taxCalculationMethod = Group::getPriceDisplayMethod((int) $customer->id_default_group);
} else {
$taxCalculationMethod = Group::getDefaultPriceDisplayMethod();
}
$priceField = $taxCalculationMethod == PS_TAX_EXC ? 'price' : 'price_wt';
$products = $cart->getProducts();
$amt = 0;
for ($i = 0; $i < sizeof($products); $i++) {
$request .= '&L_NAME' . $i . '=' . substr(urlencode($products[$i]['name'] . (isset($products[$i]['attributes']) ? ' - ' . $products[$i]['attributes'] : '') . (isset($products[$i]['instructions']) ? ' - ' . $products[$i]['instructions'] : '')), 0, 127);
$request .= '&L_AMT' . $i . '=' . urlencode($this->PayPalRound($products[$i][$priceField]));
$request .= '&L_QTY' . $i . '=' . urlencode($products[$i]['cart_quantity']);
$amt += $this->PayPalRound($products[$i][$priceField] * $products[$i]['cart_quantity']);
}
$shipping = $this->PayPalRound($cart->getOrderShippingCost($cart->id_carrier, false));
$request .= '&ITEMAMT=' . urlencode($amt);
$request .= '&SHIPPINGAMT=' . urlencode($shipping);
$request .= '&TAXAMT=' . urlencode((double) max($this->PayPalRound($paymentAmount - $amt - $shipping), 0));
} else {
$products = $cart->getProducts();
$description = 0;
for ($i = 0; $i < sizeof($products); $i++) {
$description .= ($description == '' ? '' : ', ') . $products[$i]['cart_quantity'] . " x " . $products[$i]['name'] . (isset($products[$i]['attributes']) ? ' - ' . $products[$i]['attributes'] : '') . (isset($products[$i]['instructions']) ? ' - ' . $products[$i]['instructions'] : '');
}
$request .= '&ORDERDESCRIPTION=' . urlencode(substr($description, 0, 120));
}
$request .= '&SHIPTONAME=' . urlencode($address->firstname . ' ' . $address->lastname);
$request .= '&SHIPTOSTREET=' . urlencode($address->address1);
$request .= '&SHIPTOSTREET2=' . urlencode($address->address2);
$request .= '&SHIPTOCITY=' . urlencode($address->city);
$request .= '&SHIPTOSTATE=' . ($address->id_state ? $state->iso_code : $country->iso_code);
$request .= '&SHIPTOZIP=' . urlencode($address->postcode);
$request .= '&SHIPTOCOUNTRY=' . urlencode($country->iso_code);
$request .= '&SHIPTOPHONENUM=' . urlencode($address->phone);
$request .= '&ADDROVERRIDE=1';
// Calling PayPal API
include _PS_MODULE_DIR_ . 'paypal/api/paypallib.php';
$ppAPI = new PaypalLib();
$result = $ppAPI->makeCall($this->getAPIURL(), $this->getAPIScript(), 'SetExpressCheckout', $request);
$this->_logs = array_merge($this->_logs, $ppAPI->getLogs());
return $result;
}
示例13: getURI
/**
* Return the complete URI for a module
* Could be use for return URL process or ajax call
*
* @param string $file of the module you want to target
* @param array $options (value=key)
*
* @return string
*/
public function getURI($file = '', $options = array())
{
return PayPal::getShopDomainSsl() . (__PS_BASE_URI__ . 'modules/' . $this->name . '/' . (!empty($file) ? $file : '')) . '?' . http_build_query($options, '', '&');
}