fourpaypayments 0.1.3 copy "fourpaypayments: ^0.1.3" to clipboard
fourpaypayments: ^0.1.3 copied to clipboard

outdated

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
30
pub points
0%
popularity

Publisher

verified publisher4pay.online

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

Homepage

License

unknown (LICENSE)

Dependencies

dio, flutter

More

Packages that depend on fourpaypayments