GithubHelp home page GithubHelp logo

rohan29-an / vanilla_pay_dart Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 16 KB

The Vanilla Pay International Dart package offers developers a simple yet robust solution for integrating Vanilla Pay International's payment service into their Flutter applications.

License: MIT License

Dart 100.00%

vanilla_pay_dart's Introduction

Vanilla Pay International Dart Package

With this module, developers can effortlessly integrate Vanilla Pay International's payment service into their cross-platform Flutter applications.

Introduction

The Vanilla Pay International Dart package provides a convenient way to integrate Vanilla Pay International services into your Flutter applications (Android & iOs). It allows you to generate tokens, initialize payments, check transaction statuses, and validate data authenticity with ease.

Installation

To use this package, add vanilla_pay_international as a dependency in your pubspec.yaml file:

dependencies:
  vanilla_pay_international: ^1.0.0

Then, run flutter pub get to install the package.

Usage

Initialize Payment Manager

To use the Vanilla Pay International services, you need to initialize a VanillaPay instance:

import 'package:vanilla_pay_international/vanilla_pay_international.dart';

void main() {
  VanillaPay paymentManager = VanillaPay(
    env: 'PROD',
    vpiVersion: '1.0.0',
    clientId: 'your_client_id',
    clientSecret: 'your_client_secret',
    keySecret: 'your_key_secret',
  );
}

Generate Token

Use the generateToken() method to generate a token, which remains valid for 20 minutes:

TokenResponse? tokenResponse = await paymentManager.generateToken();

Response (tokenResponse):

{
    "CodeRetour": 200,
    "DescRetour": "Génération TOKEN.",
    "DetailRetour": "",
    "Data": {
    	"Token": "Bearer <token>"
 	}
}

Initialize Payment

Initiate a payment process using the initializePayment() method:

  • token: The generated token.
  • montant: The amount of the transaction.
  • devise: The currency of the transaction (e.g EUR).
  • reference: The pro external reference.
  • panier: The identifier for the transaction.
  • notifUrl: URL called when the payment is finished.
  • redirectUrl: URL to redirect the customer after completing the payment.
InitPaymentResponse? initPaymentResponse = await paymentManager.initializePayment(
  token,
  montant,
  devise,
  reference,
  panier,
  notifUrl,
  redirectUrl,
);

Response (initPaymentResponse):

{
    "CodeRetour": 200,
    "DescRetour": "Génération lien de paiement.",
    "DetailRetour": "",
    "Data": {
        "url": "https://link.com"
    }
}

Check Transaction Status

Retrieve the status of a transaction using the getTransactionsStatus() method:

  • token: The generated token.
  • paymentLink: The payment link.
TransactionStatusResponse? transactionStatusResponse = await paymentManager.checkTransactionStatus(
  token,
  paymentLink,
);

Response (status):

{
    "CodeRetour": 200,
    "DescRetour": "Transaction status.",
    "DetailRetour": "",
    "Data": {
        "reference_VPI": "VPI23011201010101",
	    "panier" : "panier123",
        "reference": "ABC-1234",
        "montant": 58.5,
        "etat": "SUCCESS"
    }
}

Validate Data Authenticity

Validate the authenticity of provided data using the validateDataAuthenticity() method:

  • vpiSignature: The signature extracted from the headers.
  • body: The data to be hashed and compared against the signature.
bool isAuthentic = paymentManager.validateDataAuthenticity(vpiSignature, body);

Contributions and Issues

Contributions and bug reports are welcome! Please feel free to submit a pull request or open an issue on the GitHub repository: Here.


Copyright © 2024 Vanilla Pay. All rights reserved.

vanilla_pay_dart's People

Contributors

rohan29-an avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.