Paystack is an easy to setup, complete payments solution for businesses.
Add PaystackProvider as a dependancy in your Package.swift
file:
dependencies: [
...,
.Package(url: "https://github.com/aonawale/paystack-provider.git", majorVersion: 1)]
]
Paystack can be configured in a paystack.json
file located inside your Vapor Config
dir:
{
"publicKey": "your public key",
"secretKey": "your secret key"
}
After you have initialized the Config
object, simply add the provider:
import PaystackProvider
...
try config.addProvider(PaystackProvider.Provider.self)
PaystackProvider adds an extension on Droplet for easier access to Paystack, so it can be accessed simply as:
let paystack = droplet.paystack
Send card details to start a charge:
import PaystackProvider
let card = Card(number: "4084084084084081", cvv: "408", expiryMonth: "02", expiryYear: "20")
try paystack.charge(card: card, amount: 1000, email: "me@email.com")