支付paypal中的多个项目

时间:2016-06-03 07:28:29

标签: html paypal

我正在执行以下操作,将多个项目添加到Paypal但不起作用。没有添加任何项目。但是,如果我只添加一个项目而不添加附加" _1"," _2"到item_name等然后一切都很完美。在这种情况下,我做错了什么?

表格

<div id="DivForHoverItem"><p>Topic 1: Questions, puzzlement and what is okay</p>
<div id="HiddenText"><p>We begin to engage students in the ways of thinking and the pedagogical (or teaching) approach that underlie the Primary Ethics curriculum, as well as to build understanding about the behaviour expected in ethics classes.</p></div></div>

<div id="DivForHoverItem"><p>Topic 2: Secrets and a big, important question</p>
<div id="HiddenText"><p>We aim to foster students' developing capacity to make logical inferences and encourage and support students to think for themselves about the ethical question of whether or not it is okay to tell a friend's secret.</p></div></div>

<div id="DivForHoverItem"><p>Topic 3: Doing harm without meaning to</p>
<div id="HiddenText"><p>We encourage students to think for themselves about the difference between 'meaning' or intending to cause harm and causing harm 'accidentally' or without wanting to.</p></div></div>

结果

http://i.imgur.com/FYdsOpE.png

1 个答案:

答案 0 :(得分:0)

请检查Paypal Api文档中的所有必填字段。可能是缺少的东西。您应该在数据中包含一系列。物品(名称,货币,价格,数量)。您还应该有一个对象付款方(它是付款方式),重定向网址详细信息对象(税,运费) ,小计),金额对象(货币,总计),交易对象(说明,invoice_number,金额,项目)。我是在C#中做到的。你可以使用它可用的库。

  1. 在C#PayPal-NET-SDK
  2. 在PHP PayPal-PHP-SDK
  3. 其他请查看文档Payments API
  4. 选择最适合您项目的内容。它认为其中一个应该帮助你。

    这是C#中的一个示例

    using PayPal.Api;
    using System.Collections.Generic;
    
    namespace PayPal.Sample
    {
    public partial class PaymentWithCreditCard : BaseSamplePage
    {
        protected override void RunSample()
        {
            // ### 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. 
            // See [Configuration.cs](/Source/Configuration.html) to know more about APIContext.
            var apiContext = Configuration.GetAPIContext();
    
            // A transaction defines the contract of a payment - what is the payment for and who is fulfilling it. 
            var transaction = new Transaction()
            {
                amount = new Amount()
                {
                    currency = "USD",
                    total = "7",
                    details = new Details()
                    {
                        shipping = "1",
                        subtotal = "5",
                        tax = "1"
                    }
                },
                description = "This is the payment transaction description.",
                item_list = new ItemList()
                {
                    items = new List<Item>()
                    {
                        new Item()
                        {
                            name = "Item Name",
                            currency = "USD",
                            price = "1",
                            quantity = "5",
                            sku = "sku"
                        }
                    },
                    shipping_address = new ShippingAddress
                    {
                        city = "Johnstown",
                        country_code = "US",
                        line1 = "52 N Main ST",
                        postal_code = "43210",
                        state = "OH",
                        recipient_name = "Joe Buyer"
                    }
                },
                invoice_number = Common.GetRandomInvoiceNumber()
            };
    
            // A resource representing a Payer that funds a payment.
            var payer = new Payer()
            {
                payment_method = "credit_card",
                funding_instruments = new List<FundingInstrument>()
                {
                    new FundingInstrument()
                    {
                        credit_card = new CreditCard()
                        {
                            billing_address = new Address()
                            {
                                city = "Johnstown",
                                country_code = "US",
                                line1 = "52 N Main ST",
                                postal_code = "43210",
                                state = "OH"
                            },
                            cvv2 = "874",
                            expire_month = 11,
                            expire_year = 2018,
                            first_name = "Joe",
                            last_name = "Shopper",
                            number = "4877274905927862",
                            type = "visa"
                        }
                    }
                },
                payer_info = new PayerInfo
                {
                    email = "test@email.com"
                }
            };
    
            // A Payment resource; create one using the above types and intent as `sale` or `authorize`
            var payment = new Payment()
            {
                intent = "sale",
                payer = payer,
                transactions = new List<Transaction>() { transaction }
            };
    
            // ^ Ignore workflow code segment
            #region Track Workflow
            this.flow.AddNewRequest("Create credit card payment", payment);
            #endregion
    
            // Create a payment using a valid APIContext
            var createdPayment = payment.Create(apiContext);
    
            // ^ Ignore workflow code segment
            #region Track Workflow
            this.flow.RecordResponse(createdPayment);
            #endregion
    
            // For more information, please visit [PayPal Developer REST API Reference](https://developer.paypal.com/docs/api/).
        }
    }
    }