IOS

Introduction

To start using IOS SDK within your application please follow the below instructions

Download

Click here to get the SDK with the proper swift version.

Instructions

1- add (CowPay.framework) file to your frameworks

2- import CowPay in your class

import CowPay

3- init your data

let cowPaySdk = CowPaySDK()
    let apiMerchantCode = "you merchant code"
    let apiMerchantHashKey = "your merchant hash"
    let billingData = ["customer_mobile":"01234567891",
                       "customer_email":"example@gmail.com",
                       "customer_merchant_profile_id":"15",
                       "merchant_reference_id":String(UUID().uuidString.split(separator: "-").first!),
                       "amount":"1"]
    
    let token = "you generated token from api settings page"

4- use one of these functions

@IBAction func creditCard(_ sender: Any) {
        cowPaySdk.presentPay(viewController: self, apiMerchantCode: apiMerchantCode, apiMerchantHashKey: apiMerchantHashKey, billingData: billingData, token: token, paymentMethods: [.visa], isLive: true)
    }
    
    @IBAction func fawry(_ sender: Any) {
        cowPaySdk.presentPay(viewController: self, apiMerchantCode: apiMerchantCode, apiMerchantHashKey: apiMerchantHashKey, billingData: billingData, token: token, paymentMethods: [.fawry], isLive: true)
    }
    
    @IBAction func CreditCardAndFawry(_ sender: Any) {
        cowPaySdk.presentPay(viewController: self, apiMerchantCode: apiMerchantCode, apiMerchantHashKey: apiMerchantHashKey, billingData: billingData, token: token, paymentMethods: [.visa, .fawry], isLive: true)
    }
    

5- you will receive the return value in one of these delegates

extension ViewController: CowPaySDKDelegate {

    func missingData(_ error: String) {
        print(error)
    }

    func userDidCancel() {
        print("userCancelld")
    }

    func transactionAccepted(paymentMethod: PaymentType, paymentData: String) {
        print(paymentData)
    }
}