Skip to content

Instantly share code, notes, and snippets.

<?php
$hash = strtoupper(
md5(
$merchant_id .
$order_id .
number_format($payhere_amount, 2, '.', '') .
$payhere_currency .
strtoupper(md5($payhere_secret))
)
# Set PayHere as first
DESIRED_GATEWAY_ORDER = [
"PayHere Payment Gateway"
]
# ================================ Script Code (do not edit) ================================
# ================================================================
# ReorderGatewaysCampaign
#
# Reorders gateways into the entered order
@PayHereDevs
PayHereDevs / build.gradle
Created March 8, 2022 06:51
Temporary fix for Android build issues in Gradle 7.0+
// android/build.gradle
// based on:
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
// original location:
@PayHereDevs
PayHereDevs / onsite_preapprove.js
Created September 23, 2021 03:58
Code example on how to use PayHere Onsite Pre-approval
payhere.onCompleted = function (orderId) {
alert('Payment was completed with order id: ' + orderId);
};
payhere.onError = function (err) {
alert('PayHere Error: ' + err);
};
payhere.onDismissed = function () {
alert('PayHere Dismissed!');
@PayHereDevs
PayHereDevs / notify.example.actual.txt
Created September 22, 2021 09:04
A correctly encoded version of the PayHere Payment Notification
merchant_id=1218158&order_id=1631271478419_order&payment_id=320025156250&captured_amount=397.00&payhere_amount=397.00&payhere_currency=LKR&status_code=2&md5sig=7CCBCD300F716F7B77A7A446BE32889B&custom_1=&custom_2=&status_message=Successfully+received+the+VISA+payment&method=TEST&card_holder_name=Nipuna+Munasinghe&card_no=************1292&card_expiry=11%2F22&recurring=0
@PayHereDevs
PayHereDevs / notify.example.easy.json
Created September 22, 2021 09:04
Warning! Actual Payment Notification is encoded as 'application/x-www-form-urlencoded'. JSON notation is for ease of reading.
{
"merchant_id": "1213817",
"order_id": "46",
"payment_id": "320025157750",
"captured_amount": "4500.00",
"payhere_amount": "4500.00",
"payhere_currency": "LKR",
"status_code": "2",
"md5sig": "E325CE9B9315D3890727A3916090B056",
"custom_1": "",
@PayHereDevs
PayHereDevs / payhere_android_notifyurl.java
Created January 2, 2021 04:58
How to set the Notify URL in the PayHere Android SDK InitRequest
InitRequest req = new InitRequest();
req.setMerchantId("1211149"); // Your Merchant ID
req.setMerchantSecret("Merchant Secret");
req.setNotifyUrl("store.com/notify"); // Your Notify URL
req.setCurrency("LKR"); // Currency code LKR/USD/GBP/EUR/AUD
req.setAmount(250.00); // Final Amount to be charged
req.setRecurrence("1 Month"); // Recurrence of the Subscription
@PayHereDevs
PayHereDevs / functions.php
Created September 30, 2020 05:19
Override PayHere Plugin's Payment Order Status
add_filter('woocommerce_payment_complete_order_status', 'modify_gateway_status', 10, 3);
function modify_gateway_status($status, $order_id, $order){
if ($order->get_payment_method() == 'payhere'){
return 'completed';
}
else{
return $status;
}
}