In this blog, we are going to learn about the BillDesk Payment gateway in Swift. Payment gateway is an essential part of any mobile application for sales and purchase of services or products. BillDesk is an Indian online payment gateway in the region of Maharashtra and Madhya Pradesh.
Thereafter, please follow the below steps are the integration of the BillDesk Payment gateway in Swift.
Step – 1
Please create your account on the BillDesk Payment gateway from here.
Step – 2
Now drag and drop the BilldeskLiberary into your project from the demo BillDesk project.
Step – 3
In addition, make use of libBilldesk_device if you are running on your device and libBilldesk_simulator if you are running your app on your simulator.
Step – 4
Now copy the drag and drop the controller folder from the sample project to your swift project.
Step – 5
After that, we will create an instance of the BDFirstViewController and pass the required information for the payment gateway.
1 2 3 4 5 6 |
let viewController: BDFirstViewController = segue.destination as UIViewController as! BDFirstViewController viewController.amount = "\(orderReviewViewModel.orderTotalAmount.last?.value ?? "")" viewController.email = orderReviewViewModel.billdesk?.email ?? "" viewController.messgae = orderReviewViewModel.billdesk?.msg ?? "" viewController.returnUrl = orderReviewViewModel.billdesk?.returnUrl ?? "" viewController.telephone = orderReviewViewModel.billdesk?.telephone ?? "" |
Step – 6
For instance the transaction result, we will show an alert and navigate the controller to success and failure controller.
1 2 3 4 5 6 7 8 |
func showAlert(_ message: String) { let alertController = UIAlertController(title: "Payment status", message: message, preferredStyle: .alert) alertController.addAction(UIAlertAction(title: "Ok", style: .cancel) { (action:UIAlertAction!) in self.callingApi() }) self.present(alertController, animated: true, completion: nil) } |
In Conclusion
We have successfully integrated the bill desk payment gateway in swift. Thanks for reading my blog. Please refer to my other blog from here.