https://github.com/assemblypayments/ios-sdk
https://github.com/assemblypayments/ios-sdk
platforms
Last synced: 29 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/assemblypayments/ios-sdk
- Owner: AssemblyPayments
- License: mit
- Created: 2016-01-12T05:04:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-10-16T04:27:28.000Z (over 8 years ago)
- Last Synced: 2025-10-23T08:42:58.861Z (8 months ago)
- Topics: platforms
- Language: Objective-C
- Size: 74.2 KB
- Stars: 0
- Watchers: 26
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PromisePay - iOS SDK
[](https://travis-ci.org/KevinHakans/PromisePay)
[](http://cocoapods.org/pods/PromisePay)
[](http://cocoapods.org/pods/PromisePay)
[](http://cocoapods.org/pods/PromisePay)
#1. Installation
## Manual
Download the latest release from GitHub, then add the PromisePay holder to your relevant xcode project.
## CocoaPods
PromisePay is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod "PromisePay"
```
#2. Usage
Import the header and create PromisePay object.
```Objective-C
#import "PromisePay.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize the PromisePay with the Environment and PublickKey
PromisePay *promisePay = [[PromisePay alloc] initWithEnvironment:@"prelive" publicKey:@"cbd748a608eda8635e1f325d914080b4"];
// Create the Card
PPCard *card = [[PPCard alloc] initWithNumber:@"4111111111111111"
fullName:@"Bobby Buyer"
expiryMonth:@"12"
expiryYear:@"2020"
cvv:@"123"];
[promisePay createCardAccount:@"460b3a207121352b1d48aa0724734e4b" card:card callBack:^(id result, NSError * error) {
// TODO: process with the callback
}];
}
```
###Using the card scanner
Declare conformity to the `PromisePayCardScannerDelegate` protocol.
```Objective-C
#import "PromisePayCardScanner.h"
@interface ViewController : UIViewController
@end
```
Implement the delegate methods in your view controller.
```Objective-C
#import "PromisePay.h"
@interface ViewController ()
@property (nonatomic, strong) PromisePay *promisePay;
@property (nonatomic, strong) PromisePayCardScanner *promisePayCardScanner;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize the PromisePay with the Environment and PublickKey
PromisePay *promisePay = [[PromisePay alloc] initWithEnvironment:@"prelive" publicKey:@"cbd748a608eda8635e1f325d914080b4"];
// Initialize the PromisePayCardScanner
self.promisePayCardScanner = [[PromisePayCardScanner alloc] init];
self.promisePayCardScanner.delegate = self;
}
#pragma mark - PromisePayCardScannerDelegate methods
- (void)userDidScanCard:(PPCard *)card {
[self.promisePay createCardAccount:@"460b3a207121352b1d48aa0724734e4b" card:card callBack:^(id result, NSError * error) {
// TODO: process with the callback
}];
}
- (void)userDidCancelCardScanning {
NSLog(@"user cancelled");
}
@end
```
Start the card scanner
```Objective-C
[self.promisePayCardScanner scanCardFromViewController:self];
```
#3. Examples
##Configuration
Initialize PromisePay using as following.
```Objective-C
PromisePay *promisePay = [[PromisePay alloc] initWithEnvironment:@"prelive" publicKey:@"PUBLIC_KEY"];
```
##Create Card Account
Create the PPCard object with the information of card like this.
```ObjectiveC
PPCard *card = [[PPCard alloc] initWithNumber:@"4111111111111111"
fullName:@"Bobby Buyer"
expiryMonth:@"12"
expiryYear:@"2020"
cvv:@"123"];
```
Now calling the createCardAccount method, you can get the callback of result.
````ObjectiveC
[promisePay createCardAccount:@"CARD_TOKEN" card:card callBack:^(id _Nonnull result, NSError * _Nonnull error) {
if(error != nil) {
NSLog(@"error = %@", error);
}
else {
NSLog(@"Succeed to create card account, result=%@", result);
}
}];
```
Alternatively use the card scanner to return a PPCard object by implementing the delegate methods.
```ObjectiveC
- (void)userDidScanCard:(PPCard *)card {
[self.promisePay createCardAccount:@"460b3a207121352b1d48aa0724734e4b" card:card callBack:^(id result, NSError * error) {
// TODO: process with the callback
}];
}
- (void)userDidCancelCardScanning {
NSLog(@"user cancelled");
}
```
Start the card scanner
```Objective-C
[self.promisePayCardScanner scanCardFromViewController:self];
```
#4. License
PromisePay is available under the MIT license. See the LICENSE file for more info.
#5. Requirements
Third-party open source libraries used within PromisePay:
1. [CardIO](https://github.com/card-io/card.io-iOS-SDK) - Credit card scanning