iOS Package

PLPaymentGateway SDK: Seamlessly integrate with our payment gateway service. Generate invoice URLs and handle authentication with ease. Simplify payment processing in your iOS apps.

Installation

To use Paylink SDK for iOS, put the following line in the project Podfile.

pod 'PaylinkGateway', :git => 'https://github.com/Paylink-sa/PLPaymentGatewayPod.git'

Update

If you are already using Paylink SDK for iOS, just run the command "pod update" to update the new versions of the SDK.

Usage

Initialization

To use the SDK, first, create an instance of the PaylinkGateway class with the desired environment:

import PLPaymentGateway
let gateway = PaylinkGateway(environment: .prod)

Generating an Invoice transaction no

An invoice should be created on the application's server side by calling the addInvoice endpoint and then passing transactionNo to the client.

📘

Parameters

transactionNo: this is same value of transactionNo received from calling addInvoice endpoint.

from: viewController: this is the viewController in iOS that will host the payment form.

Opening Payment Form

You can then display the payment of the invoice using the openPaymentForm method:

// Open Payment View Controller, transactionNo is received from the server side
gateway.openPaymentForm(transactionNo: transactionNo, from: viewController) {
  result in
  switch result {
    // After payment is completed (Paid or Declined), orderNumber 
    // and transactionNo are returned.
    case .success((let orderNumber, let transactionNo)):
    print("order number: \(orderNumber)")
    print("transaction no: \(transactionNo)")
    // Pass the transactionNo to the backend server to check the payment status
    // ...
    break;
    case .failure(_):
    break;
  }
} loaded: {
  // .. code when the ViewController got loaded.
}

Get Payment View for SwiftUI

Suppose you use SwiftUI and want to display the payment form within the SwiftUI tree. Use the method getPaymentFormView to retrieve the payment form view.

// Get Payment View for SwiftUI: To use SwiftUI and want to display the payment 
// form within the SwiftUI tree. Use the method getPaymentFormView to retrieve 
// the payment form view. tranNo is received from the backend server side.
gateway.getPaymentFormView(transactionNo: tranNo) {
  // After payment is completed (Paid or Declined), orderNumber and transactionNo is returned.
  orderNum, transNo in
  
  print("order number: \(orderNumber)")
  print("transaction no: \(transactionNo)")
 
  // Pass the transactionNo to the backend server to check the payment status
  // ...
}

Check order status

Pass the received transactionNo to your server side to check the order status using the getInvoice endpoint

Customized Payment Form URL

Paylink usually opens the payment form based on Paylink's branding and look and feel. But what if the merchant or the developer using Paylink's SDK wants to design their payment form?

Here in Paylink, we enable developers to fully control the payment form using the initializing parameter "paymentFormUrl." Developers can set their payment form and pass their URL to the constructor of the class PaylinkGateway in the parameter "paymentFormUrl."

self.gateway = PaylinkGateway(environment: PaylinkGateway.Environment.test,
                        paymentFormUrl: "https://merchants-website.com/mobile-payment-form.php",
                        platform: "ios")

Then, Paylink, during payment, will open the merchant's customized payment form instead of the default one.

📘

Customized Payment Form parameters:

During opening payment form, Paylink will pass two parameters to the customized payment form which are:

Field nameTypeDescription
transactionNoStringA transaction no of the payment.
platformStringthe platform of the device "android" or "ios"

Example:

https://merchant-website.com/mobile-payment-form.php?transactionNo=123123123&platform=ios

Sample of code

To download a sample of the code, click here