转移到 PayPal -> 付款处理 -> 返回网站。 根据客户想要“立即购买”的商品,提交表-6ren">
gpt4 book ai didi

paypal - 无法在 PayPal HTMLButton 上为每个付款请求指定 "amount"

转载 作者:太空宇宙 更新时间:2023-11-03 15:47:14 25 4
gpt4 key购买 nike

我正在尝试使用“HTML 按钮”方法与 PayPal 集成。结帐流程相当简单,用户点击“立即购买” -> 转移到 PayPal -> 付款处理 -> 返回网站。

根据客户想要“立即购买”的商品,提交表格中的“金额”会有所不同,我无法让 PayPal 接受我发送的金额。当重定向到 PayPal 时,我总是看到一个空的文本输入。

我尝试了托管和非托管按钮,但仍然无法看到预期的效果。

托管按钮 HTML 示例:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="HOSTEDBTNVALUE">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/SG/i/btn/btn_buynowCC_LG.gif" name="submit" alt="PayPal – The safer, easier way to pay online!" style="border: 0;">
<img alt="" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" style="border: 0; width: 1; height: 1;">
<input type="text" readonly="true" name="item_name" value="Test PayPal integration payment">
<div class="form-group" id="amount_field">
<label class="control-label col-md-2" for="amount">Amount</label>
<div class="col-md-5">
<input type="text" id="amount" name="amount" value="100" aria-describedby="amount_info_0" class="form-control"><span id="amount_info_0" class="help-block">Real</span></div>
</div>
<div class="form-group" id="txnRef_field">
<label class="control-label col-md-2" for="txnRef">Transaction Ref</label>
<div class="col-md-5">
<input type="text" id="txnRef" name="txnRef" value="8d724ad470af4d9d91d49f84068c4bab" aria-describedby="txnRef_info_0" class="form-control"><span id="txnRef_info_0" class="help-block">Required</span></div>
</div>
<input type="hidden" name="currency_code" value="SGD">
</form>

上面的“金额”目前是一个文本输入,因为这是我的集成测试页面,在实际应用中它将是一个隐藏/只读嵌入在表单中的输入。

这是非托管按钮示例代码:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----ReallyLongKey-----END PKCS7-----">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/SG/i/btn/btn_buynowCC_LG.gif" name="submit" alt="PayPal – The safer, easier way to pay online!" style="border: 0;"><img alt="" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" style="border: 0; width: 1; height: 1;">
<input type="hidden" name="notify_url" value="https://myapplication.com/transaction/paypal/status">
<input type="hidden" name="currency_code" value="SGD">
<input type="hidden" name="custom" value="ad4a63e2f2f04b908ddb8e7c67f9c67a">
<input type="text" readonly="true" name="item_name" value="Test PayPal integration payment">
<div class="form-group" id="amount_field">
<label class="control-label col-md-2" for="amount">Amount</label>
<div class="col-md-5">
<input type="text" id="amount" name="amount" value="100" aria-describedby="amount_info_0" class="form-control"><span id="amount_info_0" class="help-block">Real</span></div>
</div>
<div class="form-group" id="txnRef_field">
<label class="control-label col-md-2" for="txnRef">Transaction Ref</label>
<div class="col-md-5">
<input type="text" id="txnRef" name="txnRef" value="ad4a63e2f2f04b908ddb8e7c67f9c67a" aria-describedby="txnRef_info_0" class="form-control"><span id="txnRef_info_0" class="help-block">Required</span></div>
</div>
</form>

下面是应用程序页面的屏幕截图,以及我在 PayPal 付款页面上看到的结果。请原谅缺乏对齐和样式。这是为了在它变得漂亮之前进行概念验证。

  1. 我的应用程序集成测试页 enter image description here

  2. paypal 页面,其中的金额预计将根据我的要求固定且不可编辑。 enter image description here

不确定我在这里做错了什么。请帮忙。

谢谢。

最佳答案

我能够通过使用以下设置让 PayPal 生成按钮来实现它:1. 商家帐户 ID:使用我的主要电子邮件地址 [未使用安全的商家帐户 ID]2. 取消选中 save button at PayPal 复选框。另外,在html按钮生成界面中,我点击了链接remove code protection,这使得cmd的值从_s-xclick变为了 _x点击

关于paypal - 无法在 PayPal HTMLButton 上为每个付款请求指定 "amount",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40210676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com