Background:
Working in a Django application, I have a template that performs an action (makes a payement) using an external API. The API call is done in Javascript.
On Success, the API returns a response
object. This works well on tests.
function makePayment(applicationAmount) {
let paymentEngine = RmPaymentEngine.init({
key: 'abcd'
firstName: '{{ user.f_name }}',
onSuccess: function(response) {
console.log('callback Successful Response', response);
// TODO: Add a function to post the payment records to the database
// response from the API contains a dictionary like (read json) object
// how can I get that response object in Python and use those response
// object values to update a django model database records
},
onError: function(response) {
console.log('callback Error Response', response);
// TODO: Add a function to throw an error message
},
onClose: function() {
console.log("closed");
}
});
}
Question:
How can I get that onSuccess
response
object variables in Python and use those response
object values to update a django model database records?
Looked at this link: How do I return the response from an asynchronous call? but can't seem to implement my need.
I'd be happy to be directed to a simple resource that explains the procedure, not something very involved that takes hours to understand.