Native SDK - iOS 接入指南
约 1002 字大约 3 分钟
2026-04-03
前置准备
在开始 iOS 接入之前,请确保已完成 Native SDK 概览 中的准备流程和服务端集成。
环境要求
| 项目 | 要求 |
|---|---|
| iOS 版本 | 15.6+ |
导入说明
手动集成
- 下载 SDK 的
.framework和PPCashDeskSDKBundle.bundle资源文件 - 将以上两个文件拖动到项目路径中
依赖项
Podfile 中需保证以下依赖项:
| 依赖库 | 版本 | 说明 |
|---|---|---|
| AFNetworking | 4.x | 网络请求 |
| SDWebImage | 5.x | 图片加载与缓存 |
| MJExtension | 3.x | JSON 与模型转换 |
| MJRefresh | 3.x | 下拉刷新与上拉加载 |
| Masonry | 1.x | 自动布局 |
| MBProgressHUD | 1.x | 加载提示 |
| Bugly | - | 错误监控 |
核心概念与交互时序
SDK 配置与关键对象
关键对象说明
| 类名 | 说明 |
|---|---|
| PPCDManager | SDK 主入口类,单例模式 |
| PPCDConfig | SDK 配置类 |
| PPPaymentRequest | 支付请求参数 |
| PPPaymentResult | 支付结果回调 |
环境配置
环境枚举:
PPCDEnvironmentType.h
typedef NS_ENUM(NSInteger, PPCDEnvironmentType) {
PPCDEnvironmentTypeRelease = 1, // 生产欧洲
PPCDEnvironmentTypeSandBox = 4, // 沙箱
PPCDEnvironmentTypeReleaseUS = 6, // 生产美国
};| 枚举值 | 值 | 说明 | API 端点 |
|---|---|---|---|
| PPCDEnvironmentTypeSandBox | 4 | 沙箱环境 | https://sandbox-acquirer-payment.pingpongx.com |
| PPCDEnvironmentTypeRelease | 1 | 生产环境-欧洲 | https://acquirer-payment.pingpongx.com |
| PPCDEnvironmentTypeReleaseUS | 6 | 生产环境-美国 | https://acquirer-payment-checkout-us.pingpongx.com |
配置示例:
PPCDConfig 初始化
PPCDConfig *config = [[PPCDConfig alloc] init];
config.environmentType = PPCDEnvironmentTypeSandBox; // 沙箱
// config.environmentType = PPCDEnvironmentTypeRelease; // 生产欧洲
// config.environmentType = PPCDEnvironmentTypeReleaseUS; // 生产美国关键接入步骤
步骤 1:初始化 SDK
AppDelegate.m
#import <PPCashDeskSDK/PPCashDeskSDK.h>
// 获取 SDK 实例
PPCDManager *manager = [PPCDManager sharedInstance];
// 配置 SDK
PPCDConfig *config = [[PPCDConfig alloc] init];
config.environmentType = PPCDEnvironmentTypeRelease; // 设置网络环境
config.shouldStartRecLog = YES; // 开启日志记录
config.cardBinLengthValue = 11; // 设置卡Bin位数长度
config.applePayMerchantId = @""; // 设置ApplePay的MerchantId,需要用户自行申请配置
manager.config = config;配置参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| environmentType | enum | PPCDEnvironmentTypeSandBox / PPCDEnvironmentTypeRelease |
| shouldStartRecLog | BOOL | 是否开启日志记录 |
| cardBinLengthValue | int | 设置卡Bin位数长度 |
| applePayMerchantId | String | 设置ApplePay的MerchantId,需要用户自行申请配置 |
步骤 2:唤起半屏支付
PaymentViewController.m
[manager initWithToken:@"your_token"
completed:^(NSString *code) {
// 支付成功回调
NSLog(@"支付流程完成: %@", code);
}
failure:^(NSError *error) {
// 支付失败回调
NSLog(@"支付流程失败: %@", error.localizedDescription);
}
cancel:^{
// 支付取消回调
NSLog(@"用户取消支付");
}];Apple Pay 配置
配置开发者账户
创建商家标识符:
- 登录 Apple 开发者中心,选择 "Merchant IDs"
- 输入唯一标识符(格式:
merchant.com.{app_name})
生成付款处理证书:
- 在开发者中心选择对应商家标识符,点击 "Create Certificate"
- 下载 CSR 文件(通过 Xcode 或终端生成),上传后获取
.cer证书文件
传入 Merchant ID:
ApplePay Merchant ID 配置
PPCDConfig *config = [[PPCDConfig alloc] init];
config.applePayMerchantId = @"merchant.com.yourapp";
manager.config = config;