# 5.渠道专属配置
## 5.1 EB渠道
* 渠道专属配置:

  ```xml
  
  1.将allpaysdk/WXModule文件夹下的文件add到项目中
  
  2.Set Always embed swift standard libraries to YES from project build settings 
  
  ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
  
  3.To simply disable ATS, you can follow this steps by open Info.plist, and add 	the following lines:
    <key>NSAppTransportSecurity</key>
    <dict> <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
  ```


* 消费接口专属字段

请求报文

	

 序号 |名称  |长度|类型|参数名称|备注 
 -----|-----|----|----|------|------
  1| 姓名     |32  |文本|trxn_firstname         |This is name of the customer who is doing the transaction. 
  2| 邮箱     |40  |文本|trxn_email_id         |this is email id of the customer who is doing transaction.
  3|电话 |20  |文本|trxn_phone|Phone number of the customer.
  4|优惠券选项 |1  |文本|trxn_is_coupon_enabled| If the value is 0 then customer will not be able to see the coupons. If the value is 1 then customer will be able see the coupons and able to select the coupons
  5|客户id |10  |文本|unique_id|This is customer’s unique id.不能超过10位

## 5.2 WX渠道
* 渠道专属配置:
1. 将allpaysdk/EBModule文件夹下的文件add到项目中
2. 项目设置APPID
商户在微信开放平台申请开发APP应用后,微信开放平台会生成APP的唯一标识APPID。在Xcode中打开项目,设置项目属性中的URL Schemes为您的APPID 如图标红位置所示

![image](/b2c/ios_wx_01.jpg)
3. 导入下面框架和链接库

   ```objective-c
   Security.framework
   CoreTelephony.framework
   SystemConfiguration.framework
   libc++.tbd
   libz.tbd
   libsqlite3.tbd
   ```

4. 在“Info.plist”中将要使用的 URL Schemes 列为白名单 

   ```xml
   <key>LSApplicationQueriesSchemes</key>
   <array>
   <string>weixin</string>
   </array>
   <key>NSAppTransportSecurity</key>
   <dict>
   <key>NSAllowsArbitraryLoads</key>
   <true/>
   </dict>
   
   ```


## 5.3 APMP渠道

- 消费接口专属字段

请求报文

| Parameter | Type       | Required | Description                                                  | Sample                                 |
| --------- | ---------- | -------- | ------------------------------------------------------------ | -------------------------------------- |
| timeout   | String(10) | O        | The default is 12h. Please contact Alipay Technical Support if you need to use other values. Max value is 15d. This parameter controls the valid time from login to completion. | 5m 10m 15m 30m 1h 2h 3h 5h 10h 12h 1d. |

* 渠道专属配置:
1. 将allpaysdk/AliModule文件夹下的文件add到项目中

2. 在Build Phases选项卡的Link Binary With Libraries中,增加以下依赖:

   ```objective-c
   libc++.tbd
   libz.tbd
   SystemConfiguration.framework
   CoreTelephony.framework
   QuartzCore.framework
   CoreText.framework
   CoreGraphics.framework
   CFNetwork.framework
   CoreMotion. .framework    
      
   ```

3. 点击项目名称,点击“Info”选项卡,在“URL Types”选项中,点击“+”,在“URL Schemes”中输入alipay, , 如图标红位置所示

![image](/b2c/ios_wx_01.jpg)

## 5.3 UP渠道
* 渠道专属配置:

1. 将allpaysdk/UPModule文件夹下的文件add到项目中

2. 导入下面框架和链接库

   ```objective-c
   CFNetwork.framework
   SystemConfiguration.framework
   libz.tbd    
   ```

3. 在工程info.plist设置中添加一个URL Types回调协议,用于在支付完成后返回商户客户端。请注意URL Schemes需要是唯一的,。 设置的Scheme的值要和支付接口中参数scheme的值相同。

4. 需要在工程对应的plist文件中,添加LSApplicationQueriesSchemes  Array并加入uppaysdk、uppaywallet、uppayx1、uppayx2、uppayx3五个item 

   ```xml
   <key>LSApplicationQueriesSchemes</key> 
   <array>
   <string>uppaysdk</string> 
       <string>uppaywallet</string>
       <string>uppayx1</string> 
       <string>uppayx2</string> 
       <string>uppayx3</string> 
   </array>
   ```

5. http请求设置(ats) 

   在测试环境测试时,需要在工程对应的plist文件中添加NSAppTransportSecurity  Dictionary 并同时设置里面NSAllowsArbitraryLoads 属性值为 YES,发生产环境可删除此设置。向Apple发布正式版本时请删除此设置。

## 5.4 Apple Pay渠道
* 渠道专属配置:
1. 将allpaysdk/AppleModule文件夹下的文件add到项目中
2. xcode 打开 apple pay 功能,如下图
   
![image](/b2c/apple_pay_set.png)

3. 用户 app 判断手机是否支持 Apple Pay 功能,以及是否已加载有可用的支付卡片 

   ```objective-c
   //判读方法为:
   if([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkChinaUnionPay]] )
   {
   // app 展示 apple pay 支付图标 
   }
   
   
   ```