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 platformtitle
(required): Your app titleamount
(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 ifdisplayType = 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
- Default value :
-
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
- Default :
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
Contributors ✨
- YTECH Developers Team
Would you buy us a coffee 🙋♂️😊
- 📞 +226 07 77 53 31
Libraries
- api_payment
- api_payment_method_channel
- api_payment_platform_interface
- api_payment_web
- core/api/client
- core/api/exception
- models/transaction
- provider/api_provider
- provider/verify_provider
- utils/compnents/widgets/custom_text
- utils/compnents/widgets/custom_text_field
- utils/compnents/widgets/otp_field_widget
- utils/constants/app_constant
- utils/enums/api_routes
- utils/enums/display_types
- utils/functions/function
- utils/lang/app_content
- utils/lang/default_payment_translation
- utils/themes/app_colors
- utils/validators/form_validator
- utils/widgets
- utils/widgets/transction_rows
- yt_core
- yt_ypay