softtek_openpay 1.0.1 copy "softtek_openpay: ^1.0.1" to clipboard
softtek_openpay: ^1.0.1 copied to clipboard

unlistedoutdated

This plugin was be designed to facilitate the connect process with OpenPay for Android an iOS devices apps.

example/lib/main.dart

import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:softtek_openpay/softtek_openpay.dart';

import 'model/open_pay_request.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  /// initPlatformState
  ///
  /// Generate a new token with Openpay using OpenPayRequest model, the response will be a json
  Future<void> initPlatformState() async {
    String openPayToken;
    try {
      const request = OpenPayRequest(
        credentials: OpenPayCredentials(
          productionMode: false,
          merchant: 'MERCHANT_ID',
          apiKey: 'API_KEY',
        ),
        cardInfo: OpenPayCardInfo(
          name: 'Luis Alberto Gutierrez Loz',
          cardNumber: '4111111111111111',
          expirationMonth: 12,
          expirationYear: 23,
          cvv: '123',
        ),
      );
      final requestJson = jsonEncode(request);
      openPayToken = await SofttekOpenpay.getToken(requestJson);
    } on PlatformException {
      openPayToken = 'Failed to get openPay Token.';
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = openPayToken;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('OpenPay Tokenization '),
        ),
        body: Center(
          child: Text('Openpay Token: $_platformVersion\n'),
        ),
      ),
    );
  }
}
2
likes
0
points
56
downloads

Publisher

unverified uploader

Weekly Downloads

This plugin was be designed to facilitate the connect process with OpenPay for Android an iOS devices apps.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on softtek_openpay

Packages that implement softtek_openpay