PGWSDK for Flutter
A PGW SDK Flutter project.
Getting Started
Add this to your package's pubspec.yaml file:
dependencies:
pgw_sdk: ^0.0.3
System Requirements
The SDK has been developed using Dart version >=2.12.0
, iOS Deployment Target 12.0
, and Android Version 6 (API Level 23)
. To ensure you can actually compile the sdk smoothly, we recommend to use the developed versions. However if needed, you can convert to your preferred version.
Platform | Minimum Version |
---|---|
iOS | 11.0 |
Android | 6 (API Level 23) |
Dart SDK | 2.12.0 |
Initialize
Add initialize to your main.dart file
PGWSDK.initialize(APIEnvironment.Production);
** Change to APIEnvironment.Sandbox
if test needed. For more information follow this link
Usage
Card Payment
Import the library to your file
import 'package:pgw_sdk/builder/card_payment_builder.dart';
import 'package:pgw_sdk/models/payment_code.dart';
import 'package:pgw_sdk/models/transaction_result_request_builder.dart';
import 'package:pgw_sdk/pgw_sdk.dart';
After get payment token from merchant server then construct transaction request
var paymentCode = PaymentCode(channelCode: 'CC');
var paymentRequest = CardPaymentBuilder(paymentCode: paymentCode, cardNo: '4111111111111111')
.setExpiryMonth(12)
.setExpiryYear(2021)
.setSecurityCode('123')
.build();
var request = TransactionResultRequestBuilder(
paymentToken: 'PAYMENT_TOKEN',
paymentRequest: paymentRequest,
);
Execute Payment Request
var result = await PGWSDK.proceedTransaction(request);
var redirectUrl = result.data;
Finally got a redirect url from result.
2c2p supported a list of payment methods. Refer to this link
For more information click here
Payment with Card Token
Import the library to your file
import 'package:pgw_sdk/builder/card_token_payment_builder.dart';
import 'package:pgw_sdk/models/payment_code.dart';
import 'package:pgw_sdk/models/transaction_result_request_builder.dart';
import 'package:pgw_sdk/pgw_sdk.dart';
After get payment token from merchant server then construct transaction request
var paymentCode = PaymentCode(channelCode: 'CC');
var paymentRequest = CardTokenPaymentBuilder(paymentCode: paymentCode, cardToken: cardToken).build();
var request = TransactionResultRequestBuilder(
paymentToken: 'PAYMENT_TOKEN',
paymentRequest: paymentRequest,
);
Execute Payment Request
var result = await PGWSDK.paymentWithCardToken(request);
var redirectUrl = result.data;
Finally got a redirect url from result.
Payment Features Example Usage
This project has been created example app for test the function of SDK so this is how to use some feature that quite complicated.
Contributing
2C2P
License
Libraries
- builder/card_payment_builder
- builder/card_token_payment_builder
- builder/digital_payment_builder
- builder/internet_banking_builder
- builder/pay_at_counter_builder
- builder/qr_payment_builder
- builder/self_service_machine_builder
- builder/web_payment_builder
- models/api_environment
- models/card_token_info/card_token_info_request
- models/card_token_info/card_token_info_response
- models/exchange_rate/exchange_rate_request
- models/exchange_rate/exchange_rate_response
- models/payment_code
- models/payment_data
- models/payment_info
- models/payment_option/payment_option_request
- models/payment_option/payment_option_response
- models/payment_option_detail/payment_option_detail_request
- models/payment_option_detail/payment_option_detail_response
- models/payment_request
- models/transaction_result_request_builder
- models/transaction_result_response
- models/transaction_status/transaction_status_request
- models/transaction_status/transaction_status_response
- models/univeral_payment_builder
- pgw_sdk
- ui/constants/colours
- ui/constants/payment_method_type
- ui/constants/styles
- ui/scenes/credit_card/credit_card_interactor
- ui/scenes/credit_card/credit_card_page
- ui/scenes/credit_card/credit_card_router
- ui/scenes/proceed/proceed_page
- ui/utils/input_formatters
- ui/widgets/app_bar_custom
- ui/widgets/dialog_view
- ui/widgets/loading_dialog
- ui/widgets/text_field_custom