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.
... View more