I need integrate paypal subscriptions to my project. I use new paypal subscriptions api https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions and need to know how i can identify payer and my own db user.
Here is scenario in my mind:
- I create my own db user with signup form.
- I set my own user id to paypal api call
- After user confirm subscription paypal return me subscriptions id, then i call paypal api to get details of returned subscription and see my own db user id
But looks like paypal cant provide it.
here is my smart checkout button code
paypal.Buttons({
style: {
layout: 'horizontal',
size: 'small',
color: 'blue',
label: 'pay',
height: 55,
tagline: 'false'
},
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'P-5GS67390M7258253CLUHXAHQ',
'metadata' : {
'user_id' : 'myuserid'
}
});
},
onApprove: function(data, actions) {
console.log(data);
alert('You have successfully created subscription ' + data.subscriptionID);
}
}).render('#paypal-button-container');
</script>
I found only one way how i can do it
- User insert all data to signup form and then click on paypal button
After success paypal payment on
onApprove: function(data, actions) { $('#myform').append('<input name="subscriptions_id" value="data.subscriptionID"') $('#myform').submit() alert('You have successfully created subscription ' + data.subscriptionID); }
What is the best way to add subscriptions id for mysql db user?