in_app_payment 0.0.2 copy "in_app_payment: ^0.0.2" to clipboard
in_app_payment: ^0.0.2 copied to clipboard

In app payment package for the stage 6 task of the HNGx Internship. This package would enable flutter developers make payments through google pay and apple pay in their application.

A package to add google pay and apple pay to your Flutter application. It is the payment package for the stage 5 task of HNGx internship.

Platform Support #

Android Google Pay
iOS: Apple Pay

Features #

This package helps to integrate Google pay and Apple pay into your app.

Getting started #

Usage #

  1. Import the package into your project. To start using this plugin, add in_app_payment as a dependency in your pubspec.yaml file:

    dependencies:
    in_app_payment: ^0.0.2
    
  2. Initialize HNGPay:

       final pay = HNGPay();
    
  3. For Android, invoke the googlePay function in place of your 'pay' button in your app and pass the amount to be paid as argument.

    pay.googlePay(context, amountToPay: "24", userID: '23')
    
  4. For IOS, invoke the applePay function in place of your 'pay' button in your app and pass the amount to be paid as argument.

    pay.applePay(context, amountToPay: "24", userID: '23'),
    

Example #

This snippet assumes the existence a payment configuration

import 'package:flutter/material.dart';
import 'package:in_app_payment/in_app_payment.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
    
    final pay = HNGPay();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text("Payment test"),
      ),
      body: Center(
        child: Container(
          child: pay.googlePay(context, amountToPay: "24", userID: '23'), //for android implementaion
        ),
      ),
    );
  }
}

Authors #

3
likes
120
pub points
57%
popularity

Publisher

unverified uploader

In app payment package for the stage 6 task of the HNGx Internship. This package would enable flutter developers make payments through google pay and apple pay in their application.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, http, pay

More

Packages that depend on in_app_payment