![SwiftyOpenPay v0.2.1](https://img.shields.io/badge/Latest Version-v0.4-brightgreen.svg)
SwiftyOpenPay is an unofficial OpenPay API client for iOS written in Swift.
Use at your own risk.
SwiftyOpenPay
can be installed using Carthage.
In your Cartfile, include SwiftyOpenPay
:
github "Pacific3/SwiftyOpenPay" ~> 0.4
Then, update:
$ carthage update
Drag all the .framework
files at Carthage/Build/iOS
to your target's Linked Frameworks and Libraries
section.
import SwiftyOpenPay
let myAddress = Address(
line1: "1 Infinite Loop",
city: "Cupertino",
state: "California",
countryCode: "US",
postalCode: "95014"
)
let myCard = Card(
holderName: "John Doe",
expirationMonth: "12",
expirationYear: "19",
address: myAddress,
number: "XXXXXXXXXXXX"
)
let configuration = SwiftyOpenPay.Configuration(
merchantId: "MyMerchantId",
apiKey: "MyAPIKey",
sandboxMode: true,
verboseMode: true
)
let openPay = SwiftyOpenPay(configuration: configuration)
do {
try openPay.createTokenWithCard(myCard,
completion: { token in
print(token.id)
},
error: { error in
print(error)
}
)
} catch {
print(error)
}
You can either crate a SwiftyOpenPay
instance using a SwiftyOpenPay.Configuration
, or passing the values directly to the initializer.
sandboxMode
and verboseMode
default to false
. Both of them can be omitted from the constructors.
SwiftyOpenPay is not an oficial Openpay product. Openpay is not responsible for either this code or what you use it for. The use of SwiftyOpenPay is your and only your responsability.
Openpay does provide an officially supported version of their iOS API client, which can be found over at their GitHub page.
Refer to Openpay's Privacy Notice and Terms of Service.