asp.net中具有PayPal付款功能的未验证结帐

时间:2018-09-15 12:12:56

标签: paypal

我正在尝试将带Paypal的支付功能集成到我的APS.NET网站中。 我发现了这个例子LINK 这看起来不错,网站正在调用PayPal网站进行登录,指定我的付款并要付款。如果我单击向前付款,浏览器将显示结帐错误“未验证的结帐”。在这种情况下怎么了? 在哪里可以找到问题?

        public static Payment CreatePayment(string baseUrl, string intent)
    {
        // ### Api Context
        // Pass in a `APIContext` object to authenticate 
        // the call and to send a unique request id 
        // (that ensures idempotency). The SDK generates
        // a request id if you do not pass one explicitly. 
        var apiContext = PayPalConfiguration.GetAPIContext();

        // Payment Resource
        var payment = new Payment()
        {
            intent = intent,    // `sale` or `authorize`
            payer = new Payer() { payment_method = "paypal" },
            transactions = GetTransactionsList(),
            redirect_urls = GetReturnUrls(baseUrl, intent)
        };

        // Create a payment using a valid APIContext
        var createdPayment = payment.Create(apiContext);

        return createdPayment;
    }

    private static List<Transaction> GetTransactionsList()
    {
        // A transaction defines the contract of a payment
        // what is the payment for and who is fulfilling it. 
        var transactionList = new List<Transaction>();

        // The Payment creation API requires a list of Transaction; 
        // add the created Transaction to a List
        transactionList.Add(new Transaction()
        {
            description = "Transaction description.",
            invoice_number = GetRandomInvoiceNumber(),
            amount = new Amount()
            {
                currency = "EUR",
                total = "10.00",       // Total must be equal to sum of shipping, tax and subtotal.
                details = new Details() // Details: Let's you specify details of a payment amount.
                {
                    tax = "0",
                    shipping = "0",
                    subtotal = "10"
                }
            },
            item_list = new ItemList()
            {
                items = new List<Item>()
        {
            new Item()
            {
                name = "Item Name",
                currency = "EUR",
                price = "10.00",
                quantity = "1",
                sku = "sku"
            }
        }
            }
        });
        return transactionList;
    }

0 个答案:

没有答案