Zoie  Trantow

Zoie Trantow

1678852858

An Un-official Flutter Plugin for FonePay Payment Gateway

FonePay Flutter

An un-official Flutter plugin for FonePay Payment Gateway. With this plugin, you can easily integrate FonePay Payment Gateway into your Flutter app and start accepting payments from your customers. Whether you're building an eCommerce app or any other type of app that requires payments, this plugin makes the integration process simple and straightforward.

Cover Image

Note

This package doesn't use any plugin or native APIs for payment initialization. Instead, it is based on the Flutter InAppWebView package. A shoutout to the developer of InAppWebView package for providing such a useful package.

Features

  • Easy integration
  • No complex setup
  • Pure Dart code
  • Simple to use

Requirements

  • Android: minSdkVersion 17 and add support for androidx ( see AndroidX Migration)
  • iOS: --ios-language swift, Xcode version >= 11

Setup

PlatformConfiguration
iOSNo Configuration Needed. For more info, see here
AndroidSet minSdkVersion of your android/app/build.gradle file to at least 17. For more info, see here

Usage

  1. Add fonepay_flutter as a dependency in your pubspec.yaml file:
dependencies:
  fonepay_flutter: ^1.0.0

2.    Import the package in your Dart code:

import 'package:fonepay_flutter/fonepay_flutter.dart';

3.    Create an instance of FonePayConfig with your payment information:

The FonePayConfig class holds the configuration details for the payment gateway. Pass an instance of FonePayConfig to the init() method of the FonePay class to initiate the payment process.


final config = FonePayConfig.live(
  pid: 'liveMerchantCode',
  ru: 'https://example.com/fonepay/return',
  prn: '123456',
  amt: 100.0,
  sk: 'mySecretKey',
  r1: 'Payment for order #123',
  r2: 'Additional info',
);

4.    Initialize the payment by calling FonePay.init() method:

final result = await FonePay.i.init(
  context: context,
  fonePayConfig: config,
);

5.    Check the payment result:

After the payment is completed or cancelled by the user, the plugin returns an instance of FonePayPaymentResult. If the payment was successful, hasData will be true and you can access the FonePayResponse object using data. If the payment was unsuccessful, hasError will be true and you can access the error message using error.

if (result.hasData) {
  // Payment successful
  final response = result.data!;
  print('Payment successful. Ref ID: ${response.uid}');
} else {
  // Payment failed or cancelled
  final error = result.error!;
  print('Payment failed or cancelled. Error: $error');
}

Dev/Live Mode

FonePayConfig supports both dev and live mode. For live mode, use the FonePayConfig.live() constructor, and for dev mode, use the FonePayConfig.dev() constructor. Here's an example of using the dev mode:


final config = FonePayConfig.dev(
  ru: 'https://example.com/fonepay/return',
  prn: '123456',
  amt: 100.0,
  r1: 'Payment for order #123',
  r2: 'Additional info',
);

APIs

Class : FonePay

The FonePay provides a way to initialize FonePay payment using a custom button or a custom UI. Here's an example:

Methods

init({required BuildContext context,required FonePayConfig fonePayConfig,FonePayPageContent? pageContent})

Initializes payment method

final result = await FonePay.i.init(
                    context: context,
                    fonePayConfig: FonePayConfig.dev(
                      amt: 10.0,
                      r2: 'https://www.marvel.com/hello',
                      ru: 'https://www.marvel.com/hello',
                      r1: 'qwq',
                      prn: 'PD-2-${FonePayUtils.generateRandomString(len: 2)}',
                    ));

Class : FonePayPageContent

The FonePayPageContent class provides options for customizing the FonePay payment screen. You can add an app bar and a custom loader to the payment screen. Here's an example:

FonePayPageContent(
  appBar: AppBar(
    title: Text('FonePay Payment'),
  ),
  progressLoader: CircularProgressIndicator(),
);

Class: FonePayConfig

The FonePayConfig class provides configuration options for FonePay payments.

Properties

  • ru (required): Live - Return Url where FonePay system notifies payment information to merchant site.
  • serverUrl: FonePay prod server URL. Defaults to "https://clientapi.fonepay.com/api/merchantRequest?".
  • sk (required): Secret key for the FonePay account.
  • pid: Live Merchant Code, defined by FonePay system. Defaults to "fonepay123".
  • prn (required): Product Reference Number, need to be sent by the merchant. Must be between 3 and 25 characters.
  • amt (required): Payable amount, specified as a double with a maximum of 18 digits.
  • crn: Currency code. Defaults to "NPR".
  • dt: Payment date in MM/dd/yyyy format. Defaults to the current date.
  • r1 (required): Payment details that identify what the payment was for (e.g., receipt ID or payment description).
  • r2: Additional information, defaults to "N/A".
  • md: Payment mode, defaults to "P".
  • dv: SHA512 hashed value, generated using the secure hash calculation method described below.

Methods

FonePayConfig.live

Initializes a configuration for FonePay live payments.

Parameters

  • pid (required): Live Merchant Code, defined by FonePay system.
  • ru (required): Live - Return Url where FonePay system notifies payment information to merchant site.
  • prn (required): Product Reference Number, need to be sent by the merchant.
  • amt (required): Payable amount.
  • crn: Currency code. Defaults to "NPR".
  • dt: Payment date in MM/dd/yyyy format. Defaults to the current date.
  • sk (required): Secret key for the FonePay account.
  • r1 (required): Payment details that identify what the payment was for.
  • r2: Additional information. Defaults to "N/A".
  • md: Payment mode. Defaults to "P".

Example


final config = FonePayConfig.live(
  pid: 'liveMerchantCode',
  ru: 'https://example.com/fonepay/return',
  prn: '123456',
  amt: 100.0,
  sk: 'mySecretKey',
  r1: 'Payment for order #123',
  r2: 'Additional info',
);

FonePayConfig.dev

Initializes a configuration for FonePay development stage.

Parameters

  • ru (required): Live - Return Url where FonePay system notifies payment information to merchant site.
  • prn (required): Product Reference Number, need to be sent by the merchant.
  • amt (required): Payable amount.
  • crn: Currency code. Defaults to "NPR".
  • dt: Payment date in MM/dd/yyyy format. Defaults to the current date.
  • r1 (required): Payment details that identify what the payment was for.
  • r2: Additional information. Defaults to "N/A".
  • md: Payment mode. Defaults to "P".

Example


final config = FonePayConfig.dev(
  ru: 'https://example.com/fonepay/return',
  prn: '123456',
  amt: 100.0,
  r1: 'Payment for order #123',
  r2: 'Additional info',
);

Class: FonePayResponse

Represents a response from the FonePay API.

Properties

NameTypeDescription
prnStringThe payment reference number.
pidStringThe merchant's payment identifier.
psStringThe payment status.
rcStringThe response code.
uidStringThe unique transaction identifier.
bcStringThe bank code.
iniStringThe transaction initialization date and time.
pAmtStringThe paid amount.
rAmtStringThe refund amount.
dvStringThe device type.

Methods

toJson()

Converts the FonePayResponse instance to a JSON object.

Returns

A Map object representing the FonePayResponse instance.

Class: FonePayPaymentResult

Class representing the result of a payment transaction.

Properties

  • data: The payment response data, if the payment was successful. Null otherwise.
  • error: The error message, if the payment failed or was cancelled. Null otherwise.
  • hasData: A boolean indicating whether the payment was successful and contains a non-null data property.
  • hasError: A boolean indicating whether the payment failed or was cancelled and contains a non-null error property.

Class: FonePayButton

The FonePayButton class is a StatelessWidget that represents a button that initiates a FonePay payment. It takes several parameters to configure the button and initiate the payment.

Parameters

  • width (optional): The width of the button.
  • height (optional): The height of the button.
  • onSuccess (required): A callback function that will be called when the payment is successful. It takes a FonePayResponse object as its parameter.
  • onFailure (required): A callback function that will be called when the payment fails. It takes a failure message as its parameter.
  • paymentConfig (required): A FonePayConfig object that contains the configuration for the FonePay payment.
  • radius (optional): The border radius of the button.
  • widget (optional): A widget that will be displayed instead of the button title. This can be used to display an icon or a custom widget.
  • title (optional): The title of the button. The default value is "Pay with FonePay".
  • textStyle (optional): The text style of the button title.
  • style (optional): The ButtonStyle of the button.

Example Usage

FonePayButton(
    paymentConfig: FonePayConfig(),
    onSuccess: (response) {
        // Handle successful payment
        print('Payment successful! Response: ${response.toJson()}');
    },
    onFailure: (message) {
        // Handle failed payment
        print('Payment failed. Message: $message');
    },
)

Class: FonePayUtils

The FonePayUtils class provides utility functions for FonePay integration.

Static Method: formatDate

static String formatDate
(

DateTime date
)

Returns the formatted date string in the format of MM/dd/yyyy.

date (required): The DateTime object to be formatted.

Method: generateRandomString

String generateRandomString({int? len})
  • Generates a random string of specified length or a default length of 6 if not specified.

len (optional): The length of the random string to be generated. If not specified, the default length of 6 will be used. Note: To prevent payment request failure due to duplicate PRN number in FonePayConfig, it is recommended to generate a unique PRN number by utilizing this method.

Dev Testing Information

To access the development environment, use the following credentials:

  • Bank: Any bank available in dev mode [Currently Global IME Bank]
  • Username: [any 10 digit random Nepali number starting with 98]
  • Password: [anything random, like 1212122]
  • OTP: [anything random, like 1212122]

Please note that these credentials are for testing purposes only and should not be used in production.

Screenshots

Here are some screenshots of the FonePay Payment Gateway integrated into a ecommerce Flutter app:

Example Order ScreenPayment Screen

Run the example app

  • Navigate to the example folder
  • cd example
  • Install the dependencies
    • flutter pub get
  • Set up configuration FonePayConfig.live() or directly run with just FonePayConfig.dev() in dev mode
  • Start the example
    • Terminal : flutter run

Contributions

Contributions are welcome! To make this project better, Feel free to open an issue or submit a pull request on Github..


Download details:

Author: iamnabink
Source code: https://github.com/iamnabink/fonepay_flutter

License: MIT license

#flutter #dart 

What is GEEK

Buddha Community

An Un-official Flutter Plugin for FonePay Payment Gateway

Google's Flutter 1.20 stable announced with new features - Navoki

Flutter Google cross-platform UI framework has released a new version 1.20 stable.

Flutter is Google’s UI framework to make apps for Android, iOS, Web, Windows, Mac, Linux, and Fuchsia OS. Since the last 2 years, the flutter Framework has already achieved popularity among mobile developers to develop Android and iOS apps. In the last few releases, Flutter also added the support of making web applications and desktop applications.

Last month they introduced the support of the Linux desktop app that can be distributed through Canonical Snap Store(Snapcraft), this enables the developers to publish there Linux desktop app for their users and publish on Snap Store.  If you want to learn how to Publish Flutter Desktop app in Snap Store that here is the tutorial.

Flutter 1.20 Framework is built on Google’s made Dart programming language that is a cross-platform language providing native performance, new UI widgets, and other more features for the developer usage.

Here are the few key points of this release:

Performance improvements for Flutter and Dart

In this release, they have got multiple performance improvements in the Dart language itself. A new improvement is to reduce the app size in the release versions of the app. Another performance improvement is to reduce junk in the display of app animation by using the warm-up phase.

sksl_warm-up

If your app is junk information during the first run then the Skia Shading Language shader provides for pre-compilation as part of your app’s build. This can speed it up by more than 2x.

Added a better support of mouse cursors for web and desktop flutter app,. Now many widgets will show cursor on top of them or you can specify the type of supported cursor you want.

Autofill for mobile text fields

Autofill was already supported in native applications now its been added to the Flutter SDK. Now prefilled information stored by your OS can be used for autofill in the application. This feature will be available soon on the flutter web.

flutter_autofill

A new widget for interaction

InteractiveViewer is a new widget design for common interactions in your app like pan, zoom drag and drop for resizing the widget. Informations on this you can check more on this API documentation where you can try this widget on the DartPad. In this release, drag-drop has more features added like you can know precisely where the drop happened and get the position.

Updated Material Slider, RangeSlider, TimePicker, and DatePicker

In this new release, there are many pre-existing widgets that were updated to match the latest material guidelines, these updates include better interaction with Slider and RangeSliderDatePicker with support for date range and time picker with the new style.

flutter_DatePicker

New pubspec.yaml format

Other than these widget updates there is some update within the project also like in pubspec.yaml file format. If you are a flutter plugin publisher then your old pubspec.yaml  is no longer supported to publish a plugin as the older format does not specify for which platform plugin you are making. All existing plugin will continue to work with flutter apps but you should make a plugin update as soon as possible.

Preview of embedded Dart DevTools in Visual Studio Code

Visual Studio code flutter extension got an update in this release. You get a preview of new features where you can analyze that Dev tools in your coding workspace. Enable this feature in your vs code by _dart.previewEmbeddedDevTools_setting. Dart DevTools menu you can choose your favorite page embed on your code workspace.

Network tracking

The updated the Dev tools comes with the network page that enables network profiling. You can track the timings and other information like status and content type of your** network calls** within your app. You can also monitor gRPC traffic.

Generate type-safe platform channels for platform interop

Pigeon is a command-line tool that will generate types of safe platform channels without adding additional dependencies. With this instead of manually matching method strings on platform channel and serializing arguments, you can invoke native class and pass nonprimitive data objects by directly calling the Dartmethod.

There is still a long list of updates in the new version of Flutter 1.2 that we cannot cover in this blog. You can get more details you can visit the official site to know more. Also, you can subscribe to the Navoki newsletter to get updates on these features and upcoming new updates and lessons. In upcoming new versions, we might see more new features and improvements.

You can get more free Flutter tutorials you can follow these courses:

#dart #developers #flutter #app developed #dart devtools in visual studio code #firebase local emulator suite in flutter #flutter autofill #flutter date picker #flutter desktop linux app build and publish on snapcraft store #flutter pigeon #flutter range slider #flutter slider #flutter time picker #flutter tutorial #flutter widget #google flutter #linux #navoki #pubspec format #setup flutter desktop on windows

Adobe XD plugin for Flutter with CodePen Tutorial

Recently Adobe XD releases a new version of the plugin that you can use to export designs directly into flutter widgets or screens. Yes, you read it right, now you can make and export your favorite design in Adobe XD and export all the design in the widget form or as a full-screen design, this can save you a lot of time required in designing.

What we will do?
I will make a simple design of a dialogue box with a card design with text over it as shown below. After you complete this exercise you can experiment with the UI. You can make your own components or import UI kits available with the Adobe XD.

#developers #flutter #adobe xd design export to flutter #adobe xd flutter code #adobe xd flutter code generator - plugin #adobe xd flutter plugin #adobe xd flutter plugin tutorial #adobe xd plugins #adobe xd to flutter #adobe xd tutorial #codepen for flutter.

Terry  Tremblay

Terry Tremblay

1598396940

What is Flutter and why you should learn it?

Flutter is an open-source UI toolkit for mobile developers, so they can use it to build native-looking** Android and iOS** applications from the same code base for both platforms. Flutter is also working to make Flutter apps for Web, PWA (progressive Web-App) and Desktop platform (Windows,macOS,Linux).

flutter-mobile-desktop-web-embedded_min

Flutter was officially released in December 2018. Since then, it has gone a much stronger flutter community.

There has been much increase in flutter developers, flutter packages, youtube tutorials, blogs, flutter examples apps, official and private events, and more. Flutter is now on top software repos based and trending on GitHub.

Flutter meaning?

What is Flutter? this question comes to many new developer’s mind.

humming_bird_dart_flutter

Flutter means flying wings quickly, and lightly but obviously, this doesn’t apply in our SDK.

So Flutter was one of the companies that were acquired by **Google **for around $40 million. That company was based on providing gesture detection and recognition from a standard webcam. But later when the Flutter was going to release in alpha version for developer it’s name was Sky, but since Google already owned Flutter name, so they rename it to Flutter.

Where Flutter is used?

Flutter is used in many startup companies nowadays, and even some MNCs are also adopting Flutter as a mobile development framework. Many top famous companies are using their apps in Flutter. Some of them here are

Dream11

Dream11

NuBank

NuBank

Reflectly app

Reflectly app

Abbey Road Studios

Abbey Road Studios

and many more other apps. Mobile development companies also adopted Flutter as a service for their clients. Even I was one of them who developed flutter apps as a freelancer and later as an IT company for mobile apps.

Flutter as a service

#dart #flutter #uncategorized #flutter framework #flutter jobs #flutter language #flutter meaning #flutter meaning in hindi #google flutter #how does flutter work #what is flutter

Stripe Payment Gateway Integration Example In Laravel 8

In this post i will share you stripe payment gateway integration example in laravel 8, stripe payment gateway is integrated in many website for payment collection from client, In this time many e-commerce website and other shopping websites are use stripe payment gateway.

So, here we will learn stripe payment gateway integration in laravel 8.

Read More : Stripe Payment Gateway Integration Example In Laravel 8

https://websolutionstuff.com/post/stripe-payment-gateway-integration-example-in-laravel-8


Read Also : How To Integrate Paypal Payment Gateway In Laravel

https://websolutionstuff.com/post/how-to-integrate-paypal-payment-gateway-in-laravel

#stripe payment gateway integration example in laravel 8 #laravel 8 stripe payment gateway integration example #stripe payment gateway integration in laravel 8 #stripe payment gateway #laravel8 #payment gateway

Einar  Hintz

Einar Hintz

1602564925

Razorpay Payment Gateway Integration in ASP.NET MVC

In this article, you will learn Razorpay Payment Gateway Integration in ASP.NET MVC web application or an eCommerce website using C#. With Razorpay, you have access to all payment modes, including credit and debit cards, UPI, and popular mobile wallets.

To check the Razorpay Payment Gateway demo, please click here:

How to integrate Razorpay Payment Gateway in ASP.NET

The Razorpay Payment Gateway enables you to accept payments via debit card, credit card, net banking (supports 3D Secure), UPI, or through any of our supported wallets. Refer to the Payment Methods section for a list of payment methods we support.

Find the below steps to integrate Razorpay in your website:-

#asp.net #how to #mvc #razorpay payment gateway #razorpay payment gateway demo #razorpay payment gateway documentation #razorpay payment gateway integration #razorpay payment gateway integration in asp.net c#