Get Paypal transaction ID to post to form from OnApprove
KieranL33
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Mar-04-2021
04:10 AM
I have a paypal transaction set up with a smart button and I would like on approval following a redirect for the payment ID to be posted into my registration form. I can get it to redirect after the payment successfully but I cannot seem to get it to post the ID into the 'invoice' field.
Here is my working so far -
<script> function initPayPalButton() { paypal.Buttons({ style: { shape: 'rect', color: 'black', layout: 'vertical', label: 'buynow', }, createOrder: function(data, actions) { return actions.order.create({ purchase_units: [{"amount":{"currency_code":"USD","value":1}}] }); }, onApprove: function(data, actions) { return actions.order.capture().then(function(details) { window.location.replace("https://www.mywebsite.com/register"); document.getElementById("invoice").value=details.id; }); }, onError: function(err) { console.log(err); } }).render('#paypal-button-container'); } initPayPalButton(); </script>
And then my forms.py is set up as follows -
class UserRegisterForm(UserCreationForm): email = forms.EmailField() invoice = forms.CharField(max_length=50, widget= forms.TextInput(attrs={'id':'invoice'})) class Meta: model = User fields = ['email', 'invoice', 'password1', 'password2']
I should mention that the form is on the register page that I am redirecting to.
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.
Related Content
- how long does it take for paypal to activate Reference Transactions express checkout in PayPal Payments Standard
- [JS SDK] When I revise subscriptions the price shows incomplete in SDKs
- PayPal could you activate my reference transactions for my Shopify store please in REST APIs
- Does the merchant receive the payments instantly? in Payflow
- What are basic create-paypal-order and capture-paypal-order files? in REST APIs