PayPal doesn't capture payment after subscription is created - React

random4
Contributor
Contributor

We are using PayPal in order to enable subscription in our platform. I set up the product and plans inside PayPal and integrated the "PayPal Smart Buttons" using the "react-smart-payment-buttons" package (https://github.com/erksch/react-smart-payment-buttons).

We managed to create the subscription successfully but the first payment is not captured immediately or at all.

When we are using the PayPal Subscription API in order the see when will be the next billing cycle, it shows a timestamp that has already passed.

For example, this is part of the JSON I got from the API:

"billing_info": {
        "outstanding_balance": {
            "currency_code": "USD",
            "value": "0.0"
        },
        "cycle_executions": [
            {
                "tenure_type": "REGULAR",
                "sequence": 1,
                "cycles_completed": 0,
                "cycles_remaining": 12,
                "current_pricing_scheme_version": 1
            }
        ],
        "next_billing_time": "2019-07-01T10:00:00Z",
        "failed_payments_count": 0
    },
    "auto_renewal": false,
    "create_time": "2019-07-01T15:34:02Z"
}

As you can see, the next_billing_time value is before the create_time which doesn't make sense.

What we already did: After the user approves the subscription, we are getting the ID of the order and also the subscription. When trying to capture the payment by using the PayPal Payments API and the order id I got, we are getting back an error. I checked the status of the created subscription and it shows ACTIVE.

createSubscription(data, actions) {
    let plan_id = process.env.REACT_APP_PAY_PAL_BASIC_PLAN_ID;
    return actions.subscription.create({        plan_id
    });
}onApprove(data, actions) {
    const Http = new XMLHttpRequest();
    let url = process.env.REACT_APP_UPGRADE_USER_URL;
    Http.open("POST", url);
    Http.setRequestHeader("x-access-token", this.state.token);
    Http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    Http.send(`plan=${this.state.plan}&subscriptionId=${data.subscriptionID}`);
}

we'll be happy if someone can assist me with this problem.

Thanks in advance.

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.