omise-ios 是一个用于管理信用卡和通过 Omise API 进行支付授权的 Cocoa 库。
通过使用此库生成的令牌,您可以在不让敏感信息通过您的服务器的情况下安全地处理信用卡。这些令牌还可以用来存储对卡详情的引用,这允许客户在未来的支付中重复使用卡,而不必再次输入他们的信息。
所有数据都是通过 HTTPS 传输到我们的 PCI-DSS 认证的机器上。
Omise-iOS-Swift 通过 CocoaPods 提供。要安装它,请简单地将以下行添加到您的 Podfile
中
pod 'omise-ios', '~> 1.0'
或者,手动安装的话,请将 {repository root}/Omise-iOS/Omise-iOS/OmiseLib
下的所有文件复制到您的项目中。
表示卡信息的类。
封装请求令牌参数的类。您需要将卡信息作为参数设置到此类中。
表示令牌的类。这是在请求成功时传递给代理的类。
用于请求令牌的类。请参阅下面的示例代码。
通过打开 Omise-iOS_Test.xcodeproj 并在 Xcode 中构建它,示例应用将会启动并创建一个用于测试的充电令牌。
ExampleViewController.h
:
#import <UIKit/UIKit.h>
#import "Omise.h"
#import "TokenRequest.h"
#import "Card.h"
@interface ExampleViewController : UIViewController <OmiseRequestTokenDelegate>
@end
ExampleViewController.m
:
#import "ExampleViewController.h"
@implementation ExampleViewController
-(void)viewDidLoad
{
[super viewDidLoad];
//set parameters
TokenRequest* tokenRequest = [TokenRequest new];
tokenRequest.publicKey = @"pkey_test_4ya6kkbjfporhk3gwnt"; //required
tokenRequest.card.name = @"JOHN DOE"; //required
tokenRequest.card.city = @"Bangkok"; //required
tokenRequest.card.postalCode = @"10320"; //required
tokenRequest.card.number = @"4242424242424242"; //required
tokenRequest.card.expirationMonth = @"11"; //required
tokenRequest.card.expirationYear = @"2016"; //required
tokenRequest.card.securityCode = @"123"; //required
//request
Omise* omise = [Omise new];
omise.delegate = self;
[omise requestToken:tokenRequest];
}
#pragma OmiseRequestDelegate
-(void)omiseOnFailed:(NSError *)error
{
//handle error
//see OmiseError.h and .m
}
-(void)omiseOnSucceededToken:(Token *)token
{
//your code here
//ex.
NSString* brand = token.card.brand;
NSString* location = token.location;
BOOL livemode = token.livemode;
}