Hello guys, Today we will learn about the Conekta Payment Gateway Integration
Overview To Implement Conekta Payment Integration Through SDK:-
In this blog, we are learning about How to integrate Conekta Payment Gateway Integration in the App
A Conekta Payment SDK provides a secure payment for iOS, Flutter, Android applications.
To integrate Conekta payment we need to follow some basic step-
Step1:- download Conekta SDK through this link.
- Firstly clone this project – $ git clone git@github.com:conekta/conekta-ios.git
- after that move the Conekta folder into your project folder And add the Conekta file to your Xcode
- On you xcodeproj, go to Build Setting-> Search Path -> Library Search Path, then double click and enter the value
12$(inherited)$(PROJECT_DIR)/Conekta
Step 2:- You need to add the following code into your Header Bridging file
1 |
#import "Conekta.h" |
create a Bridging file into your project –
- Add New file -> Header File -> click to next button.
- Now add your bridging file name and click on create button
- Add the bridging path in Project -> Target -> Build Setting -> Objective-c Bridging Header – enter your bridging path
Step 3:- After this, we need to create a ConektaPaymenViewController storyboard to integrate the Conekta payment method
Now add some code in ConektaPaymentViewController.swift file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
import UIKit import Firebase class ConektaPaymentViewController: UIViewController { @IBOutlet weak var proceedBtnOutlet: UIButton! @IBOutlet weak var cvvlbl: UILabel! @IBOutlet weak var expLbl: UILabel! @IBOutlet weak var cardOwnerLabel: UILabel! @IBOutlet weak var carkNumberLabel: UILabel! @IBOutlet weak var numberCardUI: UITextField! @IBOutlet weak var nameCardUI: UITextField! @IBOutlet weak var expMonthUI: UITextField! @IBOutlet weak var expYearUI: UITextField! @IBOutlet weak var cvcUI: UITextField! @IBOutlet weak var outTokenUI: UILabel! @IBOutlet weak var outUUID_UI: UILabel! var tokenId = "" var publicKey = "" override func viewDidLoad() { super.viewDidLoad() expMonthUI.placeholder = "MM" expYearUI.placeholder = "YYYY" numberCardUI.placeholder = "XXXX XXXX XXXX XXXX" nameCardUI.placeholder = "Name" cvcUI.placeholder = "CVC" } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } @IBAction func SubmitBtnClick(_ sender: UIButton) { let conekta = Conekta() conekta.delegate = self conekta.publicKey = "Enter your pubilc key " conekta.collectDevice() let card = conekta.card() card?.setNumber(numberCardUI.text, name: nameCardUI.text, cvc: cvcUI.text , expMonth: expMonthUI.text, expYear: expYearUI.text) let token = conekta.token() token?.card = card token?.create(success: { (data) -> Void in if let data = data as NSDictionary? as! [String:Any]? { self.tokenId = data["id"] as? String ?? "" //self.outUUID_UI.text = conekta.deviceFingerprint() print(data) // Success block }, andError: { (error) -> Void in print(error) }) } } |
we have successfully integrated the Conekta payment method into the app
Thanks for reading!