PayGateSDK 1.0.4

PayGateSDK 1.0.4

许可协议 MIT
发布最后发布2016年4月

DuyKienNgo 维护。



  • Homedirect

PayGateSDK-IOS

PayGateSDK for IOS 提供了管理用户和允许在 Paydirect 系统上集成支付功能的最简单方式。SDK 为各种支付方式提供解决方案。PayGateSDK 支持 iOS 7.0 及以上版本。有关连接方式的具体信息,请联系 [email protected]

集成 SDK 的步骤

  1. 安装 PayGateSDK SDK

  2. 配置 SDK

  3. 集成

1. 安装 PayGateSDK

有几种方法可以将 PayGateSDK 添加到您的 Xcode 项目中。您可以使用 CocoaPods 或手动将 framework 和相关库添加到项目。

A. Cocoapod

Cocoapods 是在 iOS 应用程序中快速轻松地加载和更新 PayGateSDK 的最佳方式。只需更新 Podfile,然后使用以下命令调用 pod install

pod '‘PayGateSDK‘'

您可以在以下链接中查看使用说明
https://guides.cocoapods.org.cn/using/using-cocoapods.html

PayGateSDK 已经通过以下链接更新到 Cocoapods:https://cocoapods.org.cn/?q=PayGateSDK

B. 下载 PayGateSDK

您可以直接从上述提到的 git 仓库下载 PayGateSDK。将 PayGateSDK.framework 和 PayGateSDK.bundle 文件拖放到您的项目。

请勾选复选框:“如果需要,将项目复制到目标文件夹的文件夹中”。

2. 配置 SDK

SDK 通过 PayGateSDK 类初始化。可以通过 PayGateClient 调用 PayGateSDK。

#import <PayGateSDK/PayGateSDK.h>

在使用 SDK 之前,调用 Client 的安装函数(只调用一次):针对处于 sandbox 状态的应用程序

PayGateClient *payGateClient = [[PayGateClient alloc] initWithSandbox];

针对处于 publish 状态的应用程序

PayGateClient *payGateClient = [[PayGateClient alloc] initWithPartnerCode: partnerCode password:password secretKey:secretKey];

3. 集成卡服务

在 PayGateSDK 中,我们将集成 Topup 和 Buy Card 两种服务。PayGateSDK 提供 PDTopupPhoneViewController 和 PDBuyCardViewController 类,其中包含支付卡服务形式的完整界面。要集成到服务中的必要功能,您只需要调用在 PayGateClient 类中提供的相应函数。

Topup 服务

PDTopupPhoneViewController * pdTopupPhoneViewController = [[PDTopupPhoneViewController alloc] initWithPayGateClient:self.payGateClient transRef:[NSString randomTransRef]];

    pdTopupPhoneViewController.delegate = self;

    [self presentViewController:pdTopupPhoneViewController
                       animated:YES completion:nil];

BuyCard 服务

P PDBuyCardViewController * pdBuyCardViewController = [[PDBuyCardViewController alloc] initWithPayGateClient:self.payGateClient transRef:[NSString randomTransRef]];

    pdBuyCardViewController.delegate = self;

    [self presentViewController:pdBuyCardViewController
                       animated:YES completion:nil];

transRef 的值依次是账户参数和客户系统交易码。

此外,您还可以在 PayGateClient 类中使用以下函数

调用销售商购买卡的函数

/**
 *  topup API
 *
 *  @param PDVendor     Vendor
 *  @param price        Card's price
 *  @param quantity     Number of cards want to buy
 *  @param transId      Transaction id, generate from parter
 *  @param resultBlock  block to handle result
 */
- (void)buyCardWithVendor:(PDVendor)vendor
                    price:(NSNumber * _Nonnull)price
                 quantity:(NSNumber * _Nonnull)quantity
                  transId:(NSString * _Nonnull)transId
                completed:(_Nonnull PayGateBuyCardResultBlock)resultBlock;

获取交易状态

/**
 *  get Transaction Status/Code
 *
 *  @param transRef    Transaction reference id
 *  @param resultBlock block to handle resutl
 */
- (void)getTransactionResult:(NSString * _Nonnull)transId
                   completed:(_Nonnull PayGateTransactionResultBlock)resultBlock;

获取卡详细信息

/**
 *  get cards Infomation
 *
 *  @param transRef    Transaction reference id
 *  @param resultBlock block to handle resutl
 */
- (void)getCard:(NSString * _Nonnull)transId

获取销售商列表

/**
 *
 *  @return List of supported Vendors
 */
+ (NSArray * _Nonnull) supportVendors;