當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Paypal::submitPayment2方法代碼示例

本文整理匯總了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);
}
開發者ID:scttrgd,項目名稱:scottish-piping,代碼行數:101,代碼來源:eStore_payment_submission.php


注:本文中的Paypal::submitPayment2方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。