Switchpay is an intelligent system of routing payment traffic via various payment aggregrators (PA).
Configuration
iOS
Add below keys in info.plist using Xcode. The steps that has to be followed are:
- Open your project target's
info.plistfile. - Add a Key called
NSAppTransportSecurityas a Dictionary. - Add a Subkey called
NSAllowsArbitraryLoadsasBooleanand set its value toYES.
or
In source code of info.plist file we can add that:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Android
Add the below line in your application tag of AndroidManifest.xml:
android:usesCleartextTraffic="true"
As shown below:
<application
....
android:usesCleartextTraffic="true"
....>
Usage
To use this plugin, add switchpay as a dependency in your pubspec.yaml file.
The switchpay package can be imported using:
import 'package:switchpay/switchpay.dart';
Example
Switchpay(
context: context,
url: 'your_context',
token: 'your_token',
uuid: 'your_uuid',
orderId: 'your_unique_order_id',
amount: 'transactional_amount',
name: 'customer_name',
emailId: 'customer_email',
mobileNumber: 'customer_mobile_number',
description: 'description_for_record',
enabledModeOfPayment: 'instrument like upi or cc',
onInitLoading: (isLoading) {
// TODO: Show loading action while redirecting.
},
onTransactionCompleted: (status) {
// TODO: Action after transaction completion. (Deprecated)
},
onTransactionDone: (status) {
// TODO: Action after transaction completion. (Deprecated)
},
onTransactionFinished: (status) {
// TODO: Action after transaction completion. (Recommended)
},
onErrorOccurred: (error) {
// TODO: Action if any error occured.
});
onCancel: (error) {
// TODO: Action if user click on back button.
});