本文整理汇总了PHP中Paypal::submitPayment2方法的典型用法代码示例。如果您正苦于以下问题:PHP Paypal::submitPayment2方法的具体用法?PHP Paypal::submitPayment2怎么用?PHP Paypal::submitPayment2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paypal
的用法示例。
在下文中一共展示了Paypal::submitPayment2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submit_to_paypal
//.........这里部分代码省略.........
foreach ($_SESSION['eStore_cart'] as $item) {
$rounded_price = round($item['price'], 2);
$rounded_price = apply_filters('eStore_change_price_before_payment_filter', $rounded_price);
$myPaypal->addField("item_name_{$count}", htmlspecialchars($item['name']));
$myPaypal->addField("amount_{$count}", $rounded_price);
$myPaypal->addField("quantity_{$count}", $item['quantity']);
$myPaypal->addField("item_number_{$count}", $item['item_number']);
//Check to see if this is a tax free item and set the tax accordingly so that the profile based PayPal tax can work nicely
if ($item['tax'] == "0") {
$myPaypal->addField("tax_{$count}", $item['tax']);
}
$id = $item['item_number'];
$ret_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$id}'", OBJECT);
if (!empty($ret_product->weight)) {
$weight += $ret_product->weight * $item['quantity'];
}
if (empty($item['digital_flag'])) {
$all_items_digital = false;
}
$count++;
}
$total_items_in_cart = count($_SESSION['eStore_cart']);
if ($total_items_in_cart == 1 && !empty($ret_product->return_url)) {
$myPaypal->addField('return', $ret_product->return_url);
} else {
if (!empty($eStore_return_url)) {
$myPaypal->addField('return', $eStore_return_url);
}
}
if (!get_option('eStore_paypal_profile_shipping')) {
//Not Using paypal's profile based shipping so include shipping otherwise ignore shipping here as it will be calculated on paypal's site
$shipping = round($_SESSION['eStore_cart_postage_cost'], 2);
if (!empty($shipping)) {
$shipping = apply_filters('eStore_change_shipping_before_payment_filter', $shipping);
//change tax amount before submitting if converting currency to another type
$myPaypal->addField('no_shipping', '2');
$myPaypal->addField('handling_cart', $shipping);
//$myPaypal->addField('shipping_1', $shipping);
} else {
//If you do not want to collect address for checkout that has no shipping cost then uncomment the following line of code.
//$myPaypal->addField('no_shipping', '1');
}
} else {
//Include the weight for profile based shipping calc
$myPaypal->addField('weight_cart', round($weight, 2));
$myPaypal->addField('weight_unit', 'lbs');
if ($all_items_digital) {
//All the items in the cart are digital items so set the shipping flag to 0 so no shipping is charged
$total_items = count($_SESSION['eStore_cart']);
for ($i = 1; $i <= $total_items; $i++) {
$myPaypal->addField('shipping_' . $i, '0');
}
} else {
if (isset($_SESSION['eStore_cart_postage_cost']) && $_SESSION['eStore_cart_postage_cost'] == 0) {
//Free shipping discount applied. send 0 shipping to override profile based shipping
if (empty($weight)) {
//Add $0 shipping override
$myPaypal->addField('shipping_1', '0');
}
}
}
}
if (!empty($_SESSION['eStore_cart_total_tax'])) {
$cart_total_tax = round($_SESSION['eStore_cart_total_tax'], 2);
$cart_total_tax = apply_filters('eStore_change_tax_before_payment_filter', $cart_total_tax);
//change tax amount before submitting if converting currency to another type
$myPaypal->addField('tax_cart', $cart_total_tax);
}
if (get_option('eStore_display_tx_result')) {
$myPaypal->addField('rm', '1');
}
if (defined('WP_ESTORE_FORCE_LANGUAGE_OF_PAYPAL_PAGE') && WP_ESTORE_FORCE_LANGUAGE_OF_PAYPAL_PAGE !== '0') {
//Set the country/region preference by force.
$myPaypal->addField('lc', WP_ESTORE_FORCE_LANGUAGE_OF_PAYPAL_PAGE);
}
$myPaypal->addField('cmd', '_cart');
$myPaypal->addField('upload', '1');
$custom_field_val = eStore_get_custom_field_value();
$myPaypal->addField('custom', $custom_field_val);
$myPaypal->addField('mrb', '3FWGC6LFTMTUG');
$page_style_name = get_option('eStore_paypal_co_page_style');
if (!empty($page_style_name)) {
$myPaypal->addField('page_style', $page_style_name);
}
$returnButtonText = get_option('eStore_paypal_return_button_text');
if (!empty($returnButtonText)) {
$myPaypal->addField('cbt', $returnButtonText);
}
// Enable sandbox mode if needed
if ($eStore_sandbox_enabled) {
$myPaypal->enableTestMode();
}
// Lets clear the cart if automatic redirection is not being used otherwise we will empty the cart after the redirection
$PDT_auth_token = get_option('eStore_paypal_pdt_token');
if (empty($PDT_auth_token)) {
reset_eStore_cart();
}
// submit the payment!
$myPaypal->submitPayment2(WP_ESTORE_CLICK_HERE);
}