Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.5.2 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions opennode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
Plugin Name: WooCommerce Payment Gateway - OpenNode
Plugin URI: https://opennode.com
Description: Accept Bitcoin Instantly via OpenNode
Version: 1.5.1
Version: 1.5.2
Author: OpenNode
Author URI: https://opennode.com/about
*/

add_action('plugins_loaded', 'opennode_init');

define('OPENNODE_WOOCOMMERCE_VERSION', '1.5.1');
define('OPENNODE_WOOCOMMERCE_VERSION', '1.5.2');
define('OPENNODE_CHECKOUT_PATH', 'https://checkout.opennode.com/');

function opennode_init()
Expand All @@ -32,7 +32,7 @@ public function __construct()

$this->id = 'opennode';
$this->has_fields = false;
$this->method_title = 'OpenNode';
$this->method_title = __('OpenNode','opennode-for-woocommerce');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be translatable


$this->init_form_fields();
$this->init_settings();
Expand All @@ -51,8 +51,8 @@ public function __construct()
public function admin_options()
{
?>
<h3><?php _e('OpenNode', 'woothemes'); ?></h3>
<p><?php _e('Accept Bitcoin instantly through OpenNode.com.', 'woothemes'); ?></p>
<h3><?php _e('OpenNode', 'opennode-for-woocommerce'); ?></h3>
<p><?php _e('Accept Bitcoin instantly through OpenNode.com.', 'opennode-for-woocommerce'); ?></p>
<table class="form-table">
<?php $this->generate_settings_html(); ?>
</table>
Expand All @@ -64,33 +64,33 @@ public function init_form_fields()
{
$this->form_fields = array(
'enabled' => array(
'title' => __('Enable OpenNode', 'woocommerce'),
'label' => __('Enable Bitcoin payments via OpenNode', 'woocommerce'),
'title' => __('Enable OpenNode', 'opennode-for-woocommerce'),
'label' => __('Enable Bitcoin payments via OpenNode', 'opennode-for-woocommerce'),
'type' => 'checkbox',
'description' => '',
'default' => 'no',
),
'title' => array(
'title' => __('Title', 'woocommerce'),
'title' => __('Title', 'opennode-for-woocommerce'),
'type' => 'text',
'description' => __('The payment method title which a customer sees at the checkout of your store.', 'woocommerce'),
'default' => __('Pay with Bitcoin: on-chain or with Lightning', 'woocommerce'),
'description' => __('The payment method title which a customer sees at the checkout of your store.', 'opennode-for-woocommerce'),
'default' => __('Pay with Bitcoin: on-chain or with Lightning', 'opennode-for-woocommerce'),
),
'description' => array(
'title' => __('Description', 'woocommerce'),
'title' => __('Description', 'opennode-for-woocommerce'),
'type' => 'textarea',
'description' => __('The payment method description which a customer sees at the checkout of your store.', 'woocommerce'),
'default' => __('Powered by OpenNode'),
'description' => __('The payment method description which a customer sees at the checkout of your store.', 'opennode-for-woocommerce'),
'default' => __('Powered by OpenNode', 'opennode-for-woocommerce'),
),
'api_auth_token' => array(
'title' => __('API Auth Token', 'woocommerce'),
'title' => __('API Auth Token', 'opennode-for-woocommerce'),
'type' => 'text',
'description' => __('Your personal API Key. Generate one <a href="https://app.opennode.com/developers/integrations" target="_blank">here</a>. ', 'woocommerce'),
'description' => __('Your personal API Key. Generate one <a href="https://app.opennode.com/developers/integrations" target="_blank">here</a>.', 'opennode-for-woocommerce'),
'default' => (empty($this->get_option('api_secret')) ? '' : $this->get_option('api_secret')),
),
'checkout_url' => array(
'title' => __('Checkout URL', 'woocommerce'),
'description' => __('URL for the checkout', 'woocommerce'),
'title' => __('Checkout URL', 'opennode-for-woocommerce'),
'description' => __('URL for the checkout', 'opennode-for-woocommerce'),
'type' => 'text',
'default' => OPENNODE_CHECKOUT_PATH,
),
Expand Down Expand Up @@ -154,31 +154,31 @@ public function payment_callback()

try {
if (!$order || !$order->get_id()) {
throw new Exception('Order #' . $request['order_id'] . ' does not exists');
throw new Exception(__('Order #','opennode-for-woocommerce') . $request['order_id'] . __(' does not exist','opennode-for-woocommerce'));
}

$token = get_post_meta($order->get_id(), 'opennode_order_id', true);

if (empty($token) ) {
throw new Exception('Order has OpenNode ID associated');
throw new Exception(__('Order has OpenNode ID associated','opennode-for-woocommerce'));
}


if (strcmp(hash_hmac('sha256', $token, $this->api_auth_token), $request['hashed_order']) != 0) {
throw new Exception('Request is not signed with the same API Key, ignoring.');
throw new Exception(__('Request is not signed with the same API Key, ignoring.','opennode-for-woocommerce'));
}

$this->init_opennode();
$cgOrder = \OpenNode\Merchant\Order::find($request['id']);

if (!$cgOrder) {
throw new Exception('OpenNode Order #' . $order->get_id() . ' does not exists');
throw new Exception(__('OpenNode Order #','opennode-for-woocommerce') . $order->get_id() . __(' does not exist','opennode-for-woocommerce'));
}

switch ($cgOrder->status) {
case 'paid':
$statusWas = "wc-" . $order->get_status();
$order->add_order_note(__('Payment is settled and has been credited to your OpenNode account. Purchased goods/services can be securely delivered to the customer.', 'opennode'));
$order->add_order_note(__('Payment is settled and has been credited to your OpenNode account. Purchased goods/services can be securely delivered to the customer.', 'opennode-for-woocommerce'));
$order->payment_complete();

if ($order->get_status() === 'processing' && ($statusWas === 'wc-expired' || $statusWas === 'wc-canceled')) {
Expand All @@ -189,19 +189,19 @@ public function payment_callback()
}
break;
case 'processing':
$order->add_order_note(__('Customer has paid via standard on-Chain. Payment is awaiting 1 confirmation by the Bitcoin network, DO NOT SEND purchased goods/services UNTIL payment has been marked as PAID', 'opennode'));
$order->add_order_note(__('Customer has paid via standard on-Chain. Payment is awaiting 1 confirmation by the Bitcoin network, DO NOT SEND purchased goods/services UNTIL payment has been marked as PAID', 'opennode-for-woocommerce'));
break;
case 'underpaid':
$missing_amt = number_format($cgOrder->missing_amt/100000000, 8, '.', '');
$order->add_order_note(__('Customer has paid via standard on-Chain, but has underpaid by ' . $missing_amt . ' BTC. Waiting on user to send the remainder before marking as PAID.', 'opennode'));
$order->add_order_note(__('Customer has paid via standard on-Chain, but has underpaid by ','opennode-for-woocommerce') . $missing_amt . __(' BTC. Waiting on user to send the remainder before marking as PAID.', 'opennode-for-woocommerce'));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should either be 2 strings like this, or a sprintf()

break;
case 'expired':
$order->add_order_note(__('Payment expired', 'opennode'));
$order->add_order_note(__('Payment expired', 'opennode-for-woocommerce'));
$order->update_status('cancelled');
break;
case 'refunded':
$refund_id = $cgOrder->refund['id'];
$order->add_order_note(__('Customer has canceled the payment. Refund ID - ' . $refund_id . ' .', 'opennode'));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with text-domain being anything other than opennode-for-woocommerce, translate.wp.org does not pick up string as translatable

$order->add_order_note(__('Customer has canceled the payment. Refund ID - ' . $refund_id . ' .', 'opennode-for-woocommerce'));
$order->update_status('cancelled');
break;
}
Expand Down
16 changes: 14 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Contributors: OpenNode
Donate link: https://opennode.com
Tags: opennode, bitcoin, lightning, lightning network, accept bitcoin, accept lightning, instant bitcoin, bitcoin processor, bitcoin gateway, payment gateway, payment module, bitcoin module, bitcoin woocommerce, btc
Requires at least: 4.0
Tested up to: 5.9.3
Tested up to: 6.1.1
Stable tag: trunk
Requires PHP: 7.3

Start accepting Bitcoin instantly through Lightning Network today. Powered by OpenNode

Expand All @@ -26,9 +28,19 @@ This plugin allows stores that use Wordpress WooCommerce shopping cart system to
== Installation ==

1. Install the WooCommerce OpenNode plugin:
* Install through [Wordpress Plugin Manager](https://codex.wordpress.org/Plugins_Add_New_Screen): Admin » Plugins » Add New » Enter "opennode woocommerce" in search » Click "Install Now"
* Install through [WordPress Plugin Manager](https://codex.wordpress.org/Plugins_Add_New_Screen): Admin » Plugins » Add New » Enter "opennode woocommerce" in search » Click "Install Now"
* [Upload ZIP](https://codex.wordpress.org/Plugins_Add_New_Screen#Upload_Tab): Admin » Plugins » Add New » Upload Plugin
* Extract ZIP and upload extracted directory to the `/wp-content/plugins/` through FTP
3. Activate the plugin through the 'Plugins' menu in WordPress
4. Enter [API Credentials]() to WooCommerce-OpenNode Plugin Settings: Admin » WooCommerce » Click on Checkout tab » Find "OpenNode" in Payment Gateways table » Click "Settings"
6. Check "Enable Cryptocurrency payments via OpenNode" checkbox.

== Screenshots ==

== Upgrade Notice ==

== Changelog ==

= 1.5.2 =
* Internationalization
* Readme compliance