Search code examples
paypalpaypal-sandboxpaypal-subscriptions

PayPal subscription payments seems to be unclaimed


I want to create a subscription and immediately charge customer on approval. I am using PayPal Rest API for creating a subscription. It is axiomatic that paypal needs user authentication for transactions so i am redirecting the user to the approval URL, which in my case can be retrieved by

// axios response
subscription.data.links.find(v => v.rel == 'approve').href 

Now on the return URL after approving i am fetching the subscription details and it's transactions where I see, subscription is activated but payment is UNCLAIMED and in dashboard of the sandbox account i can see the payment is pending and subscription is active

Subscription details after redirecting to return_url

{
  status: 'ACTIVE',
  status_update_time: '2020-10-05T09:46:38Z',
  id: 'I-CFNDNP7NB53C',
  plan_id: 'P-8VN9595625142693PL55KTVA',
  start_time: '2020-10-04T23:00:00Z',
  quantity: '1',
  shipping_amount: { currency_code: 'USD', value: '0.0' },
  ...
}

Payment details after redirecting to return_url

{
  transactions: [
    {
      status: 'UNCLAIMED',
      id: '884510049W6870025',
      amount_with_breakdown: [Object],
      payer_name: [Object],
      payer_email: '[email protected]',
      time: '2020-10-05T09:42:40.000Z'
    }
  ],
  ...
}

Screenshots from dashboard

enter image description here

enter image description here

Subscription configuration

var subscriptioConfig = {
    plan_id: variant.paypalId,
    subscriber: {
        name: {
            given_name: name.slice(0, name.length - 1).join(" "),
            surname: name.reverse()[0],
        },
        email_address: billingDetail.email,
    },
    application_context: {
        brand_name: "IODINE",
        shipping_preference: "NO_SHIPPING",
        user_action: "SUBSCRIBE_NOW",
        payment_method: {
            payer_selected: "PAYPAL",
            payee_preferred: "IMMEDIATE_PAYMENT_REQUIRED",
            standard_entry_class_code: "WEB",
        },
        cancel_url: `${process.env.BACKEND}/api/plan/paypal-subscribe/fail?${qp}`,
        return_url: `${process.env.BACKEND}/api/plan/paypal-subscribe/approve?${qp}`,
    },
    plan: {
        billing_cycles: [],
        payment_preferences: {
            auto_bill_outstanding: true,
            payment_failure_threshold: 3,
        },
    },
};

Solution

  • The payment is pending because the receiver account doesn't hold a balance in that currency, and by default PayPal accounts are set up so that new currency payments must be manually accepted, denied, or converted to your primary currency balance.

    Once you accept the payment and thus open a balance in that currency, future payments in this currency won't be pending.