Skip to content

Commit

Permalink
Fix: Bug fixes and performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmdbina committed Dec 6, 2024
1 parent 8ba2b4a commit 8292cb3
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 61 deletions.
107 changes: 106 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,108 @@
# Payhubix Gateway

Integrates Payhubix payment gateway with Easy Digital Downloads.
[Payhubix](https://payhubix.com) is a reliable way to accept payments from around the world in popular cryptocurrencies. This plugin integrates Payhubix with **Easy Digital Downloads (EDD)**, enabling store owners to accept cryptocurrency payments with ease.

# **User Manual for Payhubix Payment Gateway Plugin (Easy Digital Downloads)**

## **Introduction**

### **What is Easy Digital Downloads (EDD)?**

Easy Digital Downloads is a lightweight and user-friendly plugin for WordPress, designed to sell digital products such as eBooks, software, music, or any downloadable content. EDD offers a seamless checkout experience, built-in reporting, and extensive customization options.

### **Why Use EDD?**
- Specifically designed for selling digital products.
- Simple to set up and configure.
- Supports multiple payment gateways.
- Highly customizable with extensions.

### **Features of Payhubix EDD Plugin**
1. Accept payments in major cryptocurrencies.
2. Automatic conversion of order amounts into cryptocurrency.
3. Secure, reliable transactions.
4. User-friendly setup and configuration.
5. Customizable payment description and timeout settings.

---

## **Installation Guide**

### Step 1: Install and Activate Easy Digital Downloads
1. Log in to your WordPress dashboard.
2. Navigate to **Plugins → Add New**.
3. Search for "Easy Digital Downloads" and click **Install Now**.
4. Activate the plugin after installation.

---

### Step 2: Install the Payhubix Plugin
1. Upload the Payhubix EDD plugin:
- Go to **Plugins → Add New → Upload Plugin**.
- Select the plugin's `payhubix-gateway-edd.zip` file and click **Install Now**.
2. After installation, click **Activate Plugin**.

---

### Step 3: Configure Payhubix Settings
1. Navigate to **Downloads → Settings → Payments**.
2. Click the **Payhubix** tab in **settings** link to configure the gateway.
3. Under **Payment Gateways**, find and enable "Payhubix".
![payhubix-gateway-for-woocommerce](https://payhubix.storage.iran.liara.space/payhubix-edd-2.png)
---

## **Configuration Settings**
Here are the fields available for configuration:
![payhubix-gateway-for-woocommerce](https://payhubix.storage.iran.liara.space/payhubix-edd-1.png)
### 1. **API Key**
- Your Payhubix API key for secure transactions.
- Get your API key from your Payhubix account dashboard.

### 2. **Shop ID**
- Your unique Payhubix Shop ID.

### 3. **Payment Timeout**
- The time allowed for customers to complete their cryptocurrency payment.
- Options: `15 minutes` (default), `30 minutes`, `1 hour`, `2 hours`, `3 hours`.

---

## **How to Use Payhubix on Your EDD Store**

### Step 1: Add Digital Products
1. Navigate to **Downloads → Add New**.
2. Enter the product name, description, and pricing details.
3. Click **Publish**.

### Step 2: Test the Checkout Process
1. Add a product to the cart and proceed to checkout.
2. Select **Payhubix** as the payment method.
3. Complete the payment in cryptocurrency using the instructions provided.

---

## **Tips for Store Owners**
1. **Test Payments**
- Use a test API key provided by Payhubix to simulate transactions before going live.

2. **Enable Debug Mode**
- Add logging during initial setup to identify and resolve configuration issues.

3. **Keep API Credentials Secure**
- Never share your API Key or Shop ID publicly.

4. **Update Plugin Regularly**
- Always use the latest version of the Payhubix EDD plugin to ensure compatibility and security.

---

## **Troubleshooting**
If you encounter issues:
1. Check the **Logs** under **Downloads → Tools → Logs** for errors.
2. Verify that your API Key and Shop ID are correct.
3. Ensure your server has access to Payhubix's API.
4. Contact Payhubix support for further assistance.

---

## **Conclusion**
By integrating Payhubix with Easy Digital Downloads, you can offer a seamless cryptocurrency payment experience for your customers, boosting your store's appeal and accessibility. Follow this guide to set up your plugin and start accepting crypto payments today!
48 changes: 23 additions & 25 deletions edd-payhubix.php → payhubix-gateway-edd/edd-payhubix.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/**
* Plugin Name: Payhubix Payment Gateway for Easy Digital Downloads
* Plugin Name: Payhubix Gateway for Easy Digital Downloads
* Plugin URI: https://payhubix.com
* Description: Integrates Payhubix payment gateway with Easy Digital Downloads
* Version: 1.0.0
* Version: 1.1.0
* Author: Payhubix TM, Mohammad Bina
* Author URI: https://payhubix.com
* License: GPL-2.0+
* Text Domain: payhubix-edd-gateway
* Text Domain: payhubix-gateway-edd
*/

if (!defined('ABSPATH')) {
Expand Down Expand Up @@ -38,38 +38,38 @@ private function init_hooks() {
public function register_gateway($gateways) {
$gateways['payhubix'] = array(
'admin_label' => 'Payhubix',
'checkout_label' => __('Pay with Payhubix', 'payhubix-edd-gateway')
'checkout_label' => __('Pay with Payhubix', 'payhubix-gateway-edd')
);
return $gateways;
}

public function add_gateway_section($sections) {
$sections['payhubix'] = __('Payhubix', 'payhubix-edd-gateway');
$sections['payhubix'] = __('Payhubix', 'payhubix-gateway-edd');
return $sections;
}

public function add_gateway_settings($settings) {
$payhubix_settings = array(
array(
'id' => 'payhubix_settings',
'name' => '<strong>' . __('Payhubix Settings', 'payhubix-edd-gateway') . '</strong>',
'name' => '<strong>' . __('Payhubix Settings', 'payhubix-gateway-edd') . '</strong>',
'type' => 'header',
),
array(
'id' => 'payhubix_api_key',
'name' => __('Payhubix API Key', 'payhubix-edd-gateway'),
'name' => __('Payhubix API Key', 'payhubix-gateway-edd'),
'type' => 'textarea',
'desc' => __('Enter your Payhubix API Key', 'payhubix-edd-gateway')
'desc' => __('Enter your Payhubix API Key', 'payhubix-gateway-edd')
),
array(
'id' => 'payhubix_shop_id',
'name' => __('Payhubix Shop ID', 'payhubix-edd-gateway'),
'name' => __('Payhubix Shop ID', 'payhubix-gateway-edd'),
'type' => 'text',
'desc' => __('Enter your Payhubix Shop ID', 'payhubix-edd-gateway')
'desc' => __('Enter your Payhubix Shop ID', 'payhubix-gateway-edd')
),
array(
'id' => 'payhubix_time_for_payment',
'name' => __('Time for Payment', 'payhubix-edd-gateway'),
'name' => __('Time for Payment', 'payhubix-gateway-edd'),
'type' => 'select',
'options' => array(
'00:15' => '15 minutes',
Expand All @@ -78,15 +78,14 @@ public function add_gateway_settings($settings) {
'02:00' => '2 hours',
'03:00' => '3 hours',
),
'desc' => __('Select the time allowed for payment', 'payhubix-edd-gateway')
'desc' => __('Select the time allowed for payment', 'payhubix-gateway-edd')
)
);

if (current_filter() === 'edd_settings_gateways') {
$settings = array_merge($settings, $payhubix_settings);
}
$gateway_settings = $settings;
$gateway_settings['payhubix'] = $payhubix_settings;

return $settings;
return $gateway_settings;
}

public function payment_form() {
Expand All @@ -99,7 +98,7 @@ public function process_payment($purchase_data) {
$this->time_for_payment = edd_get_option('payhubix_time_for_payment', '02:00');

if (empty($this->api_key) || empty($this->shop_id)) {
edd_set_error('payhubix_config_error', __('Payhubix gateway is not configured correctly.', 'payhubix-edd-gateway'));
edd_set_error('payhubix_config_error', __('Payhubix gateway is not configured correctly.', 'payhubix-gateway-edd'));
edd_send_back_to_checkout();
return;
}
Expand Down Expand Up @@ -151,7 +150,7 @@ private function call_payhubix_api($payment_id, $purchase_data) {
];

$args = [
'body' => json_encode($data),
'body' => wp_json_encode($data),
'headers' => [
'Content-Type' => 'application/json',
'X-Api-key' => $this->api_key,
Expand Down Expand Up @@ -183,14 +182,13 @@ private function call_payhubix_api($payment_id, $purchase_data) {

public function listen_for_payhubix_callback() {

if (!isset($_GET['edd-listener']) || $_GET['edd-listener'] !== 'payhubix') {
if (!isset($_GET['order_id']) || !isset($_GET['edd-listener']) || $_GET['edd-listener'] !== 'payhubix') {
return;
}

$payment_id = $_GET['order_id'];
$payment_id = sanitize_text_field(wp_unslash($_GET['order_id']));

if (!$payment_id) {
error_log('Payhubix callback: Payment not found for key ' . $_GET['key']);
wp_redirect(edd_get_checkout_uri());
exit;
}
Expand All @@ -203,7 +201,6 @@ public function listen_for_payhubix_callback() {
$invoice_data = $data['message'];

if ($invoice_id != $invoice_data['link']) {
error_log('Payhubix callback: Invoice ID mismatch for payment ' . $payment_id);
wp_redirect(edd_get_checkout_uri());
exit;
}
Expand All @@ -212,6 +209,8 @@ public function listen_for_payhubix_callback() {
case 'Paid':
edd_update_payment_status($payment_id, 'complete');
edd_insert_payment_note($payment_id, 'Payment successfully processed by Payhubix.');
wp_redirect(edd_get_success_page_uri());
exit;
break;

case 'Canceled':
Expand All @@ -231,10 +230,9 @@ public function listen_for_payhubix_callback() {
break;
}

wp_redirect(edd_get_success_page_uri());
wp_redirect(edd_get_failed_transaction_uri());
exit;
} else {
error_log('Payhubix callback error: ' . json_encode($data));
wp_redirect(edd_get_checkout_uri());
exit;
}
Expand Down Expand Up @@ -270,4 +268,4 @@ function payhubix_edd_init() {
new Payhubix_EDD_Gateway();
}
add_action('plugins_loaded', 'payhubix_edd_init');
?>
?>
43 changes: 43 additions & 0 deletions payhubix-gateway-edd/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
=== Payhubix Gateway for Easy Digital Downloads ===
Contributors: Payhubix TM, Mohammad Bina
Donate link: https://payhubix.com/
Tags: easy-digital-downloads, payhubix, gateway
Requires at least: 6.5 or higher
Tested up to: 6.7.1
Stable tag: 1.1.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Easy Digital Downloads Payhubix Gateway** Integrates Payhubix payment gateway with Easy Digital Downloads.



== Description ==
**Payhubix is a reliable way to accept payments from around the world in popular cryptocurrencies. This plugin integrates Payhubix with Easy Digital Downloads (EDD), enabling store owners to accept cryptocurrency payments with ease.



== Features ==
* Compatible with latest Easy Digital Downloads and older versions
* Simple and user-friendly settings panel
* Ability to set the invoice expiration time
* Display payment gateway errors



== Installation ==
1. Upload the ‘payhubix-gateway-edd’ folder to the path ‘/wp-content/plugins/’.
2. Activate the plugin through the ‘Plugins’ menu in WordPress.
3. You can configure the plugin settings through the Easy Digital Downloads settings / Payment section / Payhubix tab.



== Change log ==

= 1.1.0 =
* Bug fixes and performance improvements

= 1.0.0 =
* Initial release

35 changes: 0 additions & 35 deletions readme.txt

This file was deleted.

0 comments on commit 8292cb3

Please sign in to comment.