PAYCOMET iOS SDK
The PAYCOMET SDK provides easy to use methods for connecting to the PAYCOMET API.
Requirements
The SDK is compatible with iOS apps supporting iOS 11.0 and later.
Important
Integration via PAYCOMET iOS SDK does not comply with PCI standards, to perform a mobile integration that complies with PCI standards you can integrate using BankStore JET-IFRAME.
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate PAYCOMET into your project, specify it in your Podfile
:
pod 'PAYTPV'
Example Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!
target '<TARGET_NAME>' do
pod 'PAYTPV'
end
Then, run the following command:
$ pod install
Don't forget to use the .xcworkspace
instead of the .xcodeproj
from now on.
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate PAYCOMET into your project using Carthage, specify it in your Cartfile
:
github "PAYCOMET/ios-bankstore" ~> 1.0
Then, run carthage update
to build the framework and drag the built PAYTPV.framework
into your Xcode project.
Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Once you have your Swift package set up, add PAYCOMET as a dependency:
dependencies: [
.package(
url: "https://github.com/PAYCOMET/ios-bankstore.git", .upToNextMajor(from: "1.0.0")
)
]
Finally, add import PayTPV
to your source code.
Usage
After you're done installing the SDK, you need to create the configuration object with your terminal details:
Swift:
import PAYTPV
let config = PTPVConfiguration(merchantCode: "MERCHANT_CODE", terminal: "TERMINAL", password: "PASSWORD", jetId: "JETID")
PTPVAPIClient.shared().configuration = config
ObjC:
#import <PAYTPV/PAYTPV.h>
PTPVConfiguration *config = [[PTPVConfiguration alloc] initWithMerchantCode:@"MERCHANT_CODE"
terminal:@"TERMINAL"
password:@"PASSWORD"
jetId:@"JETID"];
[[PTPVAPIClient sharedClient] setConfiguration:config];
After you created the configuration, you can start making requests:
Swift:
// get the user's card details
let card = PTPVCard(pan: "4111111111111111", expiryDate: "0518", cvv: "123")
// add the card
PTPVAPIClient.shared().addUser(card) { (user, error) in
guard let user = user else {
if let error = error {
// handle error
}
return;
}
// define payment details
let purchaseRequest = PTPVPurchaseRequest(amount: "199",
order: "ios_1234",
currency: PTPVCurrencyEUR,
productDescription: nil,
owner: nil,
scoring: nil)
// make the payment
PTPVAPIClient.shared().executePurchase(purchaseRequest, for: user, completion: { (purchase, error) in
guard let purchase = purchase else {
if let error = error {
// handle error
}
return;
}
// handle successful payment
})
}
ObjC:
// get the user's card details
PTPVCard *card = [[PTPVCard alloc] initWithPan:@"4111111111111111"
expiryDate:@"0518"
cvv:@"123"];
// add the card
[[PTPVAPIClient sharedClient] addUser:card completion:^(PTPVUser * _Nullable user, NSError * _Nullable error) {
if (error != nil) {
// handle error
return;
}
// define payment details
PTPVPurchaseRequest *purchaseRequest;
purchaseRequest = [[PTPVPurchaseRequest alloc] initWithAmount:@"199"
order:@"ios_1234"
currency:PTPVCurrencyEUR
productDescription:nil
owner:nil
scoring:nil];
// make the payment
[[PTPVAPIClient sharedClient] executePurchase:purchaseRequest forUser:user completion:^(PTPVPurchase * _Nullable response, NSError * _Nullable error) {
if (error != nil) {
// handle error
return;
}
// handle successful payment
}];
}];
If you have several terminals, you can instantiate a separate client with the configuration instead of using the shared client:
Swift:
let client = PTPVAPIClient(configuration: config)
client.addUser(..., completion: ...)
Objc:
PTPVAPIClient *client = [[PTPVAPIClient alloc] initWithConfiguration:config];
[client addUser:... completion:...];
Examples
There are Swift and Objective-C example applications included in the repository. They show how to use the SDK to: add a card, remove a card, make a payment, make a refund. Check the Examples
folder.