payhere_flutter 0.1.1 copy "payhere_flutter: ^0.1.1" to clipboard
payhere_flutter: ^0.1.1 copied to clipboard

A wrapper around native Payhere SDK , This plugin mimics the original Payhere SDK hence making a payment is identical to original sdk

Payhere plugin for flutter #

A Flutter plugin for making payments via Payhere Payment Gateway

πŸ’»Installation #

Add this dependencies in your app's pubspec.yaml

payhere_flutter: ^0.1.1
copied to clipboard

πŸ’° Making Payments #

This plugin mimics the original payhere android sdk hence making a payment is identical to original sdk

Import package

import 'package:payhere_flutter/payhere_flutter.dart';
copied to clipboard

One-time Payment Request

InitRequest req = new InitRequest();
//Required Params
req.setMerchantId("1210XXX");       // Your Merchant PayHere ID
req.setMerchantSecret("ugknesnvn"); // Your Merchant secret (Add your app at Settings > Domains & Credentials, to get this))
req.setCurrency("LKR");             // Currency code LKR/USD/GBP/EUR/AUD
req.setAmount(1000.00);             // Final Amount to be charged
req.setOrderId("230000123");        // Unique Reference ID
req.setItemsDescription("Door bell wireless");  // Item description title 
req.setCustom1("This is the custom message 1");
req.setCustom2("This is the custom message 2");
req.getCustomer().setFirstName("Saman");
req.getCustomer().setLastName("Perera");
req.getCustomer().setEmail("samanp@gmail.com");
req.getCustomer().setPhone("+94771234567");
req.getCustomer().getAddress().setAddress("No.1, Galle Road");
req.getCustomer().getAddress().setCity("Colombo");
req.getCustomer().getAddress().setCountry("Sri Lanka");

//Optional Params
req.getCustomer().getDeliveryAddress().setAddress("No.2, Kandy Road");
req.getCustomer().getDeliveryAddress().setCity("Kadawatha");
req.getCustomer().getDeliveryAddress().setCountry("Sri Lanka");
req.getItems().add(new Item(null, "Door bell wireless", 1, 1000.0));
copied to clipboard

call SANDBOX or LIVE end points with InitRequest

RaisedButton(  
  onPressed: () async {  
  // SANDBOX 
    PhResponse response =  
        await PayhereFlutter.oneTimePaymentSandbox(request: req);  
  child: Text("One Time Payment SANDBOX"),  
),
copied to clipboard

PhResponse is identical to PHResponse in Android SDK

PhResponse

type name description
Data data includes information about transaction
String message brief about transaction
int status Transaction status

Status #

status code
STATUS_SUCCESS 1
ERROR_UNKNOWN -1
ERROR_DATA -2
ERROR_VALIDATION -3
ERROR_NETWORK -4
ERROR_PAYMENT -5

Data #

type name description
int status payment status
double paymentNo unique payment identifier
String currency The unit of currency in which the transaction was made
price price Amount of transaction.
String sign transaction sign key
String message description about transaction

Status #

status code
INIT 0
PAYMENT 1
SUCCESS 2
FAILED -2

you can find example code in here

πŸš€ Release #

flutter uses R8 code shrinker by default if you want to use R8 you need to add proguard-rules.pro to your flutter app. more

  1. release with R8 ( default) i. create proguard-rules.pro under android>app and add this

    -keep class lk.payhere.** { *; }
    
    copied to clipboard

    ii. under app>build.gradle add this

buildTypes {  
  release {  
  // TODO: Add your own signing config for the release build.  
  // Signing with the debug keys for now, so `flutter run --release` works.  
  
  minifyEnabled true  
  useProguard true  
  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'  
  signingConfig signingConfigs.debug  
    }  
}
copied to clipboard
  1. without code shrinking run flutter build --no-shrink

πŸ“„ Implementation #

API Android iOS
One-time Payment βœ”οΈ ❌
Recurring Payment ❌ ❌
Pre-approval ❌ ❌

✏️ Contributing, 😞 Issues and πŸ› Bug Reports #

The project is open to public contribution. Please feel very free to contribute. Experienced an issue or want to report a bug? Please, report it here. Remember to be as descriptive as possible.

🚨 Issues /Bugs #

  • 0.0.3 Android Manifest merger failed error add Page maker rule for AndroidManifest.xml
    <application
    android:name="io.flutter.app.FlutterApplication"  
    android:label="appname"  
    android:icon="@mipmap/ic_launcher"  
    tools:replace="android:label"> // add this
    
    copied to clipboard

πŸ˜‡ Is this useful? #

please don't forget to give a little start ⭐ from here and give a πŸ‘ for this.

13
likes
40
points
31
downloads

Publisher

unverified uploader

Weekly Downloads

2024.10.03 - 2025.04.17

A wrapper around native Payhere SDK , This plugin mimics the original Payhere SDK hence making a payment is identical to original sdk

Repository (GitHub)

License

Apache-2.0 (license)

Dependencies

flutter, json_annotation

More

Packages that depend on payhere_flutter