I would like to put php syntax into the javascript payment completion function.
1. This is a JavaScript code that will run when your online payment is finalized.
<script>
......
function(rsp) {
if ( rsp.success ) {
var msg = 'payment success';
msg += 'Store ID : ' + rsp.imp_uid;
msg += 'Store deal ID : ' + rsp.merchant_uid;
msg += 'Price : ' + rsp.paid_amount;
msg += 'Card Authorization Number : ' + rsp.apply_num;
} else {
var msg = 'Billing failed.';
msg += 'Error reason : ' + rsp.error_msg;
}
alert(msg);
}
</script>
2. This is the php code that adds the user's credits once the payment is successfully completed.
<?php $user_wallet->balance = $user_wallet->balance + $paid_amount;?>
I want to put this code inside script section like this.
if ( rsp.success ) {
<?php $user_wallet->balance = $user_wallet->balance + $paid_amount;?>
}
But the php syntax does not work in the script section. How do I solve this problem?