Search code examples
phppaypal

Paypal DEV - The recurring payment for X is canceled


I am creating a subscription on paypal with REST API: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create

After i pay with my sandbox account, when i retrieve the subscription from my website it shows that the status is expired.

In the developer testing tools i am getting two Notifications : One is - payment received and another is -profile cancelled.

What are possible reason for this? Others are working fine. Subscription payment is also working but problem is i am getting EXPIRED status.

I am using PHP for creating pricing plan.

$request_body = [
                "product_id" => 'PROD-61H55966BE620723A,
                "name" => "SIMPLE PLAN,
                "billing_cycles" => [[
                    "tenure_type" => 'REGULAR',
                    "sequence" => 1,
                    "frequency" => [
                        "interval_unit" => 'YEAR',
                        "interval_count"=> 1
                    ],
                    "pricing_scheme" => [
                        "fixed_price" => [
                            "value" => 199,
                            "currency_code" => 'USD'
                        ]
                    ],
                ]],
                "payment_preferences" => [
                    "auto_bill_outstanding" => true,
                    "setup_fee_failure_action" => "CONTINUE",
                    "payment_failure_threshold" => 2
                ]
            ];
$args = [
        'method'      => 'POST',
        'headers' => [
            'Content-Type' => "application/json",
            'Authorization'=> 'Bearer ' . $this->access_token,
        ],
        'body' => json_encode($request_body),
    ];

enter image description here

enter image description here


Solution

  • Per the Create Plan API reference

    • billing_cycles[0].total_cycles defaults to 1. Set to 0 for infinite