1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
| <form action="" method="post" name="liste">
<select name="size" id="select" style="width:100px" Onchange="javascript:SelectValueChamp();">
<?php
$nombre = 150;
$est_divisible_par = 10;
//echo "<select>";
echo "<option selected value='' >Choisissez</option>";
for ($x = 0; $x <= $nombre ; $x++) {
if($x % $est_divisible_par === 0)
{
//echo "The number is: $x <br>";
if ($x != 0) echo "<option value=$x.00 >$x</option>";
}
}
echo "</select>";
?>
<input type="text" name="item_number" value=""><br>
<span id="current"></span>
</form>
<div id="paypal-button"></div>
<script>
document.getElementById("current").innerHTML = "Choisissez le montant que vous souhaitez regler." ;
var somme="1.00";
function showSelectedItem() {
//var somme="1.00";
var item = document.getElementById("select").value;
document.forms['liste'].elements['item_number'].value=item;
traitementSomme(item);
document.getElementById("current").innerHTML = "Vous avez choisi de regler " + item + " " ;
}
function traitementSomme(somme) {
// utiliser la valeur ici
console.log(somme);
}
var somme = console.log(somme);
document.getElementById("select").addEventListener("change", showSelectedItem);
var CURRENCY = 'EUR';
var SUBTOTAL = somme;
var TAX = '0.00';
var SHIPPING = '0.00';
var SHIPPING_DISCOUNT = '0.00';
var TOTAL = somme;
paypal.Button.render({
env: 'sandbox', // Or 'sandbox',
commit: true, // Show a 'Pay Now' button
client: {
sandbox: 'AMlXKb0P7rQnsdfgsdfgsdfgsdfgsdfgobGFnOt45U-RQB5ue9g69F9XF7bPaC6WiOUWVmGu738ZI9XrNWUvwFTisoZrn'
},
style: {
label: 'paypal',
size: 'small',
shape: 'rect',
color: 'blue'
},
// Set up the payment here
payment: function (data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: {
total: TOTAL,
currency: CURRENCY,
details: {
subtotal: SUBTOTAL,
tax: TAX,
shipping: SHIPPING,
shipping_discount: SHIPPING_DISCOUNT
}
},
//description: 'The payment transaction description',
description: 'Détail de votre transaction:',
// invoice_number: '48787589673',
item_list: {
items: [
{name: 'Règlement partiel du site', quantity: '1', price: somme, currency: CURRENCY},
]
}
}
],
note_to_payer: 'Contactez moi pour toute question concernant ce règlement.'
}
});
},
// Execute the payment here
onAuthorize: function (data, actions) {
return actions.payment.execute().then(function (payment) {
// The payment is complete!
// Get payer info
var payer = payment.payer.payer_info;
console.log("Email: " + payer.email);
console.log("Name: " + payer.first_name + ' ' + payer.last_name);
// Get payment info
console.log("Id: " + payment.id);
console.log("Intent: " + payment.intent);
console.log("State: " + payment.state);
document.location.href="http://www.mondomaine-approved.com?etat=";
});
//});
},
onCancel: function (data, actions) {
/*
* Buyer cancelled the payment
*/
console.log('Payment was cancelled!');
//window.alert('Payment was cancelled!');
document.location.href="http://www.mondomaine-cancelled.com";
},
onError: function (err) {
/*
* An error occurred during the transaction
*/
console.log(err);
window.alert('There was an error');
}
}, '#paypal-button');
//showSelectedItem();
</script> |
Partager