如何将PayPal经典付款表单转换为PayPal REST API PHP 应用程序


How to transform PayPal Classic Payment form into PayPal REST API PHP Application?

以下是最简单的PayPal接口形式:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" /> 
  <input type="hidden" name="cmd" value="_xclick" /> 
  <input type="hidden" name="business" value="JohnDoe2@example.com" /> 
  <input type="hidden" name="item_name" value="Purchase at the Virtual Store" /> 
  <input type="hidden" name="item_number" value="Organic-001" />
  <input type="hidden" name="amount" value="17.4" /> 
  <input type="hidden" name="currency_code" value="EUR" /> 
  <input type="hidden" name="notify_url" value="http://www.example.com/paypalnotify.php" /> 
  <input type="submit" name="submit" value="Pay now By PayPal" />
</form>

此表单特定于PayPal高级企业帐户和给定的支付金额,具有以下关键参数:

  1. business=JohnDoe2@example.com。
  2. 金额=17.4欧元。
  3. currency_code=欧元或美元。
  4. notify_url作为 PayPal.com 结束时的回调。

通过点击 [提交] 按钮,它会执行以下操作:

  1. 它将客户重定向到 paypal.com 站点。
  2. 用户将登录到她/他的PayPal帐户,并验证付款。
  3. PayPal网站将调用 paypalnotify.php就像回调一样,传递信息,指示付款是否已成功、取消或无效......

现在在使用PalPal REST API的新界面中,使用PHP开发工具包,如何进行支付?

有几个选项。首先查看以下文件中的代码:

https://github.com/paypal/rest-api-sdk-php/blob/master/sample/payments/CreatePayment.phphttps://github.com/paypal/rest-api-sdk-php/blob/master/sample/payments/CreatePaymentUsingPayPal.php

显然,它们没有任何交互式表单,但它们显示了一般过程。深入研究并完成创建代码的过程。然后,当您遇到问题时,请打开一个包含特定问题的新问题。StackOverflow不适用于"我如何做"类型的问题。https://stackoverflow.com/help/on-topic