如何获取 PayPal Plus 集成的 approvalURL?

How to get the approvalURL for PayPal Plus integration?

我遵循了官方说明:https://www.paypalobjects.com/digitalassets/c/website/marketing/emea/de/de/paypal-plus-center/PayPal_PLUS_integration_guide.pdf

08。集成 PayPal PLUS

Prior to rendering the payment wall a payment resource must be created. The corresponding API call is “create payment”. When creating the payment resource am ount, currency and items details must be submitted.

..好的。理解。所以我需要创建付款,获取 Url 然后我可以最终呈现 PayPalPlus-Object。

我按照 https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/payments/CreatePaymentUsingPayPal.php 作为示例脚本和其他人。但是我无法从 $payment->getApprovalLink()

收到任何东西

我完全错了吗?

我可以使用哪个示例来创建付款并呈现 paypal-plus 东西?

<?php
require '../vendor/autoload.php';
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'xxx',     // ClientID
'xxx'      // ClientSecret
)
);

$apiContext->setConfig(
array(
'mode' => 'sandbox'
)
);

$item1 = new \PayPal\Api\Item();
$item1->setName('Test item')
->setCurrency('USD')
->setQuantity(1)
->setPrice(1);

$itemList = new \PayPal\Api\ItemList();
$itemList->setItems(array($item1));

$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal');

$amount = new \PayPal\Api\Amount();
$amount->setCurrency('USD');
$amount->setTotal('1');

$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);
$transaction->setItemList($itemList);
//$transaction->setInvoiceNumber(uniqid());
//$transaction->setDescription('Description');

$redirectUrl = new \PayPal\Api\RedirectUrls();
$redirectUrl->setReturnUrl('http://localhost');
$redirectUrl->setCancelUrl('http://localhost');

$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale');
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrl);
$payment->setTransactions(array($transaction));

$payment = $payment->create($apiContext);

$approvalUrl = $payment->getApprovalLink();

echo $approvalUrl;