PAYTPV SDK for App's in iOS Apple
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
PAYTPV.xcodeproj
PayTPV.xcodeproj/xcshareddata/xcschemes
PayTPV.xcworkspace
PayTPV
PayTPVTests
docs
scripts
.gitignore
.jazzy.yaml
.reviewboardrc
LICENSE
PAYTPV.podspec
README.md

README.md

PAYTPV iOS SDK

CocoaPods Compatible Carthage compatible

The PAYTPV SDK provides easy to use methods for connecting to the PAYTPV API.

Requirements

The SDK is compatible with iOS apps supporting iOS 8.0 and later.


Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate PAYTPV into your project, specify it in your Podfile:

pod 'PAYTPV'

Example Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.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 PAYTPV into your project using Carthage, specify it in your Cartfile:

github "PayTpv/IOS-SDK" ~> 1.0

Then, run carthage update to build the framework and drag the built PAYTPV.framework into your Xcode project.


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.