SLDPayByPayment 1.0.1

SLDPayByPayment 1.0.1

payby2020 维护。



  • bing

PayBy-inApp-iOS

PayBy Payment Gateway 集成 SDK,适用于 ios,包含应用内支付场景

术语定义

  • deviceId:每个设备都有自己的唯一 deviceId。UAT 环境联合调试修复:deviceId123
  • partnerId:在申请支付服务时,每个商家都会分配一个 partnerId
  • appId:在申请支付服务时,每个商家应用的appId都会分配appId
  • token:它包含订单信息
  • Sign:首先,通过按照 deviceId、partnerId、appId、token 的顺序生成 singString。规则如下:String signString = "iapAppId="+appId+ "&iapDeviceId=" + deviceId+ "&iapPartnerId=" + partnerId+"&token=" + token ;然后,使用 privateKey 对 signString 进行签名,加密规则可以在示例中查看。

适用版本

使用 Xcode 10 及以上版本来使用 SLDPayByPayment SDK 的新版本,iOS 10.0 及以上版本

安装

使用CocoaPods进行安装

[1] 在XCode中构建您的项目。

[2] 要使用CocoaPods将SLDPayByPayment集成到您的Xcode项目中,请在您的Podfile中指定它:

  pod ‘SLDPayByPayment'

保存并执行pod install,然后使用带有.xcworkspace后缀的文件打开项目。

[3] 在Xcode中,选择您的项目设置,选择“TARGETS”列,并在“info”标签栏中为您的“payby”应用程序+ id(如图所示)添加“URL scheme”。Image text

[4] 在Xcode中,选择您的项目设置,选择“TARGETS”列,并在“info”标签中添加“LSApplicationQueriesSchemes”中的“payby”(如图所示)。Image text[5] 在您需要使用PayBy终端API的文件中导入.h头文件:i_h header文件。

#import <UIKit/UIKit.h>
#import <SLDPayByPayment/SLDPayByPayment.h>

@interface AppDelegate : UIResponder<UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

使用说明

初始化SDK(必需)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  //Setting up the development environment
   [SDLPayByPaymentInterface paymentEnvironment:SDLPaymentEnvironmentTest];
   [SDLPayByPaymentInterface initInApp:appId partnerId:partnerId];
    return YES;
}

在您的类中调用方法

[SDLPayByPaymentInterface requestInApp:token DeviceId:deviceId Sign:sign PageOnViewContorller:self success:^(id  _Nonnull result) {
            ;//H5 payment results directly returned
        } fail:^(NSError * _Nonnull error) {
            ;//Order creation failed Error message. error.userInfo[@"errorInfo"]
        }];

获取支付结果AppDelegate增加代理监控[以下iOS 12]

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
   
   NSURLComponents *components = [[NSURLComponents alloc] initWithString:url.absoluteString];
   for(NSURLQueryItem *info in components.queryItems){
       if([info.name isEqualToString:@"result"]){
           NSLog(@"result = %@",info.value);
                             break;
       }
   }
   return YES;
   
}

将代理监控添加到项目SceneDelegate[iOS 13或更高版本]

- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts API_AVAILABLE(ios(13.0)){
   
   for (UIOpenURLContext *obj in URLContexts) {
       NSURL *tempUrl = obj.URL;
       if([tempUrl.absoluteString hasPrefix:@"payby"]){
          NSURLComponents *components = [[NSURLComponents alloc] initWithString:tempUrl.absoluteString];
          for(NSURLQueryItem *info in components.queryItems){
              if([info.name isEqualToString:@"result"]){
                  NSLog(@"result = %@",info.value);
                             break;
              }
          }
           break;;
       }
   }
}

支付结果代码描述

  • SUCCESS: 收款方已成功收到付款,订单的整个支付流程已完成。
  • FAIL: 支付失败。
  • PAID: 付款方已成功付款。等待收款方收到付款,同时,您也可以通过订单号查询和跟踪订单的支付状态。
  • PAYING: 处理中。等待支付流程完成并返回最终支付结果。