In this blog, we are going to learn about how to integrate Paybox Payment Gateway in Swift with SDK approach.
Before integrating a payment gateway first we need to know what is a payment gateway.
A payment gateway is a technology used by merchants to accept debit or credit card purchases from customers.
Paybox provides a list of payment methods:
- CB, VISA, MASTERCARD
- MAESTRO
- BANCONTACT
- MISTERCASH
- E-CARTE BLEUE
- AMERICAN EXPRESS
- JCB
Let’s start the integration
Please follow the below steps in your iOS project
Step – 1
Please install the paybox pod in your project
1 |
pod 'PayBoxSdk', :git => 'https://github.com/PayBox/SDK_iOS-input-.git', :submodules => true |
Step – 2
Now, import the PayBoxSdk in viewcontroller
1 |
import PayBoxSdk |
Step – 3
Set up payment view using storyboard
- Drag & drop an instance of UIView
- Select added view and open Identity Inspector
- Enter the following values:
a. Class: PaymentView
b. Module: PayBoxSdk
After that, create an outlet for payment view.
1 |
@IBOutlet var PaymentView: PaymentView! |
Step – 4
Initialize Payment:
We need merchantid and SecretKey for sdk initialization
1 2 3 4 5 6 |
let sdk = PayboxSdk.initialize(merchantId: MerchantId!, secretKey: SecretKey) sdk.setPaymentView(paymentView: PaymentView) PaymentView.delegate = self |
Step – 5
To transfer information from the payment gate:
1 2 |
sdk.config().setCheckUrl(url: CheckURL) sdk.config().setResultUrl(url: ResultURL) |
Step – 6
Payment creation:
1 2 3 4 5 6 7 8 9 10 11 |
extra["amount"] = "\(amount)" extra["merchanID"] = "\(MerchantId)" extra["SecretKey"] = SecretKey extra["orderId"] = orderId sdk.createPayment(amount: Float(amount ?? 0), description: "description", orderId: orderId, userId: orderId, extraParams: extra) { payment, error in print(error) print(payment) } |
Step – 7
To track the progress of the payment page loading, use the WebDelegate:
1 2 3 4 5 6 7 8 9 10 11 12 |
extension PayboxPaymentViewController: WebDelegate{ func loadStarted() { } func loadFinished() { } } |
Conclusion:
In this blog, we have learned about the integration of the Paybox payment gateway integration by using SDK.
For more information regarding the Paybox payment gateway follow the link.
If you have any issues or suggestions you can leave your query/suggestion in the comment section.