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

标签 paypal paypal-sandbox

我正在尝试使用“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. 取消选中 PayPal 中的保存按钮 复选框。另外,在html按钮生成界面中,我单击了链接删除代码保护,这使得cmd值从_s-xclick变为 _xclick

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

相关文章:

android - Paypal集成开发中的PaymentActivity.EXTRA_CLIENT_ID是什么

paypal - 如何配置 Paypal 沙箱进行测试

android - PaymentActivity.EXTRA_SKIP_CREDIT_CARD无法解析

php - 如何获得 Paypal 'Add to Cart' 按钮响应?

security - PayPal 混淆的 TLS 升级 - g5 根证书

paypal - 在沙盒上找不到 Paypal 支付按钮创建

asp.net - 无法创建 SSL/TLS 安全通道 - GetRequestStream()

ruby-on-rails - 在活跃商户应用程序中使用两步验证的卡(信用卡/借记卡)会发生什么情况?

php - fatal error : Class 'Paypal\Api\Payer' not found en sdk Paypal

php - Paypal Masspay 问题