pgw_sdk 4.0.3 copy "pgw_sdk: ^4.0.3" to clipboard
pgw_sdk: ^4.0.3 copied to clipboard

2C2P PGW SDK for flutter and allows merchants to build an excellent payment experience within their mobile apps by integrating easily with 2C2P's payment gateway. As 2C2P provides omnichannel payment [...]

example/lib/main.dart

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:pgw_sdk/core/pgw_sdk_pigeon.dart';
import 'package:pgw_sdk_example/scenes/home_screen.dart';
import 'apis/info_api.dart';
import 'apis/payment_api.dart';
import 'apis/config.dart';
import 'constants.dart';

/// PGW SDK feature
final api = PGWApi();
final apiHelper = PGWHelperApi();

/// PGW SDK feature examples
final infoApi = InfoApi();
final paymentApi = PaymentApi();
final List infoApiList = [];
final List paymentApiList = [];

void main() {

  runApp(const MyApp());

  try {

    /// Request: https://developer.2c2p.com/v4.3.0/docs/sdk-classes-payment-request#init-pgw-sdk
    ///Note: Important due to PGW SDK has to initialize before request APIs.
    String request = json.encode({
      'apiEnvironment': Config.apiEnvironment,
      'log': true
    });

    api.initialize(request);
  } on PlatformException catch (error) {

    ///Handle error from PGWSDK
    ///Get error response and display error
    debugPrint('${Constants.titlePGWSDKError} Error: ${error.code}, ${error.message}, ${error.details}');
  } catch (error) {

    ///Other types of Exceptions
    ///Get error response and display error
    debugPrint('${Constants.titleCommonError} Error: ${error.toString()}');
  }

  initFeatureList();
}

void initFeatureList() {

  infoApiList.clear();
  infoApiList.add((Constants.apiClientId, infoApi.clientId, Icons.cloud_outlined));
  infoApiList.add((Constants.apiConfiguration, infoApi.configuration, Icons.cloud_outlined));
  infoApiList.add((Constants.apiPaymentOption, infoApi.paymentOption, Icons.cloud_outlined));
  infoApiList.add((Constants.apiPaymentOptionDetail, infoApi.paymentOptionDetail, Icons.cloud_outlined));
  infoApiList.add((Constants.apiCustomerTokenInfo, infoApi.customerTokenInfo, Icons.cloud_outlined));
  infoApiList.add((Constants.apiExchangeRate, infoApi.exchangeRate, Icons.cloud_outlined));
  infoApiList.add((Constants.apiUserPreference, infoApi.userPreference, Icons.cloud_outlined));
  infoApiList.add((Constants.apiTransactionStatus, infoApi.transactionStatus, Icons.cloud_outlined));
  infoApiList.add((Constants.apiSystemInitialization, infoApi.systemInitialization, Icons.cloud_outlined));
  infoApiList.add((Constants.apiPaymentNotification, infoApi.paymentNotification, Icons.cloud_outlined));
  infoApiList.add((Constants.apiCancelTransaction, infoApi.cancelTransaction, Icons.cloud_outlined));
  infoApiList.add((Constants.apiLoyaltyPointInfo, infoApi.loyaltyPointInfo, Icons.cloud_outlined));

  paymentApiList.clear();
  paymentApiList.add((Constants.paymentGlobalCreditDebitCard, paymentApi.globalCreditDebitCard, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentLocalCreditDebitCard, paymentApi.localCreditDebitCard, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentCustomerTokenization, paymentApi.customerTokenization, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentCustomerTokenizationWithoutAuthorisation, paymentApi.customerTokenizationWithoutAuthorisation, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentCustomerToken, paymentApi.customerToken, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentInstallmentPaymentPlan, paymentApi.installmentPaymentPlan, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentRecurringPaymentPlan, paymentApi.recurringPaymentPlan, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentThirdPartyPayment, paymentApi.thirdPartyPayment, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentUserAddressForPayment, paymentApi.userAddressForPayment, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentOnlineDirectDebit, paymentApi.onlineDirectDebit, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentDeepLinkPayment, paymentApi.deepLinkPayment, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentInternetBanking, paymentApi.internetBanking, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentWebPayment, paymentApi.webPayment, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentPayAtCounter, paymentApi.payAtCounter, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentSelfServiceMachines, paymentApi.selfServiceMachines, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentQRPayment, paymentApi.qrPayment, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentBuyNowPayLater, paymentApi.buyNowPayLater, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentDigitalPayment, paymentApi.digitalPayment, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentLinePay, paymentApi.linePay, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentApplePay, paymentApi.applePay, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentGooglePay, paymentApi.googlePay, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentCardLoyaltyPointPayment, paymentApi.cardLoyaltyPointPayment, Icons.energy_savings_leaf_outlined));
  paymentApiList.add((Constants.paymentZaloPay, paymentApi.zaloPay, Icons.energy_savings_leaf_outlined));
}

class MyApp extends StatelessWidget {

  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      title: Constants.titleAppName,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.lightBlue),
        useMaterial3: true,
      ),
        home: const CustomTabBar()
    );
  }
}
6
likes
0
pub points
85%
popularity

Publisher

verified publisher2c2p.com

2C2P PGW SDK for flutter and allows merchants to build an excellent payment experience within their mobile apps by integrating easily with 2C2P's payment gateway. As 2C2P provides omnichannel payment processing, the Payment Gateway SDK gives merchants access to a full suite of payment options.

Homepage

License

unknown (license)

Dependencies

flutter, pigeon, webview_flutter

More

Packages that depend on pgw_sdk