Monnify iOS SDK

 

 

 

 

Getting started with the Monnify iOS SDK

First off, the Monnify iOS SDK allows you to accept payments from customers in your iOS application via:

  1. Card Payment

  2. Bank Transfer (this is what is special:)

  3. USSD Payment

  4. Payment by Phone Number

How to Implement

1. Adding the iOS SDK to your project via CocoaPods

Monnify iOS SDK is available through [CocoaPods](https://cocoapods.org). To install it, simply add the following line to your Podfile:

pod 'MonnifyiOSSDK'

2. Access an instance of the Monnify SDK

let monnify = Monnify.shared

3. Set your merchant API key and contract code.

This should be done in your `AppDelegate.swift` file. This should only be done once in the entire application.

This can be a TEST or LIVE. The TEST mode works on a sandbox environment and payment can be simulated [here](https://websim.sdk.monnify.com/#/bankingapp).

Remember to switch to ApplicationMode.live when generating live builds for your application on production.

let apiKey = "MK_PROD_XXXXXXXX" let contractCode = "1234567890" let mode = ApplicationMode.test monnify.setApplicationMode(applicationMode: mode) monnify.setApiKey(apiKey: apiKey) monnify.setContractCode(contractCode: contractCode)

4. Specify the transaction parameters as shown below:

5. Launch the payment gateway, perhaps when the user clicks on a 'Pay' button.

The initializePayment() method requires the following:

    * A ViewController instance.    

    * An instance of TransactionParameters, e.g `parameter` above.

    * A completion/callback to be called with the monnify SDK is completing either after a failure or success.

6. Get the outcome of the payment attempt.

The result is available via the callback registered in `initializePayment()` as described above.

For example, you can access the transaction status from the result as shown below.

Other information in the result includes transaction reference, payment reference, payment method, and the amount paid.

Transaction Status Possible Values!

Possible values for transaction status enum returned from the SDK and their meanings below:

Type

Meaning

Type

Meaning

pending

No payment has been made on this transaction.

paid

Payment has been completed on this transaction.

overpaid

Customer overpaid on this transaction and Merchant has configured that overpayment is accepted. This is only possible for account transfer payment method.

partiallyPaid

Customer underpaid on this transaction and Merchant has configured that underpayment is accepted. This is only possible for account transfer payment method.

reversed

Payment has been made on this transaction but it cannot be accepted because of the merchant configuration or because of some other reasons. This is only possible for account transfer payment method.

expired

No payment was made before the allowed time elapsed. Hence transaction has expired and no payment can be made on this transaction.

cancelled

User cancelled and closed the SDK before payment was made.

failed

The transaction ended with a failure. This can happen if a transaction has expired or if an incorrect amount was paid and the merchant configured that only the exact amount should be accepted

Please reach out to the support team for any clarification. 

Payment Method Possible Values!

Type

Meaning

Type

Meaning

card

The Payment method used for payment on this transaction is Card.

accountTransfer

The payment method used for payment on this transaction is Account Transfer.

ussd

The payment method used for payment on this transaction is USSD code.

phoneNumber

The payment method used for payment on this transaction is the phone number linked to your bank account.