Subscriptions payment isn't working

ahmed_nasef
Contributor
Contributor

I have followed all the subscriptions integration steps in the docs, but when i try to test the cycle in sandbox with sandbox personal account i always get this message "Sorry, we weren’t able to set up preapproved payments at this time. Please return to the merchant and choose another way to pay."

 

I have tried the following solution:

  • Removing all extensions, clear my cache and cookies
  • Trying in other browsers and pc's
  • Set default payment method in the sandbox account profile and enabled auto payment

Does anyone know what is the cause of the problem?

 

Thanks in advance

Login to Me Too
3 REPLIES 3

MTS_Jennifer
Moderator
Moderator

Here are the steps to completing a subscription:

Get your Authorization Access_Token:

Create a Product: This is the endpoint: https://api.sandbox.paypal.com/v1/catalogs/products

JSON Request:

{
   "name": "Your Product",
   "description": "Whatever Description",
   "type": "SERVICE",
   "category": "SOFTWARE",
   "image_url": "https://example.com/streaming.jpg",
   "home_url": "https://example.com/home"
}

 

You are returned a Product ID and you will use this in your Create Plan Call. The one below is a sample only. You will receive your own.

Create Plan: Use this Endpoint: https://api.sandbox.paypal.com/v1/billing/plans

{
   "product_id": "PROD-66868863C24140122", 
   "name": "Your Product",
   "description": "Whatever Your Description",
   "billing_cycles": [
{
   "frequency": {
   "interval_unit": "MONTH",
   "interval_count": 1
},
   "tenure_type": "TRIAL",
   "sequence": 1,
   "total_cycles": 1
},
{
   "frequency": {
   "interval_unit": "MONTH",
   "interval_count": 1
},
   "tenure_type": "REGULAR",
   "sequence": 2,
   "total_cycles": 12,
   "pricing_scheme": {
   "fixed_price": {
   "value": "10",
   "currency_code": "USD"
}
}
}
],
   "payment_preferences": {
   "auto_bill_outstanding": true,
   "setup_fee": {
   "value": "10",
   "currency_code": "USD"
},
   "setup_fee_failure_action": "CONTINUE",
   "payment_failure_threshold": 3
},
   "taxes": {
   "percentage": "10",
   "inclusive": false
}
}

 

 

Create Subscription: This is the endpoint: https://api.sandbox.paypal.com/v1/billing/subscriptions

Make sure to create a start time in the future by 24 hours.

{
  "plan_id": "P-3SK50084F8836622GLZGFUKI",
  "start_time": "2020-02-19T06:00:00Z",
  "subscriber": {
  "name": {
  "given_name": "John",
  "surname": "Doe"
},
 "email_address": "buyersemail@mail.com"
},
  "application_context": {
  "brand_name": "Your Product",
  "locale": "en-US",
  "shipping_preference": "SET_PROVIDED_ADDRESS",
  "user_action": "SUBSCRIBE_NOW",
  "payment_method": {
  "payer_selected": "PAYPAL",
  "payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
},
  "return_url": "https://example.com/returnUrl",
  "cancel_url": "https://example.com/cancelUrl"
}
}

In the response you should be given a URL like this with a Billing Agreement Token Added: https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-{{restoftoken  }}

After you receive that URL with the correct Billing Agreement, make sure to log in with a personal sandbox account (not the seller account) that has at least a test credit card attached. Also make sure that the buyer account can process the currency that you are setting up. Some currencies are not available on every account.

Thank you,

Jennifer

PayPal

 

Login to Me Too

ahmed_nasef
Contributor
Contributor

Thanks a lot,

I've implemented product and plan creation and it works well and i can list my plans in the business account dashboard.

 

But for the subscription I'm using "Smart Payment Buttons" as it's recommended in the documentation and the problem comes here in the paypal secure browser, and i can't understand why

Login to Me Too

MTS_Jennifer
Moderator
Moderator

Hello,

Can you please comment your complete request including headers with no credentials?

Also can you please comment your sandbox merchant id?

 

I will review the request and see if there is a reason why the hosted page is loading.

 

Thank you,

Jennifer

PayPal

Login to Me Too

Haven't Found your Answer?

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