Payhere plugin for flutter
π»Installation
Add this dependencies
in your app's pubspec.yml
payhere_flutter: latest
π° 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';
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));
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"),
),
PhResponse
is identical to PHResponse
in Android SDK
you can find example code in here
π 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.
π Is this useful?
please don't forget to give a little start β from here and give a π for this.
Libraries
Dart
- dart:ui
- Built-in types and core primitives for a Flutter application. [...]
- dart:async
- Support for asynchronous programming, with classes such as Future and Stream. [...]
- dart:collection
- Classes and utilities that supplement the collection support in dart:core. [...]
- dart:convert
- Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
- dart:core
- Built-in types, collections, and other core functionality for every Dart program. [...]
- dart:developer
- Interact with developer tools such as the debugger and inspector. [...]
- dart:math
- Mathematical constants and functions, plus a random number generator. [...]
- dart:typed_data
- Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]
- dart:ffi
- Foreign Function Interface for interoperability with the C programming language. [...]
- dart:io
- File, socket, HTTP, and other I/O support for non-web applications. [...]
- dart:isolate
- Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]
- dart:html
- HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
- dart:js
- Low-level support for interoperating with JavaScript. [...]
- dart:js_util
-
Utility methods to manipulate
package:js
annotated JavaScript interop objects in cases where the name to call is not known at runtime. [...]