を使用して、次のような確認アラートを作成しようとしてPhonegap notification
います: 本当に購入しますか? はい・いいえ。したがって、はいを押すと、サンドボックスの Paypal Web に移動します。いいえを押すと、同じページにいます。
問題は、フォームのアクションを変更してサンドボックスのペイパル ページを呼び出すことができないことです。
から変更すると、<form action="htpp:sandobox...">
正しく機能しません。サンドボックスの購入ページではなく、主要なペイパル ページを読み込みます。
これは私のコードです。
function onConfirm(button){
alert("button="+button);
if(button==2){
return false;
}else{
if(button==1){
document.form.action="https://www.sandbox.paypal.com/cgi-bin/webscr";
return true;
}
}
}
function openPaypal(){
navigator.notification.confirm(
'Pressing Yes will continue to the final part of the order, you will not be able to come back from this point.', // mensaje (message)
onConfirm, // función 'callback' a llamar con el índice del botón pulsado (confirmCallback)
'Personalised Playing Cards: Are you sure?', // titulo (title)
'Yes,Cancel' // botones (buttonLabels)
);
}
<form name="formulario" id="formulario" action="" method="post" onSubmit="return openPaypal()">
<!-- Indica que vamos a hacer una compra tipo boton comprar ahora -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Indica que no se presente un campo para notas extras -->
<input type="hidden" name="no_note" value="1">
<!-- la moneda correspondiente -->
<input type="hidden" name="currency_code" value="GBP">
<input type="image" src="../images/confirmbutton-passive.png" id="button1" style="width:100%; margin: 0px auto;" border="0" name="submit" alt="Comprar" title="Comprar">
</form>