PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 4, 2022

[FIXED] how to implement paypal suspend subscription on reactjs

 July 04, 2022     paypal, paypal-rest-sdk     No comments   

Issue

Hi i've been using paypal's sample code but adapted with react-paypal-js.

I'm wondering if there is an example for suspend subscription?

There doesn't seem to be an equivalent suspendSubscription? I tried looking at subscription API but not sure how to adapt that here. Thanks!

 <PayPalButtons
              createSubscription={(data, actions) => {
                return actions.subscription
                  .create({
                    /* Creates the subscription */
                    plan_id: 'P-xx',
                    quantity: subscriptionCount, // The quantity of the product for a subscription
                  })
                  .then((orderId) => {
                    // Your code here after create the order
                    console.log("order id created ", orderId)
                    return orderId;
                  });
              }}
              
              onApprove={(data, actions) => {
                console.log('approved data! ', data);
              }}
            />

Solution

Suspending a subscription is done with server API calls, so reactjs is not relevant.

See the Subscriptions documentation, which gives an example in curl format

curl -v -X POST https://api-m.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/suspend
-H "Content-Type: application/json" 
-H "Authorization: Bearer <Access-Token>" 
-d '{
  "reason": "Customer-requested pause"
}'

(There is no SDK for Subscriptions API operations; use direct HTTPS API calls with an oauth2 access token)



Answered By - Preston PHX
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing