首页 > 解决方案 > Payee Poprety PayPal Checkout V2 的问题

问题描述

我希望你在这场全球大流行中一切都好

我在使用 api 进行生产时遇到问题,它不想考虑付费属性,而在 Sandbox 中它可以工作,有人可以帮助我吗?

public static function PaymentGenerator(Int $fact, String $userToken, String $productToken, Float $productPrice, String $productSeller, String $currency, String $short_description){
    $config = require('src/Resources/PayPal.php');
    $environment = new ProductionEnvironment($config['id'],$config['secret']);
    $client = new PayPalHttpClient($environment);

    $request = new OrdersCreateRequest();
    $request->prefer('return=representation');
    $request->body = [
        "intent" => "CAPTURE",
        "purchase_units" => [[
            "payee" => [
                "email" => "steellgold0@gmail.com"
            ],

            "reference_id" => "IMS-" . $fact,
            "amount" => [
                "value" => $productPrice,
                "currency_code" => "EUR"
            ],

            "description" => $short_description
        ]],

        "application_context" => [
            "cancel_url" => "http://ismyshop.xyz/payment.php",
            "return_url" => "https://ismyshop.xyz/cap.php"
        ]
    ];

    try {
        $response = $client->execute($request);
        $query = App::getPDO()->prepare("INSERT INTO payments(`user`,`product`,`order_id`, `sandbox`, `completed`) VALUES (?,?,?,?,?)");
        $query->execute(array(
            $userToken, $productToken, $fact, 0, 0
        ));


        foreach($response->result->links as $link) {
            echo "\t{$link->rel}: <a href='{$link->href}'>{$link->href}</a>\tCall Type: {$link->method}<br>";
        }

        echo "<a href='https://www.paypal.com/checkoutnow?token='". $response->result->id . "'>https://www.paypal.com/checkoutnow?token=" . $response->result->id . "</a>";
    }catch (HttpException $ex) {
        echo $ex->statusCode;
        print_r($ex->getMessage());
    }
}

标签: phppaypal-rest-sdk

解决方案


推荐阅读