-3

如果我从这里开始,我应该做什么?要进入前端的贝宝覆盖?(有一些预填充的值。像这样的https://websolutionstuff.com/adminTheme/assets/img/pay.png)这就是我现在想要的。

    $environment = new SandboxEnvironment($clientId, $clientSecret);
    $client = new PayPalHttpClient($environment);

    $request = new OrdersCreateRequest();
    $request->prefer('return=representation');
    $request->body = [
        "intent" => "CAPTURE",
        "purchase_units" => [[
            "reference_id" => "test_ref_id1",
            "amount" => [
                "value" => "100.00",
                "currency_code" => "USD",
            ],
        ]],
        "application_context" => [
            "cancel_url" => "https://example.com/cancel",
            "return_url" => "https://example.com/return",
        ],
    ];

    try {
        $response = $client->execute($request);
        print_r($response);
    } catch (HttpException $ex) {
        echo $ex->statusCode;
        print_r($ex->getMessage());
    }

}

4

1 回答 1

0

如果遇到这个问题,并且您更像是 JS 前端而不是像我这样的后端人员,那么最好使用

https://developer.paypal.com/docs/business/javascript-sdk/

用于前端并将您的数据通过

https://developer.paypal.com/docs/api-basics/notifications/ipn/IPNIntro/

对于 laravel 来说,没有像

https://laravel.com/docs/8.x/billing

为贝宝。

那里有大量的软件包,有大量的解决方案,但是在 2021 年初,没有一个是简单的或在几个小时内完成的,如果不需要贝宝,使用 laravel,去 Cashier(Stripe) 并保存很多时间。

如果您是后端/PHP 人员,那么这可能不是您的解决方案,您会认为这是一个肮脏/困难的解决方法。

于 2021-06-22T20:18:54.763 回答