本文整理汇总了PHP中PayPal\Api\Payer::setExternalSelectedFundingInstrumentType方法的典型用法代码示例。如果您正苦于以下问题:PHP Payer::setExternalSelectedFundingInstrumentType方法的具体用法?PHP Payer::setExternalSelectedFundingInstrumentType怎么用?PHP Payer::setExternalSelectedFundingInstrumentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayPal\Api\Payer
的用法示例。
在下文中一共展示了Payer::setExternalSelectedFundingInstrumentType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Payer
function payment_redirect($cart = false, $approval = false, $order_exists = false)
{
global $order, $xtPrice;
// auth
$apiContext = $this->apiContext();
// set payment
$payer = new Payer();
$payer->setPaymentMethod('paypal');
if ($this->code == 'paypalinstallment') {
$payer->setExternalSelectedFundingInstrumentType('CREDIT');
}
// set payer_info
$payer_info = new PayerInfo();
// set items
$item = array();
// set details
$this->details = new Details();
// set amount
$this->amount = new Amount();
// set ItemList
$itemList = new ItemList();
// set redirect
$redirectUrls = new RedirectUrls();
// set address
$shipping_address = new ShippingAddress();
if ($cart === true) {
$products = $_SESSION['cart']->get_products();
for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
$item[$i] = new Item();
$item[$i]->setName($this->encode_utf8($products[$i]['name']))->setCurrency($_SESSION['currency'])->setQuantity($products[$i]['quantity'])->setPrice($products[$i]['price'])->setSku($products[$i]['model'] != '' ? $products[$i]['model'] : $products[$i]['id']);
$this->details->setSubtotal($this->details->getSubtotal() + $products[$i]['final_price']);
}
$total = $price = $_SESSION['cart']->show_total();
if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == 1 && $_SESSION['customers_status']['customers_status_ot_discount'] != '0.00') {
if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) {
$price = $total - $_SESSION['cart']->show_tax(false);
}
$this->details->setShippingDiscount($this->details->getShippingDiscount() + $xtPrice->xtcGetDC($price, $_SESSION['customers_status']['customers_status_ot_discount']) * -1);
}
$this->amount->setTotal($total + $this->details->getShippingDiscount());
if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1 && MODULE_SMALL_BUSINESS != 'true') {
foreach ($_SESSION['cart']->tax as $tax) {
$this->details->setTax($this->details->getTax() + $tax['value']);
}
$total = $this->calc_total();
$amount_total = $this->amount->getTotal();
if ((string) $amount_total != (string) $total) {
$this->details->setTax($this->details->getTax() + ($amount_total - $total));
}
}
$shipping_cost = $this->get_config('MODULE_PAYMENT_' . strtoupper($this->code) . '_SHIPPING_COST');
if ((int) $shipping_cost > 0) {
$i = count($item);
$item[$i] = new Item();
$item[$i]->setName($this->encode_utf8(PAYPAL_EXP_VORL))->setCurrency($_SESSION['currency'])->setQuantity(1)->setPrice($shipping_cost);
$this->amount->setTotal($this->amount->getTotal() + $shipping_cost);
$this->details->setSubtotal($this->amount->getTotal());
}
// set amount
$this->amount->setCurrency($_SESSION['currency'])->setDetails($this->details);
// set redirect
$redirectUrls->setReturnUrl($this->link_encoding(xtc_href_link('callback/paypal/paypalcart.php', '', 'SSL')))->setCancelUrl($this->link_encoding(xtc_href_link(FILENAME_SHOPPING_CART, 'payment_error=' . $this->code, 'SSL')));
} else {
$shipping_address->setRecipientName($this->encode_utf8($order->delivery['firstname'] . ' ' . $order->delivery['lastname']))->setLine1($this->encode_utf8($order->delivery['street_address']))->setCity($this->encode_utf8($order->delivery['city']))->setCountryCode($this->encode_utf8($order_exists === false ? $order->delivery['country']['iso_code_2'] : $order->delivery['country_iso_2']))->setPostalCode($this->encode_utf8($order->delivery['postcode']))->setState($this->encode_utf8($order->delivery['state'] != '' ? xtc_get_zone_code($order->delivery['country_id'], $order->delivery['zone_id'], $order->delivery['state']) : ''));
if ($order->delivery['suburb'] != '') {
$shipping_address->setLine2($this->encode_utf8($order->delivery['suburb']));
}
$subtotal = 0;
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
$item[$i] = new Item();
$item[$i]->setName($this->encode_utf8($order->products[$i]['name']))->setCurrency($order->info['currency'])->setQuantity($order->products[$i]['qty'])->setPrice($order->products[$i]['price'])->setSku($order->products[$i]['model'] != '' ? $order->products[$i]['model'] : $order->products[$i]['id']);
$subtotal += $order->products[$i]['price'] * $order->products[$i]['qty'];
}
// set totals
if ($order_exists === false) {
if (!class_exists('order_total')) {
require_once DIR_WS_CLASSES . 'order_total.php';
}
$order_total_modules = new order_total();
$order_totals = $order_total_modules->process();
$this->get_totals($order_totals, true, $subtotal);
} else {
$this->get_totals($order->totals);
}
// set amount
$this->amount->setCurrency($order->info['currency'])->setDetails($this->details);
// set redirect
if ($order_exists === false) {
$redirectUrls->setReturnUrl($this->link_encoding(xtc_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')))->setCancelUrl($this->link_encoding(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'SSL')));
} else {
$redirectUrls->setReturnUrl($this->link_encoding(xtc_href_link('callback/paypal/' . $this->code . '.php', 'oID=' . $order->info['order_id'] . '&key=' . md5($order->customer['email_address']), 'SSL')))->setCancelUrl($this->link_encoding(xtc_href_link('callback/paypal/' . $this->code . '.php', 'payment_error=' . $this->code . '&oID=' . $order->info['order_id'] . '&key=' . md5($order->customer['email_address']), 'SSL')));
}
if ($this->code == 'paypalinstallment') {
$redirectUrls->setReturnUrl($this->link_encoding(xtc_href_link(FILENAME_CHECKOUT_CONFIRMATION, 'conditions=true', 'SSL')));
}
}
// set ItemList
if ($this->get_config('PAYPAL_ADD_CART_DETAILS') == '0' || $this->check_discount() === true) {
$item = array();
$item[0] = new Item();
//.........这里部分代码省略.........