Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nipuna21018/cordova-plugin-payhere
Cordova plugin to add payhere.lk mobile SDK into your ionic mobile app
https://github.com/nipuna21018/cordova-plugin-payhere
android cordova cordova-plugin ionic4 ionic5 ios native payhere payment-gateway
Last synced: 4 days ago
JSON representation
Cordova plugin to add payhere.lk mobile SDK into your ionic mobile app
- Host: GitHub
- URL: https://github.com/nipuna21018/cordova-plugin-payhere
- Owner: nipuna21018
- Created: 2020-06-04T11:12:22.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T08:39:53.000Z (over 4 years ago)
- Last Synced: 2024-11-06T12:54:58.720Z (9 days ago)
- Topics: android, cordova, cordova-plugin, ionic4, ionic5, ios, native, payhere, payment-gateway
- Language: Java
- Size: 39.1 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ionic Cordova Native Plugin for [PayHere](https://payhere.lk) Payment Gateway
This plugin can be used to add native behaviour of PayHere mobile SDK into your Ionic cordova project. Plugin supports two platforms Android & IOS
# Installation
---
### Plugin
Add the plugin and type definitions to your project
```
cordova plugin add [email protected]
npm install [email protected] --save
```It is also possible to install via repo url directly ( unstable )
```
cordova plugin add https://github.com/nipuna21018/cordova-plugin-payhere.git
```### CocoaPods
Note: This is only if you need plugin to support ios platform
CocoaPods is a dependency manager used in ios projects. We need to add PayHere's native ios SDK dependancy to our project.
You can install CocoaPods with the following command, ignore if CocoaPods already installed on your computer
```bash
$ gem install cocoapods
```Follow these teps to `payhereSDK` into your ios project
- Go to platform/ios folder in your ionic project
- Open `Podfile` inside `ios` folder. If `Podfile` not available. Simply run the command `pod init` on that folder
- Now you need to add two line to the pod file `use_frameworks!` & `pod 'payHereSDK' , '2.0.0'`
-- example `podfile````ruby
platform :ios, '11.0'
use_frameworks!
target '' do
project '.xcodeproj'
pod 'payHereSDK', '2.0.0'
end
```- Now run following command to install all dependancies
```bash
$ pod install
```- That's all. Now all dependencies are installed on your ios project
# Usage
---
Add the plugin to app's provider list
```ts
import { PayHere } from "types-payhere/ngx";@NgModule({
imports: [ ... ],
declarations: [ ... ],
providers: [..., PayHere],
})
export class AppModule {}
```In your page
### Checkout Payment Request:
```ts
import { PayHere, CheckoutRequest, Currency } from "types-payhere/ngx";constructor(private payhere: PayHere) { }
...
const checkoutRequest: CheckoutRequest = {
sandboxEnabled:true, // default is false
merchantId: "11111",
merchantSecret: " Domains & Credentials, to get this>",
notifyURL: "http://sample.com/notify",
amount: 100.00,
currency: Currency.LKR,
orderId: "123",
itemsDescription: "Item Desc",
custom1: "",
custom2: "",
customer: {
firstName: "Nipuna",
lastName: "Harshana",
email: "[email protected]",
phone: "0712345678",
},
billing: {
address: "No 127, Street name",
city: "Colombo",
country: "Sri Lanka",
},
shipping: {
address: "Park Street",
city: "Colombo",
country: "Sri Lanka",
},
items: [
{
id: "1",
name: "My first item name",
quantity: 1,
amount: 10.0,
},
{
id: "2",
name: "My second item name",
quantity: 1,
amount: 20.0,
},
],
}this.payhere.checkout(checkoutRequest).then((response:any) => {
// handle response
console.log(JSON.parse(response));
}, (err) => {
// Handle error
console.log(JSON.parse(err));
});
```### PreAproval Payment Request:
```ts
import { PayHere, PreApproveRequest, Currency } from "types-payhere/ngx";constructor(private payhere: PayHere) { }
...
const preApproveRequest: PreApproveRequest = {
sandboxEnabled:true, // default is false
merchantSecret: " Domains & Credentials, to get this>",
notifyURL: "http://sample.com/notify",
merchantId: "11111",
currency: Currency.LKR,
orderId: "123",
itemsDescription: "Desc",
custom1: "",
custom2: "",
customer: {
firstName: "Nipuna",
lastName: "Harshana",
email: "[email protected]",
phone: "0712345678",
},
billing: {
address: "No 127, Street name",
city: "Colombo",
country: "Sri Lanka",
},
items: [],
}this.payhere.preApprove(preApproveRequest).then((response:any) => {
// handle response
console.log(JSON.parse(response));
}, (err) => {
// Handle error
console.log(JSON.parse(err));
});
```### Recurring Payment Request:
```
not supported yet
```# PayHere API & SDK reference
---
See [Android SDK](https://support.payhere.lk/api-&-mobile-sdk/mobile-sdk-for-android), [iOS SDK](https://support.payhere.lk/api-&-mobile-sdk/mobile-sdk-for-ios)
# Todos
---
- Add support for Recurring Payment Request
- Add browser support# License
---
MIT