IOS SDK

Supporting Online Card Payments

Installation:

AcceptCardSDK is available through CocoaPods.
To install it, simply add the following line to your Podfile:

pod 'AcceptCardSDK'

And in the general settings of your project, under libraried and frameworks
change the library from "Do not embed" to "Embed and Sign"

Usage:

import the framework

import AcceptSDK
import AcceptSDK

add the delegate to the class, and add the protocol stubs

class ViewController: UIViewController, AcceptSDKDelegate {

then create a constant

let accept = AcceptSDK()

then pass self to delegate

accept.delegate = self

then create the variables

// Replace this string with your payment key
let KEY: String = "ZXlKaGJHY2lPaUpJVXpVeE1pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SjFjMlZ5WDJsa0lqb3pNU3dpYjNKa1pYSWlPbnNpWkdWc2FYWmxjbmxmYm1WbFpHVmtJanBtWVd4elpTd2lZVzF2ZFc1MFgyTmxiblJ6SWpveE1EQXNJbU4xY25KbGJtTjVJam9pUlVkUUlpd2lhWFJsYlhNaU9sdGRmU3dpWTNWeWNtVnVZM2tpT2lKRlIxQWlMQ0pwYm5SbFozSmhkR2x2Ymw5cFpDSTZOVGMyTWl3aWJHOWphMTl2Y21SbGNsOTNhR1Z1WDNCaGFXUWlPbVpoYkhObExDSndiV3RmYVhBaU9pSXhOVFl1TWpFMUxqRTNOeTR4TWpNaUxDSmlhV3hzYVc1blgyUmhkR0VpT25zaVptbHljM1JmYm1GdFpTSTZJa05zYVdabWIzSmtJaXdpYkdGemRGOXVZVzFsSWpvaVRtbGpiMnhoY3lJc0luTjBjbVZsZENJNklrVjBhR0Z1SUV4aGJtUWlMQ0ppZFdsc1pHbHVaeUk2SWpnd01qZ2lMQ0ptYkc5dmNpSTZJalF5SWl3aVlYQmhjblJ0Wlc1MElqb2lPREF6SWl3aVkybDBlU0k2SWtwaGMydHZiSE5yYVdKMWNtZG9JaXdpYzNSaGRHVWlPaUpWZEdGb0lpd2lZMjkxYm5SeWVTSTZJa05TSWl3aVpXMWhhV3dpT2lKamJHRjFaR1YwZEdVd09VQmxlR0V1WTI5dElpd2ljR2h2Ym1WZmJuVnRZbVZ5SWpvaUt6ZzJLRGdwT1RFek5USXhNRFE0TnlJc0luQnZjM1JoYkY5amIyUmxJam9pTURFNE9UZ2lMQ0psZUhSeVlWOWtaWE5qY21sd2RHbHZiaUk2SWs1QkluMHNJbUZ0YjNWdWRGOWpaVzUwY3lJNk1UQXdmUS5OVmFuOU5IUXM3NWowb2g4LTNaYkU0QkhLY05Jb0RkQmlJbGpiWUs3UUptMDZqN3VTX0dTVGpaeUtONElWem1JajktUEhFak5GdnluNEFhOUkzb1p5Zw=="

// Place your billing data here
// billing data can not be empty
// if empty, type in NA instead
let bData = [  "apartment": "",
               "email": "",
               "floor": "",
               "first_name": "",
               "street": "",
               "building": "",
               "phone_number": "",
               "shipping_method": "",
               "postal_code": "",
               "city": "",
               "country": "",
               "last_name": "",
               "state": ""
]

🚧

Payment Key

A valid payment key is required to start the payment.

Valid means Fresh(newly created), doesn't have pending transactions, the best to do is to create a new order for every payment key. To generate a payment key, check this link here.

now call the function and if you are using Paymob Pakistan, add the country parameter and set it to "pk"

do {
           try accept.presentPayVC(vC: self, billingData: bData, paymentKey: KEY, country: "pk", saveCardDefault:
           true, showSaveCard: true, showAlerts: true)
       } catch AcceptSDKError.MissingArgumentError(let errorMessage) {
           print(errorMessage)
       }  catch let error {
           print(error.localizedDescription)
       }

and if you already have a saved token

do {
try accept.presentPayVC(vC: self, billingData: bData, paymentKey: KEY,  saveCardDefault: true,
showSaveCard: false, showAlerts: true, token: "123", maskedPanNumber: "xxxx-xxxx-xxxx-1234")
} catch AcceptSDKError.MissingArgumentError(let errorMessage) {
           print(errorMessage)
       }  catch let error {
           print(error.localizedDescription)
       }

what the parameters do

//Show the user whether or not he wants to save the card
showSaveCard: true
//Initially, the save card option is on or off
saveCardDefault: true
//either show the user some alerts on success / failure or not
showAlerts: true

you can use extra parameters such as

//for the color of the buttons
buttonsColor: UIColor.blue
//for english langauge
isEnglish: false
//for arabic language
isEnglish: false

//used like this
try accept.presentPayVC(vC: self, billingData: bData, paymentKey: KEY, saveCardDefault: true,
showSaveCard: true, showAlerts: true, buttonsColor: UIColor.blue, isEnglish: false)

You can find the GitLab reference from the link here