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 @   jackchain  阅读(1204)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
历史上的今天:
2012-12-12 Sencha Touch 2 DataView / List 分页
点击右上角即可分享
微信分享提示