具有动态金额的 Paypal 网站支付标准
我有一个场景,用户可以输入他想要计费的金额。我使用使用代码创建的 buynow 按钮。现在,在这种情况下,我的想法是:
- 将最低账单金额设置为 10 美元
- 如果他输入的值低于该值,则给出错误。
- 在表单加载时将立即购买按钮的金额设置为 10 美元。
- 一旦用户输入大于 10 的数字,就会向控制器发出 ajax 请求
- 根据之前在 PayPal 上创建的金额检查其是否是保存在数据库中的按钮。
- 如果按钮不存在,请在 PayPal 上创建一个新按钮,并将按钮保存在数据库中。
- 返回新创建按钮的 HTML
- 用返回的 HTML 替换现有按钮
这种方法的问题是它可能太重了。我也不想将表格分散到两页纸上。有没有其他更好的选择?我可以做一些调整以使这个选项更强大吗?
I have a scenario where a user can input the amount he wants to be billed. I use buynow buttons that are created using code. Now in this case what what i had in mind was to:
- Set minimum billing amount to 10$
- If he enters below that, give error.
- Set the amount of buynow button 10$ when form loads.
- Once User inputs a number greater than 10 do an ajax request to controller
- Check if their is a button saved in DB against that amount that was created earier on PayPal.
- If button does not exist, create a new one on PayPal, save button in the DB.
- Return the HTML of the newly created button
- Replace the existing button with the returned HTML
Problem with this approach is that it might be too heavy. I also do not want to spread form over 2 pages. Are there any alternate and better options? Can i do some tweaks to make this option more robust?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,更好的选择是使用 API 并通过 Express 或 Payments Pro 进行付款。本质上,您试图通过将按钮设置为 API 的工作来使这一过程变得过于复杂;在此过程中,两全其美。
您仍然可以使用“立即付款”按钮图形,但只需使用几个curl命令将您自己的请求提交到paypal Express网关(正是该按钮为您所做的事情)。
有很多可用的教程,但 PayPal 在其网站上提供了 PHP 代码和完整的演练,因此我认为最好直接访问源代码。
登录PayPal->商户服务->快速结账
在“设置”下,您将找到所有实施细节。
A better option in this case would be to use the API and do the payments via either Express or Payments Pro. Essentially, you're trying to over-complicate this by making the buttons to the job of the API; getting the worst of both worlds in the process.
You could still utilize a "pay now" button graphic, but just submit your own request to the paypal express gateway (exactly what the button does for you) with a couple curl commands.
There are many tutorials available, but PayPal provides PHP code and a complete walkthrough on their site, so best, in my opinion, to go right to the source.
Log into PayPal -> Merchant Services -> Express Checkout
Under "Setting it up", you'll find all the implementation details.