Updated 20 January 2018
Hi guys , today we will learn about how to implement PayTabs payment gateway in iOS application.
You can read their integration guide https://www.paytabs.com/PayTabs_iOS_SDK_V2.0.pdf
Before starting to code first we need to know what a payment gateway is
A payment gateway is a merchant service provided by an e-commerce application service provider that authorises credit card or direct payments processing for e-businesses, online retailers, bricks and clicks, or traditional brick and mortar.
Thus , its enough for us now. Lets start by following the instructions below.
1 |
var paytab = PayTabCardReaderViewController() |
6. Now paste this code inside your payment class
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 |
func callPaytabPaymentGateway(){ paytab.tag_amount = "Order's total amount" paytab.tag_title = "Order payment title like customer's Firstname , Lastname etc" paytab.tag_currency = "Order amount currency" paytab.sdklanguage = "Your SDK language code like 'en' " paytab.tag_tax = "Total applicable tax"; paytab.shipping_address = "Customer's shipping address"; paytab.shipping_city = "Customer's shipping city"; paytab.shiping_country = "Customer's shipping country"; paytab.shipping_state = "Customer's shipping state" paytab.shipping_zip_code = "Customer's shipping zipcode" paytab.billing_address = "Customer's billing address" paytab.billing_city = "Customer's billing city" paytab.billing_country = "Customer's billing country" paytab.billing_state = "Customer's billing state" paytab.billing_zip_code = "Customer's billing zipcode" paytab.order_id = "Customer's order id that uniquely identifies order" paytab.phonenum = "Customer phone number" paytab.customer_email = "Customer's mail Id" paytab.tag_merchant_email = "Your merchant Id" paytab.timerFlag = 20100;//seconds paytab.secretKey = "Your merchant secret key" paytab.tag_original_assignee_code = "SDK"; // booking id - n self.present(paytab, animated: true, completion: nil) } func checkPaymentStatus(){ if UserDefaults.standard.value(forKey: "pt_response_code") as? String ?? "0" == "0"{ // Payment Failed showAlert(message:"Payment Failed") } else{ // Payment Success self.responseCode = UserDefaults.standard.value(forKey: "pt_response_code") as! String self.transactionId = UserDefaults.standard.value(forKey: "pt_transaction_id") as! String // Update your server for the successful payment } } func showAlert(message:String){ let errorAlert = UIAlertController(title: "", message:message, preferredStyle: .alert) let noBtn = UIAlertAction(title: "ok", style: .default, handler: {(_ action: UIAlertAction) -> Void in CheckoutShippingMethod.orderData = "" self.continue2Btn() }) errorAlert.addAction(noBtn) self.parent!.present(errorAlert, animated: true, completion: { _ in }) } |
7. Call the function callPaytabPaymentGateway() into the action of your payment button.
8. After the successful or unsuccessful transaction PayTabs stores the transaction id and response code into your UserDefaults. To check the payment status call checkPaymentStatus() function into your payment ViewController’s viewWillAppear function.
9. Finally You have successfully implemented the PayTabs Payment Gateway in your iOS application.
Note:-
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Error :
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)