Paystack iOS SDK
The Paystack iOS SDK make it easy to collect your users' credit card details inside your iOS app. By charging the card immediately on our servers, Paystack handles the bulk of PCI compliance by preventing sensitive card data from hitting your server.
This library helps collect card details on iOS, completing a charge. This shoulders the burden of PCI compliance by helping you avoid the
need to send card data directly to your server. Instead you send to Paystack's server and get a reference which you can verify in your
server-side code. The verify call returns an
authorization_code. Subsequent charges can then be made using the
Our SDK is compatible with iOS apps supporting iOS 8.0 and above. It requires Xcode 8.0+ to build the source.
You will also need to add Keychain Sharing entitlements for your app.
We've written a guide that explains everything from installation, to charging cards and more.
There is an example app included in the repository:
- Paystack iOS Example shows a minimal Swift integration with our iOS SDK using PSTCKPaymentCardTextField, a native credit card UI form component we provide. It uses a small example backend to make charges.
To build and run the example apps, open
Paystack.xcworkspace and choose the appropriate scheme.
Getting started with the Simple iOS Example App
Note: The example app requires Xcode 8.0 to build and run.
Before you can run the app, you need to provide it with your Paystack public key.
- If you haven't already, sign up for a Paystack account (it takes seconds). Then go to https://dashboard.paystack.co/#/settings/developer.
- Replace the
paystackPublicKeyconstant in ViewController.swift (for the Sample app) with your Test Public Key.
- Head to https://github.com/paystackhq/sample-charge-card-backend and click "Deploy to Heroku" (you may have to sign up for a Heroku account as part of this process). Provide your Paystack test secret key for the
PAYSTACK_TEST_SECRET_KEYfield under 'Env'. Click "Deploy for Free".
- Replace the
backendURLStringvariable in the example iOS app with the app URL Heroku provides you with (e.g. "https://my-example-app.herokuapp.com") WITHOUT THE TRAILING '/'
Making a test Charge
After completing the steps required above, you can (and should) test your implementation of the Paystack iOS library in your iOS app. You need the details of an actual debit/credit card to do this, so we provide ##test cards## for your use instead of using your own debit/credit cards.
You will find test cards on this Paystack documentation page.
To try out the OTP flow, we have provided a test "verve" card:
50606 66666 66666 6666 CVV: 123 PIN: 1234 TOKEN: 123456
You can then view the payments in your Paystack Dashboard!
See PaystackError.h for a list of error codes that may be returned from the Paystack API.