PAYTPV 1.0.3

PAYTPV 1.0.3

测试已测试
语言语言 Obj-CObjective C
许可证 NOASSERTION
发布上次发布2023年6月

Mihail Cristian Dumitru,《Diego Marcos》维护。



PAYTPV 1.0.3

  • Mihail Cristian Dumitru

PAYCOMET iOS SDK

CocoaPods Compatible Carthage compatible

PAYCOMET SDK 提供方便的方法用于连接到 PAYCOMET API。

要求

SDK 与支持 iOS 11.0 及更高版本的 iOS 应用兼容。

重要
通过 PAYCOMET iOS SDK 的集成不符合 PCI 标准,为了进行符合 PCI 标准的移动集成,您可以使用 BankStore JET-IFRAME 进行集成。


安装

为 Cocoa 项目提供依赖管理的是 CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理工具。您可以使用下面的命令来安装

$ gem install cocoapods

要集成 PAYCOMET,在您的 Podfile 文件中指定它

pod 'PAYTPV'

示例 Podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!

target '<TARGET_NAME>' do
  pod 'PAYTPV'
end

然后,运行以下命令

$ pod install

从现在开始不要忘记使用 .xcworkspace 而不是 .xcodeproj

Carthage

Carthage 是一个提供二进制框架的脱边依赖管理器。

您可以使用以下命令,通过 Homebrew 安装 Carthage

$ brew update
$ brew install carthage

要使用 Carthage 在您的项目中集成 PAYCOMET,在您的 Cartfile 中指定它

github "PAYCOMET/ios-bankstore" ~> 1.0

然后运行 carthage update 命令来构建框架,并将编译好的 PAYTPV.framework 拖拽到您的 Xcode 项目中。

Swift Package Manager

Swift Package Manager 是一个用于自动分发 Swift 代码的工具,并且已经集成到 Swift 编译器中。

一旦您设置了 Swift 包,将 PAYCOMET 添加为一个依赖。

dependencies: [
    .package(
      url: "https://github.com/PAYCOMET/ios-bankstore.git", .upToNextMajor(from: "1.0.0")
    )
]

最后,将 import PayTPV 添加到您的源代码中。


用法

在您完成SDK安装后,您需要使用终端详情创建配置对象

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];

在您创建配置后,您可以开始发送请求

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
    }];
}];

如果您有多个终端,您可以使用配置实例化独立的客户端而不是使用共享客户端

Swift

let client = PTPVAPIClient(configuration: config)
client.addUser(..., completion: ...)

Objc

PTPVAPIClient *client = [[PTPVAPIClient alloc] initWithConfiguration:config];
[client addUser:... completion:...];

示例

仓库中包含Swift和Objective-C示例应用程序。它们展示了如何使用SDK:添加卡片、移除卡片、发起支付和退款。请检查《代码示例》文件夹。