Paypal Rest Api自定义物流地址(跳过填写物流地址)

PayPal之前的Rest Api是不支持自定义物流地址的,最新升级版本的提供了这个服务(Payment Experience),大概步骤如下:

1.申请一个自定义的配置ID

  自定义配置包括Logo,Url,Shipping物流地址方案,允许填写备注等等

2.生成订单付款的时候,将该ID传送

示例代码在最新的SDK中都有Demo;如下:

一、Payment Experience Create

            var apiContext = Configuration.GetAPIContext();

            // Setup the profile we want to create
            var profile = new WebProfile()
            {
                name = Guid.NewGuid().ToString(),
                presentation = new Presentation()
                {
                    brand_name = "Sample brand",
                    locale_code = "US",
                    logo_image = "https://www.paypal.com/"
                },
                input_fields = new InputFields()
                {
                    address_override = 1,
                    allow_note = true,
                    no_shipping = 2
                }
                ,
                flow_config = new FlowConfig()
                {
                    bank_txn_pending_url = "https://www.paypal.com/",
                    landing_page_type = "billing"
                }
            };


            // Create the profile
            var response = profile.Create(apiContext);


            #region Cleanup
            // Cleanup by deleting the newly-created profile
            var retrievedProfile = WebProfile.Get(apiContext, response.id);
            retrievedProfile.Delete(apiContext);
            #endregion

InputFields.no_shipping:

// 摘要:
// Determines whether or not PayPal displays shipping address fields on the
// experience pages. Allowed values: `0`, `1`, or `2`. When set to `0`, PayPal
// displays the shipping address on the PayPal pages. When set to `1`, PayPal
// does not display shipping address fields whatsoever. When set to `2`, if
// you do not pass the shipping address, PayPal obtains it from the buyer's
// account profile. For digital goods, this field is required, and you must
// set it to `1`.

 

如何传递用户的ShippingAddress?

            ItemList itemList = new ItemList();
            itemList.items = itms;
            //设置运送地址
            ShippingAddress payaddress = new ShippingAddress();
            payaddress.city = temp.City + "," + temp.Province;

            payaddress.line1 = temp.Address1;
            payaddress.line2 = temp.Address2;
            payaddress.phone = temp.TelPhone;
            payaddress.postal_code = temp.PostalCode;
            payaddress.country_code = temp.Country;
            payaddress.recipient_name = temp.FirstName + " " + temp.LastName;

            itemList.shipping_address = payaddress;

posted @ 2014-12-12 10:59  jackchain  阅读(1198)  评论(0编辑  收藏  举报