Testing on the Sandbox using PayPal Basic Integration guide to create a subscription using the new Subscription API. The product and Plan have been created.
The subscription seems to be created, the response with the HATEOS Link which is then received is used to redirect to the approve link. Then the Paypal site is presented with the payment and agreement page but after successfully completing the steps on PayPal it does NOT redirect to merchant site. Instead there is an image of a large check mark and saying that you "You set up a subscription to John Doe’s Test Store".
While the PayPal site is accepting the subscription agreement, the url contains "return=true" in the address bar and it eventually ends at this url:
https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-7XD20193UM926691X&country.x=US&locale.x=en_US&mode=member&token=66576892AP560221M where the check mark is displayed.
Assuming that when PayPal redirects to merchant site the response will have some sort of details on the subscription that would enable the merchant site to provision the service to the user.
Subscription Request sent to Subscription API:
{
"plan_id": "P-37P31725GH704245LL2V467Q",
"subscriber": {
"name": {
"given_name": "Givenname",
"surname": "Surname"
},
"email_address": "xxREMOVEDxx"
},
"application_context": {
"user_action": "SUBSCRIBE_NOW",
"payment_method": {
"payer_selected": "PAYPAL",
"payee_preferred": "IMMEDIATED_PAYMENT_REQUIRED"
},
"return_url ": "https://localhost:44395/PayPal/SubscribeApproved",
"cancel_url ": "https://localhost:44395/PayPal/cancel"
}
}
HATEOS Response:
{
"status": "APPROVAL_PENDING",
"status_update_time": "2020-05-02T19:26:56Z",
"id": "I-SYF055DEEXGC",
"plan_id": "P-37P31725GH704245LL2V467Q",
"start_time": "2020-05-02T19:26:56Z",
"quantity": "1",
"subscriber": {
"name": {
"given_name": "Givenname",
"surname": "Surname"
},
"email_address": "xxREMOVEDxx"
},
"create_time": "2020-05-02T19:26:56Z",
"links": [
{
"href": "https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-76D512072C206284F",
"rel": "approve",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/subscriptions/I-SYF055DEEXGC",
"rel": "edit",
"method": "PATCH"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/subscriptions/I-SYF055DEEXGC",
"rel": "self",
"method": "GET"
}
]
}
3
Answers
Are you using the latest version of the Subscriptions API? Just making sure. It is not supported by any SDKS, and requires direct API calls fro PROD and Plan creation
Why are you using redirects, anyway? The best solution is to not use any redirects. At all. In keeping with modern web design practices, keep your site open in the background and render a smart button, which opens an “in context” payment window. This offers a much better payment experience.
See how to create a button for Plan approval here.
I think, the problem exists because you use "localhost" url. I had same issue and after test on online environment redirect works fine. Just try to redirect to different domain.
For local tests you can use https://ngrok.com/
Problem solved :
This will work using 127.0.0.1 instead of localhost
http://127.0.0.1/some_path
thanks me later 🙂