How Can I purchase multiple subscriptions by using just one button?

tbillen89
Contributor
Contributor

Hi guys,

 

I want to create two subscription with two plan_id (I tested it with one successfully). How do I have to change my code so that two subscription can start?

 

let plan_id = ['P-87175610EX683864NML6XXXX', 'P-6NT18915PW169903AML6XXXX'];
	
        // Render the PayPal button into #paypal-button-container        	
		paypal.Buttons({
			
            
			// Set up the transaction			
         	createSubscription: function(data, actions) {
				return actions.subscription.create({
			      'plan_id': plan_id[0]
			    });
			  },

            // Finalize the transaction
            onApprove: function(data, actions) {
				console.log("approve");
				console.log(data);
				console.log(actions);
                let js = {
					subscriptionID: data.subscriptionID,
					orderID: data.orderID,
					facilitatorAccessToken: data.facilitatorAccessToken,
					plan_id: plan_id
				}
				console.log(js);
            },

 

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.