{"id":22841165,"url":"https://github.com/iamnabink/fonepay_flutter","last_synced_at":"2025-10-27T18:08:36.146Z","repository":{"id":74182016,"uuid":"604945589","full_name":"iamnabink/fonepay_flutter","owner":"iamnabink","description":"An un-official Flutter plugin for Fonepay Payment Gateway, integrate with ease and without any hassle.","archived":false,"fork":false,"pushed_at":"2024-01-23T10:24:25.000Z","size":2224,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T05:25:28.684Z","etag":null,"topics":["android","dart","flutter","flutter-plugin","ios","package","payment-gateway","payment-integration","pub"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/fonepay_flutter","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamnabink.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-22T05:29:15.000Z","updated_at":"2024-10-18T09:39:17.000Z","dependencies_parsed_at":"2024-01-23T11:44:35.047Z","dependency_job_id":null,"html_url":"https://github.com/iamnabink/fonepay_flutter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iamnabink/fonepay_flutter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnabink%2Ffonepay_flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnabink%2Ffonepay_flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnabink%2Ffonepay_flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnabink%2Ffonepay_flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamnabink","download_url":"https://codeload.github.com/iamnabink/fonepay_flutter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamnabink%2Ffonepay_flutter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267009882,"owners_count":24020690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","dart","flutter","flutter-plugin","ios","package","payment-gateway","payment-integration","pub"],"created_at":"2024-12-13T01:15:01.935Z","updated_at":"2025-10-27T18:08:36.039Z","avatar_url":"https://github.com/iamnabink.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FonePay Flutter [![Share on Twitter](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Flutter%20FonePayPayment%20plugin!\u0026url=https://github.com/iamnabink/fonepay_flutter\u0026hashtags=flutter,flutterio,dart,wallet,fonepay,paymentgateway) [![Share on Facebook](https://img.shields.io/badge/share-facebook-blue.svg?longCache=true\u0026style=flat\u0026colorB=%234267b2)](https://www.facebook.com/sharer/sharer.php?u=https%3A//github.com/iamnabink/fonepay_flutter)\n\n[![Pub Version](https://img.shields.io/pub/v/fonepay_flutter.svg)](https://pub.dev/packages/fonepay_flutter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nAn un-official Flutter plugin for FonePay Payment Gateway. With this plugin, you can easily\nintegrate FonePay Payment Gateway into your Flutter app and start accepting payments from your\ncustomers. Whether you're building an eCommerce app or any other type of app that requires payments,\nthis plugin makes the integration process simple and straightforward.\n\n![Cover Image](https://github.com/iamnabink/fonepay_flutter/raw/master/screenshots/cover.png)\n\n# Note\n\nThis package doesn't use any plugin or native APIs for payment initialization. Instead, it is based\non the Flutter InAppWebView package. A shoutout to the developer\nof [InAppWebView](https://pub.dev/packages/flutter_inappwebview)\npackage for providing such a useful package.\n\n## Features\n\n- Easy integration\n- No complex setup\n- Pure Dart code\n- Simple to use\n\n## Requirements\n\n* Android: `minSdkVersion 17` and add support for `androidx` (\n  see [AndroidX Migration](https://flutter.dev/docs/development/androidx-migration))\n* iOS: `--ios-language swift`, Xcode version `\u003e= 11`\n\n## Setup\n\n| Platform | Configuration                                                                                                                                                                   |\n|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| iOS      | No Configuration Needed. For more info, [see here](https://pub.dev/packages/flutter_inappwebview#important-note-for-ios)                                                        |\n| Android  | Set `minSdkVersion` of your `android/app/build.gradle` file to at least 17. For more info, [see here](https://pub.dev/packages/flutter_inappwebview#important-note-for-android) |\n\n# Usage\n\n1. Add `fonepay_flutter` as a dependency in your `pubspec.yaml` file:\n\n```yaml\ndependencies:\n  fonepay_flutter: ^1.0.0\n```\n\n2. Import the package in your Dart code:\n\n```import 'package:fonepay_flutter/fonepay_flutter.dart';```\n\n3. Create an instance of `FonePayConfig` with your payment information:\n\nThe `FonePayConfig` class holds the configuration details for the payment gateway. Pass an instance\nof\n`FonePayConfig` to the init() method of the `FonePay` class to initiate the payment process.\n\n```dart\n\nfinal config = FonePayConfig.live(\n  pid: 'liveMerchantCode',\n  ru: 'https://example.com/fonepay/return',\n  prn: '123456',\n  amt: 100.0,\n  sk: 'mySecretKey',\n  r1: 'Payment for order #123',\n  r2: 'Additional info',\n);\n```\n\n4. Initialize the payment by calling `FonePay.init()` method:\n\n```\nfinal result = await FonePay.i.init(\n  context: context,\n  fonePayConfig: config,\n);\n```\n\n5. Check the payment result:\n\nAfter the payment is completed or cancelled by the user, the plugin returns an instance of\nFonePayPaymentResult. If the payment was successful, hasData will be true and you can access the\nFonePayResponse object using data. If the payment was unsuccessful, hasError will be true and you\ncan access the error message using error.\n\n```\nif (result.hasData) {\n  // Payment successful\n  final response = result.data!;\n  print('Payment successful. Ref ID: ${response.uid}');\n} else {\n  // Payment failed or cancelled\n  final error = result.error!;\n  print('Payment failed or cancelled. Error: $error');\n}\n```\n\n# Dev/Live Mode\n\n`FonePayConfig` supports both dev and live mode. For live mode, use the `FonePayConfig.live()`\nconstructor, and for dev mode, use the `FonePayConfig.dev()` constructor. Here's an example of using\nthe dev mode:\n\n```dart\n\nfinal config = FonePayConfig.dev(\n  ru: 'https://example.com/fonepay/return',\n  prn: '123456',\n  amt: 100.0,\n  r1: 'Payment for order #123',\n  r2: 'Additional info',\n);\n```\n\n# APIs\n\n## Class : FonePay\n\nThe `FonePay` provides a way to initialize FonePay payment using a custom button or a custom UI.\nHere's an example:\n\n### Methods\n\n ```\n init({required BuildContext context,required FonePayConfig fonePayConfig,FonePayPageContent? pageContent})\n ```\n\nInitializes payment method\n\n```dart\nfinal result = await FonePay.i.init(\n                    context: context,\n                    fonePayConfig: FonePayConfig.dev(\n                      amt: 10.0,\n                      r2: 'https://www.marvel.com/hello',\n                      ru: 'https://www.marvel.com/hello',\n                      r1: 'qwq',\n                      prn: 'PD-2-${FonePayUtils.generateRandomString(len: 2)}',\n                    ));\n\n```\n\n## Class : FonePayPageContent\n\nThe `FonePayPageContent` class provides options for customizing the FonePay payment screen. You can\nadd an app bar and a custom loader to the payment screen. Here's an example:\n\n```\nFonePayPageContent(\n  appBar: AppBar(\n    title: Text('FonePay Payment'),\n  ),\n  progressLoader: CircularProgressIndicator(),\n);\n\n```\n\n## Class: FonePayConfig\n\nThe `FonePayConfig` class provides configuration options for FonePay payments.\n\n### Properties\n\n- `ru` (required): Live - Return Url where FonePay system notifies payment information to merchant\n  site.\n- `serverUrl`: FonePay prod server URL. Defaults\n  to \"https://clientapi.fonepay.com/api/merchantRequest?\".\n- `sk` (required): Secret key for the FonePay account.\n- `pid`: Live Merchant Code, defined by FonePay system. Defaults to \"fonepay123\".\n- `prn` (required): Product Reference Number, need to be sent by the merchant. Must be between 3 and\n  25 characters.\n- `amt` (required): Payable amount, specified as a double with a maximum of 18 digits.\n- `crn`: Currency code. Defaults to \"NPR\".\n- `dt`: Payment date in MM/dd/yyyy format. Defaults to the current date.\n- `r1` (required): Payment details that identify what the payment was for (e.g., receipt ID or\n  payment description).\n- `r2`: Additional information, defaults to \"N/A\".\n- `md`: Payment mode, defaults to \"P\".\n- `dv`: SHA512 hashed value, generated using the secure hash calculation method described below.\n\n### Methods\n\n#### FonePayConfig.live\n\nInitializes a configuration for FonePay live payments.\n\n### Parameters\n\n- `pid` (required): Live Merchant Code, defined by FonePay system.\n- `ru` (required): Live - Return Url where FonePay system notifies payment information to merchant\n  site.\n- `prn` (required): Product Reference Number, need to be sent by the merchant.\n- `amt` (required): Payable amount.\n- `crn`: Currency code. Defaults to \"NPR\".\n- `dt`: Payment date in MM/dd/yyyy format. Defaults to the current date.\n- `sk` (required): Secret key for the FonePay account.\n- `r1` (required): Payment details that identify what the payment was for.\n- `r2`: Additional information. Defaults to \"N/A\".\n- `md`: Payment mode. Defaults to \"P\".\n\n### Example\n\n```dart\n\nfinal config = FonePayConfig.live(\n  pid: 'liveMerchantCode',\n  ru: 'https://example.com/fonepay/return',\n  prn: '123456',\n  amt: 100.0,\n  sk: 'mySecretKey',\n  r1: 'Payment for order #123',\n  r2: 'Additional info',\n);\n```\n\n### FonePayConfig.dev\n\nInitializes a configuration for FonePay development stage.\n\n### Parameters\n\n- `ru` (required): Live - Return Url where FonePay system notifies payment information to merchant\n  site.\n- `prn` (required): Product Reference Number, need to be sent by the merchant.\n- `amt` (required): Payable amount.\n- `crn`: Currency code. Defaults to \"NPR\".\n- `dt`: Payment date in MM/dd/yyyy format. Defaults to the current date.\n- `r1` (required): Payment details that identify what the payment was for.\n- `r2`: Additional information. Defaults to \"N/A\".\n- `md`: Payment mode. Defaults to \"P\".\n\n### Example\n\n```dart\n\nfinal config = FonePayConfig.dev(\n  ru: 'https://example.com/fonepay/return',\n  prn: '123456',\n  amt: 100.0,\n  r1: 'Payment for order #123',\n  r2: 'Additional info',\n);\n```\n\n## Class: FonePayResponse\n\nRepresents a response from the FonePay API.\n\n### Properties\n\n| Name   | Type     | Description                                   |\n|--------|----------|-----------------------------------------------|\n| `prn`  | `String` | The payment reference number.                 |\n| `pid`  | `String` | The merchant's payment identifier.            |\n| `ps`   | `String` | The payment status.                           |\n| `rc`   | `String` | The response code.                            |\n| `uid`  | `String` | The unique transaction identifier.            |\n| `bc`   | `String` | The bank code.                                |\n| `ini`  | `String` | The transaction initialization date and time. |\n| `pAmt` | `String` | The paid amount.                              |\n| `rAmt` | `String` | The refund amount.                            |\n| `dv`   | `String` | The device type.                              |\n\n### Methods\n\n#### `toJson()`\n\nConverts the `FonePayResponse` instance to a JSON object.\n\n**Returns**\n\nA `Map` object representing the `FonePayResponse` instance.\n\n## Class: FonePayPaymentResult\n\nClass representing the result of a payment transaction.\n\n### Properties\n\n- `data`: The payment response data, if the payment was successful. Null otherwise.\n- `error`: The error message, if the payment failed or was cancelled. Null otherwise.\n- `hasData`: A boolean indicating whether the payment was successful and contains a non-null data\n  property.\n- `hasError`: A boolean indicating whether the payment failed or was cancelled and contains a\n  non-null error property.\n\n## Class: FonePayButton\n\nThe `FonePayButton` class is a `StatelessWidget` that represents a button that initiates a FonePay\npayment. It takes several parameters to configure the button and initiate the payment.\n\n### Parameters\n\n- `width` (optional): The width of the button.\n- `height` (optional): The height of the button.\n- `onSuccess` (required): A callback function that will be called when the payment is successful. It\n  takes a `FonePayResponse` object as its parameter.\n- `onFailure` (required): A callback function that will be called when the payment fails. It takes a\n  failure message as its parameter.\n- `paymentConfig` (required): A `FonePayConfig` object that contains the configuration for the\n  FonePay payment.\n- `radius` (optional): The border radius of the button.\n- `widget` (optional): A widget that will be displayed instead of the button title. This can be used\n  to display an icon or a custom widget.\n- `title` (optional): The title of the button. The default value is \"Pay with FonePay\".\n- `textStyle` (optional): The text style of the button title.\n- `style` (optional): The `ButtonStyle` of the button.\n\n### Example Usage\n\n```\nFonePayButton(\n    paymentConfig: FonePayConfig(),\n    onSuccess: (response) {\n        // Handle successful payment\n        print('Payment successful! Response: ${response.toJson()}');\n    },\n    onFailure: (message) {\n        // Handle failed payment\n        print('Payment failed. Message: $message');\n    },\n)\n```\n\n## Class: FonePayUtils\n\nThe `FonePayUtils` class provides utility functions for FonePay integration.\n\n### Static Method: formatDate\n\n```dart\nstatic String formatDate\n(\n\nDateTime date\n)\n```\n\nReturns the formatted date string in the format of MM/dd/yyyy.\n\n`date` (required): The `DateTime` object to be formatted.\n\n### Method: generateRandomString\n\n```dart\nString generateRandomString({int? len})\n```\n\n* Generates a random string of specified length or a default length of 6 if not specified.\n\n`len` (optional): The length of the random string to be generated. If not specified, the default\nlength of 6 will be used. Note: To prevent payment request failure due to duplicate PRN number\nin `FonePayConfig`, it is recommended to generate a unique `PRN` number by utilizing this method.\n\n## Dev Testing Information\n\nTo access the development environment, use the following credentials:\n\n- Bank: Any bank available in dev mode [Currently  Global IME Bank]\n- Username: [any 10 digit random Nepali number starting with 98]\n- Password: [anything random, like 1212122]\n- OTP: [anything random, like 1212122]\n\nPlease note that these credentials are for testing purposes only and should not be used in\nproduction.\n\n## Screenshots\n\nHere are some screenshots of the FonePay Payment Gateway integrated into a ecommerce Flutter app:\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"https://github.com/iamnabink/fonepay_flutter/raw/master/screenshots/order_screen.png\" alt=\"Example Order Screen\" width=\"400\"/\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://github.com/iamnabink/fonepay_flutter/raw/master/screenshots/payment_screen.png\" alt=\"Payment Screen\" width=\"400\"/\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## Run the example app\n\n- Navigate to the [example](https://github.com/iamnabink/fonepay_flutter/tree/master/lib) folder\n- `cd example`\n- Install the dependencies\n    - `flutter pub get`\n- Set up configuration `FonePayConfig.live()` or directly run with just `FonePayConfig.dev()` in dev\n  mode\n- Start the example\n    - Terminal : `flutter run`\n\n# License\n\nThis plugin is released under the MIT License. See LICENSE for details.\n\n## Contributions\n\nContributions are welcome! To make this project better, Feel free to open an issue or submit a pull\nrequest on [Github](https://github.com/iamnabink/fonepay_flutter/issues)..\n\n## Contact\n\nIf you have any questions or suggestions, feel free\nto [contact me on LinkedIn](https://www.linkedin.com/in/iamnabink/).\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamnabink%2Ffonepay_flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamnabink%2Ffonepay_flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamnabink%2Ffonepay_flutter/lists"}