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

本文介绍PayPal最新升级版本中提供的自定义支付体验功能,包括申请配置ID、设置品牌Logo及URL、允许填写备注等。同时介绍了如何通过设置使PayPal在支付过程中显示、隐藏或从买家账户获取物流地址。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值