无法在 PayPal HTMLButton 上指定每个付款请求的“金额”

2024-01-06

我正在尝试使用“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. my application test page for integration enter image description here

  2. paypal page where amount is expected to be fixed based on my request and not editable. enter image description here

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

thanks.


我可以通过让 PayPal 使用以下设置生成按钮来实现它: 1.Merchant account IDs: Use my primary email address[未使用安全商家帐户ID] 2.取消勾选save button at PayPal复选框。另外,在html按钮生成界面中,我点击了链接remove code protection这使得cmd价值来自_s-xclick to _xclick

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法在 PayPal HTMLButton 上指定每个付款请求的“金额” 的相关文章

随机推荐