Paypal通过API取消订阅无效

问题描述 投票:0回答:1

我正在尝试通过api取消Paypal订阅。我遵循了这份文件。https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_cancel

根据本文档。

curl -v -X POST https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/cancel \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token" \
-d '{
  "reason": "Not satisfied with the service"
}'

据此,我创建了以下CURL

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.sandbox.paypal.com/v1/billing/subscriptions/I-X88N77T9HN56/cancel');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"reason\":\"Not satisfied with the service\"}");
    curl_setopt($ch, CURLOPT_POST, 1);

    $headers = array();
    $headers[] = 'Content-Type: application/json';
    $headers[] = 'Authorization: Bearer '.$access_token;
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    $result = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    }
    curl_close($ch);

    if(empty($result))die("Error: No response.");
    else
    {
        $json = json_decode($result);
        echo "<pre>";
        print_r($json);
        echo "</pre>";
    }

它对我不起作用,出现以下错误。

stdClass Object
(
    [name] => RESOURCE_NOT_FOUND
    [message] => The specified resource does not exist.
    [debug_id] => f8c1c32066dd7
    [details] => Array
        (
            [0] => stdClass Object
                (
                    [issue] => INVALID_RESOURCE_ID
                    [description] => Requested resource ID was not found.
                )

        )

    [links] => Array
        (
            [0] => stdClass Object
                (
                    [href] => https://developer.paypal.com/webapps/developer/docs/api/#INVALID_RESOURCE_ID
                    [rel] => information_link
                    [method] => GET
                )

        )

)
paypal paypal-subscriptions
1个回答
0
投票

我也面临着同样的问题。您是否找到了上述解决方案?

© www.soinside.com 2019 - 2024. All rights reserved.