本文介绍了如何将订单总计传递到贝宝中的(金额:{总计:'0.01',货币:'USD'})的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的asp.net网页上实现了paypal checkout快捷按钮.如何传递orderTotal总计:{总计:'0.01',货币:'USD'}.默认情况下,它是'0.01',我想显示实际的orderTotal.这是我的代码 paypal.Button.render({

I have implemented paypal checkout express button in my asp.net web page. how can i pass orderTotal to amount: { total: '0.01', currency: 'USD' }. by default it is '0.01' I want display actual orderTotal . This is my code paypal.Button.render({

                                                 env: 'sandbox', // sandbox | production

                                                 // PayPal Client IDs - replace with your own
                                                 // Create a PayPal app: https://developer.paypal.com/developer/applications/create
                                                 client: {
                                                     sandbox: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
                                                     //production: 'AVSYgEO5SUewyQ_We4dW5uCXyEZHgcFDfKK15gCqsd7o0edVH5UOhtHK7n2uqkFQOYtjJt0vvemfgNwg'
                                                 },

                                                 // Show the buyer a 'Pay Now' button in the checkout flow
                                                 commit: true,

                                                 // payment() is called when the button is clicked
                                                 payment: function (data, actions) {

                                                     // Make a call to the REST api to create the payment
                                                     return actions.payment.create({
                                                         payment: {
                                                             transactions: [
                                                            {
                                                                amount: { total: '0.01', currency: 'USD' }
                                                            }
                                                             ]
                                                         }
                                                     });
                                                 },
                                                 commit: true,
                                                 // onAuthorize() is called when the buyer approves the payment
                                                 onAuthorize: function (data, actions) {
                                                     // Make a call to the REST api to execute the payment
                                                     return actions.payment.execute().then(function () {
                                                         //window.alert('Payment Complete!');
                                                         onPaypalAuthorize();
                                                     });
                                                 }

                                             }, '#paypal-button-container');

推荐答案

取决于您使用的是Forms还是MVC.

Depending whether you are using Forms or MVC.

对于Web表单,您可以使用内联指令<% =MyTotal %>您想要的总数.

For web forms you can use the inline directive<% =MyTotal %> where you would like the total.

使用MVC@ model.MyTotal可以在MyTotal是您要传递给Paypal的总数的地方工作.

With [email protected] would work where MyTotal would be the total you would like to pass to paypal.

例如,WebForms

For example, WebForms

amount: { total: <% =MyTotal %>, currency: 'USD' }

MVC

amount: { total: @Model.MyTotal, currency: 'USD' }

需要指出的几件事.总数必须是一个字符串,并且需要四舍五入到小数点后两位.如果您这样做失败,它将重新启动并出错.

A couple of things that need to be pointed out. The total needs to be a string, and it needs to be rounded to two decimal points. If you fail to do this, it will kick back and error.

这篇关于如何将订单总计传递到贝宝中的(金额:{总计:'0.01',货币:'USD'})的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 21:40