dashed-slug.net › Forums › General discussion › examples of withdraw php-api › Reply To: examples of withdraw php-api
April 10, 2019 at 9:04 am
#6115
alexg
Keymaster
It would be hard to achieve what you ask with knockout templates, this is why I suggested using a standard HTML form and some simple JavaScript.
The JSON API call, using jQuery would be:
$.ajax({
dataType: 'json',
data: {
'__wallets_apiversion' : 3
'__wallets_action' : 'do_withdraw',
'__wallets_withdraw_address' : address,
'__wallets_symbol' : symbol,
'__wallets_withdraw_amount' : amount,
'__wallets_withdraw_comment' : comment,
'__wallets_withdraw_extra' : extra,
'_wpnonce' : wp.wallets.viewModels.wallets.nonces()['do_withdraw']
},
success: function( response ) {
$( form ).trigger( 'wallets_do_withdraw', [
response,
symbol,
amount,
address,
comment,
extra
] );
error: function() {
alert( 'Withdrawal not submitted' );
}
});
Just make sure to attach this to whatever button your form has, and pass the variables in from the form.
Hope this is a bit more clear. The rest is just standard html/javascript.
with regards