php - Magento 2 : How to change Payment Action Method on the fly in Paypal Express

标签 php payment-gateway magento2 paypal

我已经创建了 Paypal/Developer/Sandbox 帐户。已获得 API 凭据。

已下载 PHP SDK http://paypal.github.io/PayPal-PHP-SDK/

引用:https://developer.paypal.com/docs/api/

https://devtools-paypal.com/guide/expresscheckout/php?interactive=ON&env=sandbox

我已经使用我的 PHP 脚本通过 Authorize 方法完成了 Sandbox One Transaction。

我必须达到的目标。 我需要获得授权付款,将“授权”付款转换为“捕获/销售”方法并同时通知客户和管理员。

如何获取Authorization Id?

引用上面的文档我需要使用3个Web服务

  • 获取授权付款的详细信息
  • 获取授权付款
  • 获取已捕获付款的详细信息

已有“授权”付款的交易 ID。

请提供要遵循的步骤,如果有任何示例可用,请分享

需要在 Magento 2 中集成此功能

[更新]

我已经在 PayPal-PHP-SDK-master\sample\bootstrap.php 文件中的 PHP SDK 中更改了我的 API 沙盒凭证。

sample/payments/AuthorizePayment.php 我将获得 ID 为 PAY-0TV39791XXX02404VK7XD32I 的授权付款,它工作正常。

当我输入我的 Transaction Id 时,它会给出

{"name":"INVALID_RESOURCE_ID","message":"Requested resource ID was not found.","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID","debug_id":"1f2b08ce88633"}

我的沙盒交易 ID 是 3AA32794KF48247AA。那么问题是如何将您的交易 ID 转换为付款 ID?

https://magento.stackexchange.com/questions/138579/magento-2-change-paypal-action-method-on-the-fly

下面是Paypal的回复

Transaction id can be generated after REST API execute payment, Classic API [NVP/SOAP] DoEC API or normal button payment completion. It will never work to reverse the search to find the Payment Id.

最佳答案

如果你有paymentId,你可以通过这种方式获取授权支付的详细信息:

$payment = Payment::get( $paymentId, $apiContext );

要了解支付类的所有属性,请查看此 - Payment.php

要更改沙盒/API 凭据,请编辑 bootstrap.php在你的项目中。

更新

您不需要使用 AuthorizePayment.php。相反,请执行以下操作:

  1. 创建付款并获取授权的 url(您的网站端)。
  2. 打印用于授权的 url(您的网站端)。
  3. 客户按照授权 url 转到 PayPal 并授权付款(PayPal 端)。
  4. PayPal 使用 paymentId(PayPal 端)将客户返回到您的网站。
  5. 获取 paymentId 并执行付款(您的网站端)。

关于php - Magento 2 : How to change Payment Action Method on the fly in Paypal Express,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39785327/

相关文章:

magento2 - 用管道 (|) 分隔限制器值

php - 列存在但抛出未找到列 : 1054 Unknown column 'so.event_id' in 'where clause' while inserting into sales_order

php - 我可以在准备好的语句中参数化表名吗?

PHP DOMDocument - 获取 BODY 的 html 源代码

php - curl 中与 Moneris 服务器的 HTTPS 连接

android - 在 android 中集成 payU Money 时,成功 url 和失败 url 是什么?

Paypal IPN 处理程序

php - 按首选项覆盖 Magento_SalesRule ResourceModel 会引发错误 : Type Error occurred when creating object

php - 创建用户,但使用 PHP 检查 Active Directory 中是否存在

php - 为什么每个人都使用 latin1?