QorePay logo
QorePay logo

GateUi iOS SDK

Download Library

Installation

Manually including a framework

  1. Drag and drop the framework from Finder into your Xcode project
    • Select _Copy items if needed_
    • Click _Finish_.
  2. Open your project's settings by selecting your app target in the General tab
    • Under the _Frameworks, Libraries, and Embedded Content_ section, make sure each framework is set to “Embed & Sign”
  3. Go to the Build Phases tab. Under _Link Binary With Libraries_, make sure the frameworks are listed.

Getting Started

First you will need to choose one of the server libraries or use our API directly. You can obtain all the details the Developers section in your account. Your goal on a sever is to handle 2 requests "/purchase and"/payment_methods".
Simple usage looks like:

1import GateUi
2...
3
4struct GatePurchase: Decodable {
5  let total: Int
6  let currency: String
7}
8
9struct GatePurchaseResponse: Decodable {
10  let purchase: GatePurchase?
11  let checkout_url: String?
12  let direct_post_url: String?
13  let success_redirect: String?
14  let failure_redirect: String?
15}
16
17func createPayment() {
18  do {
19    // where methods.data is DATA received from your server for "payment_methods" request
20    let methodsResponse = try JSONDecoder().decode(GateCurrencyResponse.self, from: methods.data!)
21
22    // where purchase.data is DATA received from your server for "purchase" request
23    let purchaseResponse = try JSONDecoder().decode(GatePurchaseResponse.self, from: purchase.data!)
24
25    GateUi.config.merchant = "..." // Enter your company name to display in Payment process
26    GateUi.config.successUrl = purchaseResponse.success_redirect!
27    GateUi.config.failUrl = purchaseResponse.failure_redirect!
28    let vc = GateUi.setup(
29      purchaseResponse.checkout_url!,
30      postUrl: purchaseResponse.direct_post_url,
31      methods: methodsResponse,
32      amount: purchaseResponse.purchase?.total,
33      currency: purchaseResponse.purchase?.currency
34    )
35    // class have to conform to GateSdkViewControllerDelegate protocol
36    GateUi.paymentDelegate = self
37    vc.modalPresentationStyle = UIModalPresentationStyle.fullScreen
38    self.present(vc, animated: true, completion: nil)
39  }
40  catch let error as NSError {
41    print("Error: (error.localizedDescription)")
42  }
43}
44
45// MARK: GateSdkViewControllerDelegate
46
47func paymentCompleted() {
48  print("delegate completed")
49}
50
51func paymentFailed() {
52  print("delegate failed")
53}
54
55func paymentCanceled() {
56  print("delegate canceled")
57}