File: /www/wwwroot/www.baofufacai.com////2.php
<!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://www.paypalobjects.com/api/checkout.js?components=buttons"></script>
</head>
<body>
产品名称<br>
价格:10$ <br>
<div id="paypal-button" style="margin-top:100px;"></div>
<script>
paypal.Button.render({
locale: 'zh_CN', //语言
env: 'production', //生成环境还是沙盒环境
commit: true,
client: {
sandbox: 'AUM51Ny6aVSUH0eP4bUHk3L_J68yPVAeMWoxlVZSTMLxtYoohKhFHvi4G1HwaST8bo44D3Ym19XJhLz0',
production: 'AUM51Ny6aVSUH0eP4bUHk3L_J68yPVAeMWoxlVZSTMLxtYoohKhFHvi4G1HwaST8bo44D3Ym19XJhLz0'
},
style: {
// size: 'small',
// color: 'silver',
// shape: 'pill',
// label: 'checkout',
// tagline: false
layout: 'vertical',
// size: 'small',
color: 'gold',
shape: 'rect',
label: 'paypal'
},
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '180', currency: 'USD' }
}
]
}
});
},
onAuthorize: function(data, actions) {
console.log(data);
return actions.payment.execute().then(function(payment) {
$.ajax({
type: 'POST',
url: '/',
data: {}
}).done(function (data) {
if (data == '0') {
alert('支付完成!');
window.location.reload();
}else {
alert('支付失败')
}
})
});
},
onCancel: function(data, actions) {
// 买家取消了支付触发
// TODO
},
onError: function(err) {
// 当交易发生错误时触发
// TODO
}
}, '#paypal-button');
</script>
</body>