api_payment

Easy payment API for online systems. Works on all platforms (Android, iOS, Web, Windows).

Features

  • Manage the payment process for users
  • Simple integration
  • Two display modes:
    • Box (inline integration)
    • Modal (popup dialog)

Screenshots

Box Display Modal Display

Getting Started

Installation

Add to your pubspec.yaml:

dependencies:
  api_payment: ^0.0.3

Usage

Import the package:

import 'package:api_payment/yt_ypay.dart';

Minimal Example

1. Create a YtYpay instance

Parameters:

  • clientId (required): The ID provided by the Ytech Ypay platform
  • title (required): Your app title
  • amount (required): The payment amount
YtYpay ypay = YtYpay(
  clientId: "clientId", 
  title: "App Title", 
  amount: 500.0, 
);

2. Use the instance inside your widget

Call the method payment from the ypay instance to initialize the payment view.

🛠️ Arguments

  • displayType (DisplayTypes, optional)

    Determines how the payment UI is displayed.

    Default : DisplayTypes.BOX
    Options :
    BOX: Embeds the payment UI as a widget (no context needed)
    MODAL: Shows the payment UI in a dialog (requires context)

  • context (BuildContext, optional)
    Required only if displayType = DisplayTypes.MODAL.

  • maxWith (double, optional)
    Sets a maximum width constraint for the payment widget.

  • padding (EdgeInsetsGeometry, optional)
    Adds custom padding around the payment widget.

  • languageCode (String, optional)
    add current languageCode for translation.

    • Default value : en
    • possible values : en, fr, mo
  • onSuccess (Function(dynamic response), optional)
    Callback function triggered when the operation succeeds.

  • onError (Function(dynamic error), optional)
    Callback function triggered when an error occurs.

  • showSuccessDialog (bool, optional)
    Determines whether the default success dialog should be displayed.

    • Default : true
Option 1: DisplayTypes.BOX
// Since `displayType` is set to `BOX` by default, you don't need to provide it.
// The `context` is not needed in `DisplayTypes.BOX` mode.
// Call this as a widget

// Basic usage
ypay.payment();// returns a Widget?

// Customized box
ypay.payment(
  maxWith: 400,                   // Optional max width
  padding: EdgeInsets.all(16),    // Optional padding
  languageCode: 'fr',    // Optional languageCode,default 'en'
);

Option 2: DisplayTypes.MODAL
Padding(
  padding: const EdgeInsets.all(0.0),
  child: Builder(builder: (context) { 
    return ElevatedButton(
      onPressed: () {
        ypay.payment(displayType: DisplayTypes.MODAL, context: context) ?? Container();
      },
      child: const Text("Open in modal"),
    );
  }),
),

Display


Display

Contributors ✨

  • YTECH Developers Team

Would you buy us a coffee 🙋‍♂️😊

  • 📞 +226 07 77 53 31