4、添加按钮显示的代码
<div id="paypal-button-container"></div>
5、添加Paypal SDK调用代码,其中第13行金额的代码我帮大家改了,
复制即可使用
<!-- 引入 PayPal JavaScript SDK --><script src="https://www.paypal.com/sdk/js?client-id=test¤cy=USD"></script>
<script>// Render the PayPal button into #paypal-button-containerpaypal.Buttons({
// Set up the transactioncreateOrder: function(data, actions) {return actions.order.create({purchase_units: [{amount: {value: {{ product.price | divided_by: 100}}}}]});},
// Finalize the transactiononApprove: function(data, actions) {return actions.order.capture().then(function(details) {// Show a success message to the buyeralert('Transaction completed by ' + details.payer.name.given_name + '!');});}
}).render('#paypal-button-container');</script>
6、到PayPal开发者页面:https://developer.paypal.com/home/ 生成一个APP的客户端ID
7、把这个ID,替换到第5步代码中client-id=test的test部分(即等号后面的test删除,替换成你获取的ID)