注意:此存储库提供的框架仅支持iOS 8.0及以上版本。如果需要支持iOS 7.0,请访问此存储库以使用静态库方法。
转到存储库发布部分,从最新版本下载GetSimpl.framework.zip文件,解压它以获取最新的框架文件。
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
// smp + YourMerchantID, like; smp55d72761ec60ytbnk97414182
<string>smpYourMerchantID</string>
</array>
</dict>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>simplApp</string>
</array>
//Objective-C
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation: (id)annotation
{ if ([[GSCallBackHandler sharedInstance] canHandleURL:url]) {
return [[GSCallBackHandler sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation] ;
}
return YES;
}
//Swift
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
{
if GSCallBackHandler.sharedInstance.canHandleURL(url) {
return GSCallBackHandler.sharedInstance.application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
return true
}
//Objective-C
[GSManager enableSandBoxEnvironment:YES]
//Swift
GSManager.enableSandBoxEnvironment(true)
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
这是为了绕过App Store发布前的bug,该bug要求在提交到App Store之前,iOS框架二进制文件必须从模拟器切片中移除。有一个bug报告: Xcode 6.1.1 & 6.2:包含模拟器切片的iOS框架不能提交到App Store以及Realm#1163和Carthage#188上的长期讨论。
//Objective-C
#import <GetSimpl/GetSimpl.h>
//Swift
import GetSimpl
//Objective-C
[GSManager initializeWithMerchantID@:@"Your merchant id"];
//Swift
GSManager.initializeWithMerchantID("Your merchant id")
//Objective-C
GSUser *user = [[GSUser alloc] initWithPhoneNumber:@"user mobile number" email:@"user email"];
[[GSManager sharedManager] checkApprovalForUser:user onCompletion:^(BOOL approved, BOOL isFirstTransactionOfUser, NSString *buttonText ,NSError *error) {
}]
//Swift
let user : GSUser = GSUser(phoneNumber :"user mobile number" email:@"user email")
GSManager.sharedManager.checkApprovalForUser(user){(approved:Bool,isFirstTransactionOfUser:Bool,buttonText : String?,error:NSError?)
}
Bool approved : If GSUser is pre-approved or not
Bool isFirstTransactionOfUser : If user has already done transactions previously or not
String/NSString buttonText : The text to display on Simpl button. If GSUser is pre-approved,this will contain a value specific to merchant with default value of "Buy Now, Pay Later". Will be nil if GSUser is not pre-approved.
NSError error : Error if any
如果用户已批准并且在商户应显示Simpl按钮的情况下,如果用户不是已批准用户,则不要显示Simpl按钮。
//Objective-C
GSUser *user = [[GSUser alloc] initWithHashedPhoneNumber:@"hashed value of user phone number"];
user.extraParams = @{@"wallet_balance_in_paise" : @30000,@"transaction_amount_in_paise" : @20000};
[[GSManager sharedManager] checkApprovalForUser:user onCompletion:^(BOOL approved, BOOL isFirstTransactionOfUser, NSString *buttonText ,NSError *error) {
}]
//Swift
let user = GSUser(hashedPhoneNumber: "hashed value of user phone number")
user.extraParams = ["wallet_balance_in_paise" : 30000,"transaction_amount_in_paise" : 20000]
GSManager.sharedManager.checkApprovalForUser(user){(approved:Bool,isFirstTransactionOfUser:Bool,buttonText : String?,error:NSError?)
}
extraParams -> Extra properties of GSUser to be set as Key-Value pairs.Example of some keys are transaction_amount_in_paise, wallet_balance_in_paise,failed_transaction_bank_name,user_location,theatre_location,member_since, signed_in , etc.
This property has been provided so that merchants can provide additional parameters for real-time approval without upgrading the SDK.
如果商户使用hashedPhoneNumber进行预批准检查,则上述键将用于对用户提供实时批准,前提是商户在服务器端启用了实时配置。
//Objective-C
/// Button background color. Defaults to Simpl branding color
@property (nonatomic, strong) UIColor *buttonColor;
/// Button border color. Defaults to Black Color with 10% alpha
@property (nonatomic, strong) UIColor *buttonBorderColor;
/// Title text of button. Defaults to "Buy Now, Pay Later"
@property (nonatomic, copy) NSString *titleText;
/// Title Color of Button. Defaults to White color
@property (nonatomic, strong) UIColor *titleColor;
/// Font of button
@property (nonatomic, strong) UIFont *titleFont;
/// Text color of "Powered by Simpl" text. Defaults to R94 G107 B125 A1
@property (nonatomic, strong) UIColor *poweredByTextColor;
/// Separator line color. Defaults to Black Color with 8% alpha
@property (nonatomic, strong) UIColor *separatorColor;
//Objective-C
GSUser *user = [[GSUser alloc] initWithPhoneNumber:@"user mobile number" email:@"user email"];
GSTransaction *transaction = [[GSTransaction alloc] initWithUser:user amountInPaise:500];
[ [GSManager sharedManager] authorizeTransaction:transaction onCompletion:^(NSDictionary * jsonResponse, NSError * error) {
}];
//Swift
let user : GSUser = GSUser(phoneNumber :"user mobile number" email :@"user email")
let transaction = GSTransaction(user: user, amountInPaise: 500)
GSManager.sharedManager.authorizeTransaction(transaction) { (jsonResponse : NSDictionary?, error:NSError?) -> Void in
}
在调用 authorizeTransaction 之前,必须设置 GSUser 的电话号码。一旦您获得 transaction_token,就可以将它传递到您的服务器,服务器随后可以将交易详情传递给 Simpl。