In this blog, we will know about the implementation of the telr payment gateway.
And you will receive the payment from the customer using this payment gateway
1. We need to install the pod for this payment gateway.
1 |
pod 'TelrSDK', :path => '../' |
2. Import its library in the view controller where do you want to implement payment method like below.
1 2 |
import TelrSDK class ViewController: UIViewController { |
3. Initiate the payment request data for passing the all data for the payment gateway to initiate the payment controller.
1 |
var paymentRequest:PaymentRequest? |
4. Then you need to assign the value in the payment request
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 |
private func preparePaymentRequest() -> PaymentRequest{ let paymentReq = PaymentRequest() paymentReq.key = KEY paymentReq.store = "12" paymentReq.appId = "20153" paymentReq.appName = "TelrSDK" paymentReq.appUser = "123456" paymentReq.appVersion = "0.0.1" paymentReq.transTest = "1"//1 for test mode"//0 for live mode paymentReq.transType = "paypage" paymentReq.transClass = "ecom" paymentReq.transCartid = "123" paymentReq.transDesc = "Test API" paymentReq.transCurrency = "inr" paymentReq.transAmount = "120" paymentReq.billingEmail = "test@test.com" paymentReq.billingPhone = "1234" paymentReq.billingFName = "test" paymentReq.billingLName = "test" paymentReq.billingTitle = "Mr" paymentReq.city = "test" paymentReq.country = "test" paymentReq.region = "test" paymentReq.address = "test" paymentReq.zip = "test" paymentReq.language = "en" return paymentReq } |
5. Then you need to send the data to telr payment controller
and delegate where you want. the delegate will use to fetch the response of the payment
1 2 3 4 5 6 |
paymentRequest = preparePaymentRequest() let telrController = TelrController() telrController.delegate = self telrController.customBackButton = customBackButton telrController.paymentRequest = paymentRequest! self.navigationController?.pushViewController(telrController, animated: true) |
6. then you need to implement its delegate
For payment cancel
1 2 3 4 |
func didPaymentCancel() { print("didPaymentCancel") self.showAlert(message: "didPaymentCancel", type: "Cancel") } |
For payment success
in this method you can fatch all the detail which you have provided to initialize the payment gateway like address, card last 4 digit etc
1 2 3 4 |
func didPaymentSuccess(response: TelrResponseModel) { // in the response you can find all data } |
For payment failer
1 2 3 4 5 |
//Mark:- This method call when user click on cancel button and if payment get failed func didPaymentFail(messge: String) { print("didPaymentFail") self.showAlert(message: "didPaymentFail \(messge)", type: "Fail") } |
Now you can execute the above code and you can receive payment through Terl payment gateway
Thanks for reading 🙂
Hope this blog helped you with a better understanding of Telr payment method.
For more technical blogs please visit here.
Wants to know more about telr payment gateway please visit here.