从 API V1 迁移到 V2:捕获订单后如何获取 PaymentInstuctions?

Migrating from API V1 to V2: How to getPaymentInstuctions after capture order?

我正在尝试从 API V1 迁移到 PHP 中的 V2。在 V1 中,您可以使用此代码在执行付款后获取进一步的付款说明:

try {
    $execution = new Paypal\Api\PaymentExecution();
    $execution->setPayerId($sPayerId);
    $payment = \Paypal\Api\Payment::get($sPaymentId, getApiContext());
    $payment->execute($execution, getApiContext());

    $payment = \Paypal\Api\Payment::get($sPaymentId, getApiContext()); // re-fetch payment with payment-instructions
    if ($payment->getPaymentInstruction())
    {   $sBankName = $payment->getPaymentInstruction()->recipient_banking_instruction->bank_name;
        $sBandAccountNumber = $payment->getPaymentInstruction()->recipient_banking_instruction->international_bank_account_number;
    ...
    }
}
catch(PayPal\Exception\PayPalConnectionException $ex) {
...
}

向我们的客户显示付款说明对我们来说很重要:如果他们使用“稍后付款”/“通过发票付款”功能,他们需要知道将钱转入哪个银行和帐户.

在 API V2 中,您使用此代码获取授权订单:

$request = new PayPalCheckoutSdk\Orders\OrdersCaptureRequest($sOrderId);
try {   
    $response  = getClient()->execute($request);
}
catch(PayPalHttp\HttpException $exception) {
    ....
}

那么现在获取付款说明的后续步骤是什么?

该字段未记录 v1/payments API。

对于 v2/checkout/orders ,payment_instruction 字段被记录为订单创建 request field (within purchase_units) and response 字段。

capturing an authorization 时存在类似字段。


对于 Pay Upon Invoice,有一个 processing_instruction 字段。

在所有这些情况下,字段不包含有关“将钱转入哪个银行和帐户”或类似信息。

但是,对于 PUI,有一个响应字段 payment_source.pay_upon_invoice.deposit_bank_details。也许这就是您要找的。

{
  "id": "5O190127TN364715T",
  "intent": "CAPTURE",
  "status": "COMPLETED",
  "processing_instruction": "ORDER_COMPLETE_ON_PAYMENT_APPROVAL",
  "payment_source": {
    "pay_upon_invoice": {
      "birth_date": "1990-01-01",
      "name": {
        "given_name": "John",
        "surname": "Doe"
      },
      "email": "buyer@example.com",
      "phone": {
        "national_number": "6912345678",
        "country_code": "49"
      },
      "billing_address": {
        "address_line_1": "Schönhauser Allee 84",
        "admin_area_2": "Berlin",
        "postal_code": "10439",
        "country_code": "DE"
      },
      "payment_reference": "b8a1525dlYzu6Mn62umI",
      "deposit_bank_details": {
        "bic": "DEUTDEFFXXX",
        "bank_name": "Deutsche Bank",
        "iban": "DE89370400440532013000",
        "account_holder_name": "Paypal - Ratepay GmbH - Test Bank Account"
      }
    }
  },
  "purchase_units": [
    ....
  ],
  "links": [
    ....
  ]
}