Pay Hero M-Pesa Payment Short code For WordPress

The PayHero M-Pesa Payment Shortcode plugin allows you to easily accept payments via the PayHero M-Pesa STK API on any page or post in your WordPress website. With this plugin, you can configure your payment settings, display a payment form using a shortcode, and redirect users to a specified URL upon successful payment.


Features

  • Easy Integration: Add a payment form to any page or post using a simple shortcode.
  • Customizable Settings: Set your channel ID, callback URL, basic auth token, and redirect URL via the WordPress admin panel.
  • Real-Time Payment Status: Automatically checks the payment status and provides feedback to the user.
  • Bootstrap 5 Styling: The payment form is styled using Bootstrap 5 for a modern and responsive design.
  • SweetAlert 2 Notifications: Provides user-friendly feedback using Sweet Alert 2 for success, error, and loading messages.

Installation

  1. Download the plugin zip file below and upload to the wp-content/plugins directory, or install the plugin directly through the WordPress admin panel.
  1. Activate the plugin via the Plugins page in your WordPress admin panel.

Configuration

  1. Go to Settings > PayHero M-Pesa in your WordPress admin panel.
  2. Configure the following settings:
    • Channel ID: Enter your Pay Hero payment channel ID.
    • Callback URL: Set the URL where Pay Hero will send payment notifications.
    • Basic Auth Token: Enter your Pay Hero basic authentication token without starting with the word Basic. You can know how to get it by Reading Docs Here
    • Redirect URL: Set the URL where users will be redirected after a successful payment.
  3. Save your settings.

Usage

To display the payment form on any page or post, use the following shortcode:

[[phpmp_payment_form amount="10"]]

Shortcode Parameters

  • amount: The amount to be paid. Replace 10 with the desired amount.

Example

To request a payment of KES 50, use the following shortcode:

[[phpmp_payment_form amount="50"]]

View Demo Here

How It Works

  1. User Submits Payment Form:
    • The user enters their phone number and payment reference.
    • The plugin initiates the payment via the PayHero M-Pesa STK API.
  2. Payment Status Check:
    • The plugin periodically checks the payment status .
    • If the payment is successful, the user is redirected to the specified URL.
    • If the payment fails, the user is notified and can try again.
  3. Feedback:
    • SweetAlert 2 is used to display loading indicators, success messages, and error messages.

Requirements

  • WordPress 5.0 or higher.
  • PHP 7.0 or higher.
  • A valid Pay Hero account with access to the M-Pesa STK API.

Support

For support or feature requests, please contact us at +254765344101 or [email protected]


Changelog

Version 1.1

  • Initial release of the PayHero M-Pesa Payment Shortcode plugin.

License

This plugin is released under the GPL-2.0 license. Feel free to modify and distribute it as needed.


Enjoy seamless M-Pesa payments on your WordPress website with the PayHero M-Pesa Payment Shortcode plugin!