fourpaypayments 0.1.4
fourpaypayments: ^0.1.4 copied to clipboard

Flutter Android iOS

4pay.online allows you to accept payments - comfortably and safely.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';

import 'package:fourpaypayments/fourpaypayments.dart';
import 'package:uuid/uuid.dart';

void main() => runApp(
      MyApp(
        config: {
          "linkId": "your_auth_token",
          "apple_pay_params": {"merchant_identifier": "merchant.YourId"},
          "gpay_params": {
            "gateway": "themap",
            "gatewayMerchantId": "yourGatewayMerchantId",
            "merchantId": "yourMerchantId",
            "merchantName": "yourMerchantName"
          },
          'amount': 1,
          'txid': Uuid().v1(),
        },
      ),
    );

class MyApp extends StatefulWidget {
  final Map<String, dynamic> config;

  MyApp({
    Key key,
    this.config,
  }) : super(key: key);
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

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

  @override
  Widget build(BuildContext context) {

    
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              RaisedButton(
                child: Text('Test Apple Pay'),
                onPressed: () async {
                  var result = await _makeApplePay();
                  print(result);
                },
              ),
              SizedBox(height: 20),
              RaisedButton(
                child: Text('Test Google Pay'),
                onPressed: () async {
                  var result = await _makeGooglePay();
                  print(result);
                },
              ),
            ],
          ),
        ),
      ),
    );
  }

  Future<PaymentResult> _makeApplePay() {
    return FourPayPayments.makeApplePayment(
      widget.config['linkId'],
      widget.config['apple_pay_params']['merchant_identifier'],
      label: 'Test Apple Pay',
      description: 'Test Apple Pay',
      amount: 1,
      txid: Uuid().v1(),
    );
  }

  Future<PaymentResult> _makeGooglePay() {
    return FourPayPayments.makeGooglePayment(
      widget.config['linkId'],
      widget.config['gpay_params']['merchantId'],
      amount: 1,
      description: 'Test Google Pay',
      gateway: widget.config['gpay_params']['gateway'],
      environment: 'test',
      merchantInfo: widget.config['gpay_params']['merchantName'],
      txid: Uuid().v1(),
    );
  }
}
3
likes
80
pub points
0%
popularity

Publisher

4pay.online

4pay.online allows you to accept payments - comfortably and safely.

Homepage

Documentation

API reference

License

Apache 2.0 (LICENSE)

Dependencies

dio, flutter

More

Packages that depend on fourpaypayments