• 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;

  • 相关阅读:
    bash的for循环从命令读取值
    BFS-hdu-1226-超级密码
    计算机改名导致数据库链接的诡异问题
    There is insufficient system memory to run this query 错误
    SQL Server 2008 R2的发布订阅配置实践
    MS SQL 日常维护管理常用脚本(二)
    TreeSize工具介绍
    迁移Reporting Services的方法与WMI错误
    spring-session-data-redis解决session共享的问题
    elasticSearch6源码分析(12)DiscoveryModule
  • 原文地址:https://www.cnblogs.com/qidian10/p/4159263.html
Copyright © 2020-2023  润新知