PayBy Payment Gateway integration SDK for ios with In-app pay scenes
- deviceId:every device has its own unique deviceId. UAT environment [joint debugging] fixed: deviceId123
- partnerId:every merchant is assigned a partnerId while applying for the payment service
- appId:every app of a merchant is assigned an appId while applying for the payment service
- token:it contains order information
- Sign:first, generate a singString by arranging deviceId、partnerId、appId、tokenn order.The rules are as follows:String signString ="iapAppId="+appId+ "&iapDeviceId=" + deviceId+ "&iapPartnerId=" + partnerId+"&token=" + token ;Second,sign the signString with privateKey, and the encryption rules can be seen in the demo.
Use Xcode 10 and above to use the new version of SLDPayByPayment SDK, ios 10.0 and above
[1] Build your project in XCode.
[2] To integrate SLDPayByPayment into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'SLDPayByPayment'
Save and execute pod install, then open the project with a file with the suffix .xcworkspace.
[3] In Xcode, select your project settings, select the "TARGETS" column, and add "URL scheme" to the "URL type" in the "info" tab bar for your registered application "payby" + id (As shown).
[4] In Xcode, select your project settings, select the "TARGETS" column, and add payby to "LSApplicationQueriesSchemes" in the "info" tab (As shown).
[5] In the file you need to use the PayBy terminal API #import <SLDPayByPayment/SLDPayByPayment.h>
.h header file.
#import <UIKit/UIKit.h>
#import <SLDPayByPayment/SLDPayByPayment.h>
@interface AppDelegate : UIResponder<UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Setting up the development environment
[SDLPayByPaymentInterface paymentEnvironment:SDLPaymentEnvironmentTest];
[SDLPayByPaymentInterface initInApp:appId partnerId:partnerId];
return YES;
}
SDLPaymentEnvironment Description:
- SDLPaymentEnvironmentDev:the environment for developing and testing.
- SDLPaymentEnvironmentTest:the environment for customer debuging.
- SDLPaymentEnvironmentRelease:the environment for product online.
Call methods in your class
[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"]
}];
Get The Payment Result AppDelegate adds proxy monitoring[below ios12]
- (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;
}
Add proxy monitoring to the project SceneDelegate[iOS13 or above]
- (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: the payee has received the payment successfully, and the entire payment process for the order is completed.
- FAIL: payment failed.
- PAID: the payer paid successfully. Wait for the payee to receive the payment, at the same time, you can also query and track the payment status of the order by order NO.
- PAYING: processing. Wait for the payment process to complete and return the final payment result.