KKIAPAY
DashboardSupport
EN 1.0.0
EN 1.0.0
  • Introduction
  • Home
    • KKiaPay
  • Account
    • Create an account
    • Account activation
    • KKiaPay Sandbox : Test Guide
    • Using KKiaPay
  • Payements
    • Supported Currencies
    • Payment Methods
    • Fees
    • Payouts
    • Transactions
  • Plugin and SDK
    • Prestashop
    • WooCommerce
    • Wordpress Give
    • Wordpress Jobster
    • Javascript SDK
      • Using KKiaPay with Vue.js
      • Using KKiaPay with React.js
      • Using KKiaPay with Angular
      • Using KKiaPay with Svelte
    • Android SDK
    • SDK Flutter
    • SDK React-Native
    • SDK Swift for iOS
    • Admin SDKs (Server-side)
      • PHP Admin SDK
      • Python Admin SDK
      • Node.js Admin SDK
  • KKIAPAY SERVICES
    • KKiaPay Direct
    • KKiaPay POS
  • Dashboard
    • General Presentation
    • Menu
      • Transactions
      • Customers
      • Payouts
      • Developers
      • Settings
    • Webhook
  • Security
    • Security provisions
    • Suspicious email and website
    • Untitled
Powered by GitBook
On this page

Was this helpful?

  1. Plugin and SDK

SDK Swift for iOS

PreviousSDK React-NativeNextAdmin SDKs (Server-side)

Last updated 3 years ago

Was this helpful?

The KKiaPay SDK for Swift is designed to make the integration of our plugin into your mobile application as easy as possible. To set it up you will need to on platform and follow the process here describes :

  • Add the KKiaPay Swift SDK to your application

You can add the KKiaPay Swift SDK to your project using the Swift package manager.

Practical guide for installing a package with Swift : .

  • Import the package KKiaPay

 import KKiaPaySDK;
  • Create a view model to use later

@ObservedObject var viewModel = KKiaPayViewModel()
  • Initialise the KKiaPay Instance

 private var kkiaPay: KKiaPay{
    KKiaPay(amount: "3000",
            phone: "22997000000",
            data: "Hello world",
            publicAPIKey: "xxxxxxxxxxxxxxxxxxx",
            sandbox: true,//set this to false in production
            theme: "#4E6BFC",
            name: "John Doe",
            email:"user@email.com",
            callback: "https://redirect.kkiapay.com",
            viewModel:viewModel
    )
}
Attribute
Type
Description

amount

Numeric

The amount to be paid (in XOF)

phone

String

A valid money mobile number (MTN or MOOV) Ex: 22997000000 Ex: 22995000000

data

String

The data or information related to a transaction and interpretable by your system

publicAPIKey

String

name

String

The first and last name of the initiator of the payment

email

String

The email address of the initiator of the payment

sandbox

Boolean

callback

Function

The callback function called only when the payment was successful

Important !

You can subscribe to payment transaction events with the onReceive function. To be notified of the successful status of a payment transaction, you can proceed as follows :

kkiaPay.onReceive(self.viewModel.paymentData.receive(on: RunLoop.main)){paymentData in
    
    if(paymentData.isSuccessful){
        print("The amount of the transaction is " + paymentData.amount+" with id "+paymentData.transactionId)
        showWebView = false
    }else{
        print("The payment was not successful")
    }
}

Example

import SwiftUI
import KKiaPaySDK

struct ContentView: View {
        //Create a view model instance to use later
        @ObservedObject var viewModel = KKiaPayViewModel()
        @State private var showWebView = false
        
        //Initialise the Kkiapay Instance
        private var kkiaPay: KKiaPay{
            KKiaPay(amount: "3000",
                    phone: "97000000",
                    data: "Hello world",
                    publicAPIKey: "xxxxxxxxxxxxxxxxxxx",
                    sandbox: true,//set this to false in production
                    theme: "#4E6BFC",
                    name: "John Doe",
                    email:"user@email.com",
                    callback: "https://redirect.kkiapay.com",
                    viewModel:viewModel
            )
        }
        
        var body: some View {
            Button {
                showWebView.toggle()
            } label: {
                Text("Pay")
            }
            .sheet(isPresented: $showWebView) {
                
                //Get the transaction data back 
                kkiaPay.onReceive(self.viewModel.paymentData.receive(on: RunLoop.main)){paymentData in
                    
                    if(paymentData.isSuccessful){
                        print("The amount of the transaction is " + paymentData.amount+" with id "+paymentData.transactionId)
                        showWebView = false
                    }else{
                        print("The payment was not successful")
                    }
                }
            }
        }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

ParamètresTypeDescriptionLe montant à payer en FCFAStringUn numéro mobile money valideLa donnée ou information liée à une transaction et interprétable par votre systèmeStringLa liée à votre ​StringLes nom et prénoms de l’initiateur du paiementStringL’adresse mail de l’initiateur du paiementVous permet de basculer de l'environnement de test à l'environnement de production. La valeur true de cet attribut signifie que vous êtes en ​La fonction de callback appelée uniquement lorsque le paiement est effectué avec succès

The linked to your

Allows you to switch from the to the production environment. The value true for this attribute means that you are in a test environment

To avoid fraud, perform the server-side verification of the transaction operation. Learn more about the .

For more informations on the SDK please follow the link below :

create an account
kkiapay.me
Installing a package
clé publique
compte KKiaPay
environnement de test
Admin SDKs (Server-Side)
KKiaPay Swift SDK.
public key
KKiaPay account
test environment