亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用我自己的各種付款選項的高級設置的自定義條紋結賬表單

使用我自己的各種付款選項的高級設置的自定義條紋結賬表單

PHP
四季花海 2023-07-21 16:24:48
好的,我可以提供盡可能多的細節,我正在嘗試讓條形結帳表格與我自己的高級設置一起使用。這意味著在我網站的管理面板中,我可以從那里添加設置或調整價格。我將提供照片和代碼。以下是 PayPal 表單代碼示例。正如您所看到的,我使用按鈕代碼變量來處理我設置的不同價格和產品。代碼變量示例 = [merchant_id] [item_name] [amount] [item_number] [user_id] [return] [notify] [merchant_button]<form action="" method="post">  <input type="hidden" name="cmd" value="_xclick">  <input type="hidden" name="business" value="[merchant_id]">  <input type="hidden" name="item_name" value="[item_name]">  <input type="hidden" name="amount" value="[amount]">  <input type="hidden" name="no_note" value="1">  <input type="hidden" name="currency_code" value="USD">  <input type="hidden" name="item_number" value="[item_number]">  <input type="hidden" name="custom" value="[user_id]">  <input type="hidden" name="return" value="[return]">  <input type="hidden" name="notify_url" value="[notify]">  <input type="image" src="[merchant_button]" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"></form>我需要條紋結賬表格以同樣的方式工作。下圖是產品的銷售套餐。另外,我還添加了一個產品,如下圖所示,按鈕會自動添加到會員銷售頁面。這是創建按鈕和結賬的表單代碼需要執行的地方。這是需要進入表單值的代碼變量,以使表單結賬適用于每個價格或產品。我有從下面的條紋中嘗試過的表格。<!-- Load Stripe.js on your website. --><script src="https://js.stripe.com/v3"></script><!-- Create a button that your customers click to complete their purchase. Customize the styling to suit your branding. --><buttonstyle="background-color:#6772E5;color:#FFF;padding:8px 12px;border:0;border-radius:4px;font-size:1em"id="checkout-button-price_1H2XkYEESdtcMolQIxkRKapX"role="link"type="button">Checkout</button>div id="error-message"></div>我需要能夠將以下代碼變量 --> [merchant_id] [item_name] [amount] [item_number] [user_id] [return] [notify]<-- 放入條帶結帳表單中,以便它能夠拾取用戶單擊的每個價格按鈕,這些按鈕是我從管理員的“銷售包”頁面設置的,就像您在 PayPal 中看到的那樣。我已經嘗試了幾天,我想獲得正確的表單和腳本,以類似的方式工作。也許我使用了來自 stripe 的錯誤代碼和腳本?
查看完整描述

1 回答

?
慕虎7371278

TA貢獻1802條經驗 獲得超4個贊

當使用“僅客戶端”(即僅 Javascript)結賬時,只能傳入已知的 Price 對象,而不是動態價格:

https://stripe.com/docs/js/checkout/redirect_to_checkout#stripe_checkout_redirect_to_checkout-options-lineItems

這意味著您無法從前端 Javascript 傳遞商品的金額。相反,您必須在 Stripe Dashboard 中創建產品 + 價格,然后在按鈕代碼中引用價格的 ID:

(function() {


var stripe = Stripe('pk_test_6pRNASCoBOKtIshFeQd4XMUh');

var checkoutButton = document.getElementById('checkout-button-price_1H2XkYEESdtcMolQIxkRKapX');


checkoutButton.addEventListener('click', function () {

? stripe.redirectToCheckout({

? ? lineItems: [{price: 'price_1H2XkYEESdtcMolQIxkRKapX', quantity: 1}],

? ? mode: 'payment',

? ? successUrl: window.location.protocol + '//proadtraffic.com/success',

? ? cancelUrl: window.location.protocol + '//proadtraffic.com/canceled',

? })

? .then(function (result) {

? ? if (result.error) {

? ? ? var displayError = document.getElementById('error-message');

? ? ? displayError.textContent = result.error.message;

? ? }

? });

});


})();

</script>

但是,如果您想要從前端傳入的可變金額,您可以做的是創建 1 美元的價格(例如),然后根據您銷售的每種產品的需要設置數量。我建議使用允許動態定價的客戶端-服務器方法,或者為您銷售的商品創建價格并傳遞價格 ID,如上所示。


與 PayPal 按鈕不同,這種方法可以防止客戶編輯 Web 表單并給自己打折(例如)——Stripe 只允許在 Checkout 中顯示已知價格。


查看完整回答
反對 回復 2023-07-21
  • 1 回答
  • 0 關注
  • 134 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號