Look at your initial post. You already had that in the callback. What I said is to remove the one from the end of the payWithPaystack function.
So you should have
<script>
function payWithPaystack(){
var handler = PaystackPop.setup({
key: '####',
email: '{{ auth()->check()?auth()->user()->email: null}}',
amount: '{{$prv->amount}}',
currency: "NGN",
ref: ''+Math.floor((Math.random() * 1000000000) + 1), // generates a pseudo-unique reference. Please replace with a reference you generated. Or remove the line entirely so our API will generate one for you
metadata: {
custom_fields: [
{
display_name: "Mobile Number",
variable_name: "mobile_number",
value: "+2348012345678"
}
]
},
callback: function(response){
alert('success. transaction ref is ' + response.reference);
document.myform.submit();
},
onClose: function(){
alert('window closed');
}
});
// document.myform.submit(); this should be removed.
handler.openIframe();
}
</script>
@bugsysha your reply which was me removing the document.myform.submit();
Was originally my initial code and which only submits on the payment platform and gives a flash message. NOTE it doesn't send a POST request to my controller and I needed it to.
What I did was I replaced the callback value with a document.myform.submit();.
You really did not understand what I was talking about.
I'm glad I got you laughing.🙂
@tomasosho to be honest I did not. I'm repeating one thing and you are repeating other. For some reason we do not understand each other fully. Sorry for that.
You should create a duplicate form, then pass the values of the original form to the duplicate form when the payment gateway is initiated. Then apply the submit method on the form duplicate inside the callback response.