Skip to content

3allaam/CirclePay

Repository files navigation

Alt Text

Website Version License Platform Developer

Product Objectives 🎯

By using the SDK , developers gotta be allowed to use Circlepay open api from iOS apps. also they can use CirclePay checkout embed screens which gonna reduce a lot of effort to the developer.

Table of Contents ⚓

Integration 💻
Prepare SDK & Adding Keys 🔑
Change SDK environment 👀
Usage 🧑‍💻
Checkout Embed 📲
Call Backs 🔙
UI Configuration 🎨
Author
License

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

pod 'CirclePay'

Then run this command in your terminal to fetch the latest version:

pod repo update

Prepare SDK & Adding Keys 🔑

Once integration done you can import the SDK in your classes like below:

import CirclePaySDK

Now you have put your keys and call CirclePay.prepareSDK method before using the SDK methods . you can put it into your AppDelegate.swift file like this :

import UIKit
import CirclePaySDK
@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window:UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        CirclePay.merchantToken = "Your Merchant Token"
        CirclePay.accountToken = "Your Account Token"
        CirclePay.accountKey = " Your Account Key"
        CirclePay.prepareSDK()
        let window = UIWindow(frame: UIScreen.main.bounds)
        window.rootViewController = InitialViewController()
        self.window = window
        window.makeKeyAndVisible()
        return true
    }
}

Change SDK environment 👀

You can change the environment like this :

 CirclePay.mode = .sandbox

Note that there's two environments :

Enviroments Mode
SandBox .sandbox
Production .production

By default the environment is set to .sandbox

Usage 🧑‍💻

Mainly the SDK contain some main modules you can call them by a class called CirclePay , below the main modules that SDK Support :

  • invoices
  • createInvoice
  • deleteInvoice
  • listInvoices
  • getInvoice
  • payInvoice
  • customers
  • createCustomer
  • updateCustomer
  • listCustomers
  • getCustomer
  • merchants
  • createMerchant
  • getMerchant
  • getAllMerchants
  • disablePaymentGateway
  • enablePaymentGateway
  • listPaymentGateway
  • disablePaymentMethod
  • enablePaymentMethod
  • listPaymentMethods
  • updateMerchant
  • sendOTP
  • verifyMerchant
  • payments
  • getPayment
  • getAllPayments
  • refunds
  • getRefundStatus
  • getAllRefunds
  • requestRefund
  • paymentGateways
  • getPaymentGateway
  • getAllPaymentGatways
  • paymentMethods
  • getPaymentMethod
  • getAllPaymentMethods

You can use those modules methods by importing the SDK into your class , then calling its methods throw CirclePay class like shown below:

    CirclePay.invoices.getInvoice(invoiceNumber: self.invoiceNumber) { invoiceData, err in
            //Write your logic
    }

For more details you can visit the open API docs :

Docs

Checkout Embed 📲

Invoice Summary Invoice Details Payment Methods Sucsessfully Transaction

To use checkout embed you have to call execute methods which is in our main class CirclePay like below:

 CirclePay.excutePayment(with: .Invoice(invoiceNumber: unwrappedInvoiceNumber))

By passing the invoice number argument you should start the checkout embed jounry easily , and carry on.

Call Backs 🔙

By Conforming to CirclePayDelegete Interface you will be able to receive the transaction result call back . First You have to assign delegete like below :

    CirclePay.delegete = self

Then you should implement CirclePayDelegete in your class like below:

extension InitialViewController: CirclePayDelegete {
    
    func didGetErrorAtCheckoutProcess(error: CirclePayError) {
        print("Check out error :- " , error.errorMsg )
    }
    
    func didPaidTransactionSucsessfully(transaction: TransactionResult) {
        print("Sucsessfully Paid :-", transaction)
    }
    
    func didGetErrorAtPayingTransaction(transaction: TransactionResult, error: CirclePayError) {
        print("Failed to Pay :-", transaction)
    }
}

Transaction Result object contains:

 var paymentGatewayName: String?
 var paymentMethodName: String?
 var transactionId: String?
 var transactoinStatus: String?
 var transactionType: Int

UI Configuration 🎨

The UI is fully dynamic based on your configuration on the dashboard , it will reflect directly checkout embed screens like image below :

UI Will be reflected directly with your configuration like primary colors , hiding/showing elements

Author

Mahmoud3allam, mahmoudallam@circlepay.ai , https://github.com/Mahmoud3allam

Adel Mohey, adelmohey@circlepay.ai

License

CirclePay is available under the MIT license. See the LICENSE file for more info.