Skip to content

Commit 5c11270

Browse files
committed
v3.1 - Support for WC subscriptions, price update, and unpaid order cancellation
1 parent bf02e12 commit 5c11270

8 files changed

Lines changed: 541 additions & 107 deletions

File tree

CryptAPI.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin Name: CryptAPI Payment Gateway for WooCommerce
55
Plugin URI: https://github.com/cryptapi/woocommerce-cryptapi
66
Description: Accept cryptocurrency payments on your WooCommerce website
7-
Version: 3.0.1
7+
Version: 3.1
88
Requires at least: 4.0
99
Tested up to: 5.8
1010
WC requires at least: 2.4
@@ -46,7 +46,6 @@ function cryptapi_loader() {
4646
add_action('plugins_loaded', 'cryptapi_loader');
4747
add_filter('woocommerce_payment_gateways', 'cryptapi_include_gateway');
4848

49-
5049
function cryptapi_include_dirs($dirs) {
5150

5251
foreach ($dirs as $dir) {
@@ -82,4 +81,27 @@ function cryptapi_is_includable($file) {
8281
if (strtolower(substr($file,-3,3)) != 'php') return false;
8382

8483
return true;
84+
}
85+
86+
add_filter( 'cron_schedules', function ( $cryptapi_interval ) {
87+
$cryptapi_interval['cryptapi_interval'] = array(
88+
'interval' => 300,
89+
'display' => esc_html__( 'CryptAPI Interval' ),
90+
);
91+
92+
return $cryptapi_interval;
93+
} );
94+
95+
register_activation_hook( __FILE__, 'cryptapi_activation' );
96+
97+
function cryptapi_activation() {
98+
if (! wp_next_scheduled ( 'cryptapi_cronjob' )) {
99+
wp_schedule_event( time(), 'cryptapi_interval', 'cryptapi_cronjob' );
100+
}
101+
}
102+
103+
register_deactivation_hook( __FILE__, 'cryptapi_deactivation' );
104+
105+
function cryptapi_deactivation() {
106+
wp_clear_scheduled_hook( 'cryptapi_cronjob' );
85107
}

controllers/CryptAPI.php

Lines changed: 404 additions & 98 deletions
Large diffs are not rendered by default.

define.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

33

4-
define('CRYPTAPI_PLUGIN_VERSION', '3.0.1');
4+
define('CRYPTAPI_PLUGIN_VERSION', '3.1');
55
define('CRYPTAPI_PLUGIN_PATH', plugin_dir_path(__FILE__));
66
define('CRYPTAPI_PLUGIN_URL', plugin_dir_url(__FILE__));

emails/renewal-email.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
defined( 'ABSPATH' ) || exit;
3+
4+
/*
5+
* @hooked WC_Emails::email_header() Output the email header
6+
*/
7+
do_action( 'woocommerce_email_header', $email_heading, $email );
8+
printf(
9+
wp_kses(
10+
/* translators: %1$s Site title, %2$s Order pay link */
11+
__( 'Please renew your subscription on %1$s. You can pay the renewal when you’re ready: %2$s', 'cryptapi' ),
12+
array(
13+
'a' => array(
14+
'href' => array(),
15+
),
16+
)
17+
),
18+
esc_html( get_bloginfo( 'name', 'display' ) ),
19+
'<a href="' . esc_url( $order->get_checkout_payment_url() ) . '">' . esc_html__( 'Pay for this order', 'woocommerce' ) . '</a>'
20+
);
21+
/*
22+
* @hooked WC_Emails::email_footer() Output the email footer
23+
*/
24+
do_action( 'woocommerce_email_footer', $email );

readme.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: cryptapi
33
Tags: crypto payments, woocommerce, payment gateway, crypto, payment, pay with crypto, payment request, bitcoin, bnb, usdt, ethereum, monero, litecoin, bitcoin cash, shib, doge
44
Requires at least: 4.4
55
Tested up to: 5.8.3
6-
Stable tag: 3.0.1
6+
Stable tag: 3.1
77
Requires PHP: 5.5
88
WC requires at least: 2.4
99
WC tested up to: 6.1
@@ -58,8 +58,8 @@ Supported currencies for automatic exchange rates are:
5858
* (HKD) Hong Kong Dollar
5959
* (CNY) Chinese Yuan
6060
* (BRL) Brazilian Real
61-
* (DKK) DKK
62-
* (AED) UAE Dollar
61+
* (DKK) Danish Krone
62+
* (AED) UAE Dirham
6363
* (JPY) Japanese Yen
6464
* (CAD) Canadian Dollar
6565
* (GBP) GB Pound
@@ -167,5 +167,15 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
167167
* UI Improvements
168168
* Minor Bug Fixes
169169

170+
= 3.0.2 =
171+
* New setting to show QR Code by default
172+
* UI Improvements
173+
* Minor Bug Fixes
174+
175+
= 3.1 =
176+
* Add support for WooCommerce Subscriptions plugin
177+
* Add new feature to refresh values based on store owner preferences
178+
* Add new feature to cancel orders if they take more than selected time to pay
179+
170180
== Upgrade Notice ==
171181
* No breaking changes

static/cryptapi.css

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
background: #FAFAFA !important;
1818
font-weight: bold;
1919
color: #000 !important;
20+
border: 0;
2021
}
2122

2223
.ca_details_box {
@@ -64,6 +65,7 @@
6465
letter-spacing: .045em;
6566
background-color: #FAFAF9 !important;
6667
color: #000 !important;
68+
border: 0 !important;
6769
}
6870

6971
.ca_qrcode_buttons button.active {
@@ -138,6 +140,7 @@
138140
right: 25px;
139141
background-size: contain;
140142
background: transparent url(./files/ca_copy_icon.svg) no-repeat !important;
143+
border: 0 !important;
141144
}
142145

143146
.ca_copy_icon_tooltip {
@@ -204,14 +207,30 @@
204207
.ca_progress {
205208
display: flex;
206209
margin-top: 52px;
210+
flex-wrap: wrap;
207211
}
208212

209213
.ca_progress .ca_progress_icon {
210214
position: relative;
211215
width: 33.33%;
216+
flex: 0 0 33.33%;
212217
text-align: center;
213218
}
214219

220+
.ca_notification_text {
221+
display: block;
222+
width: 100%;
223+
flex: 0 0 100%;
224+
margin-top: 35px;
225+
text-align: center;
226+
}
227+
228+
.ca_notification_text span {
229+
display: block;
230+
margin-bottom: 3px;
231+
font-size: 14px;
232+
}
233+
215234
.ca_progress .ca_progress_icon.waiting_network {
216235
position: relative;
217236
}
@@ -251,19 +270,23 @@
251270
width: 100%;
252271
}
253272

254-
.ca_payment_confirmed h2 {
273+
.ca_payment_confirmed h2,
274+
.ca_payment_canceled h2 {
255275
text-align: center;
256276
font-size: 28px;
257277
text-transform: uppercase;
258278
font-weight: 700;
259279
margin-top: 26px;
260280
}
261281

262-
.ca_payment_confirmed .ca_payment_confirmed_icon {
282+
.ca_payment_confirmed .ca_payment_confirmed_icon,
283+
.ca_payment_canceled .ca_payment_cancelled_icon {
263284
text-align: center !important;
285+
margin-bottom: 15px;
264286
}
265287

266-
.ca_payment_confirmed .ca_payment_confirmed_icon svg {
288+
.ca_payment_confirmed .ca_payment_confirmed_icon svg,
289+
.ca_payment_canceled .ca_payment_cancelled_icon svg {
267290
max-width: 100% !important;
268291
width: 100px !important;
269292
margin: 0 auto !important;
@@ -313,6 +336,7 @@
313336

314337
.ca_progress .ca_progress_icon {
315338
width: 100%;
339+
flex: 0 0 100%;
316340
}
317341

318342
.ca_progress .ca_progress_icon.waiting_payment:before,

static/payment.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ function check_status(ajax_url) {
99
let waiting_network = jQuery('.waiting_network');
1010
let payment_done = jQuery('.payment_done');
1111

12+
if (data.cryptapi_cancelled === '1') {
13+
jQuery('.ca_loader').hide();
14+
jQuery('.ca_payments_wrapper').slideToggle('400');
15+
jQuery('.ca_payment_cancelled').slideToggle('400');
16+
jQuery('.ca_progress').slideToggle('400');
17+
is_paid = true;
18+
}
19+
1220
if (data.is_pending) {
1321
waiting_payment.addClass('done');
1422
waiting_network.addClass('done');
@@ -27,6 +35,19 @@ function check_status(ajax_url) {
2735

2836
is_paid = true;
2937
}
38+
39+
if (data.crypto_total) {
40+
jQuery('.ca_value').html(data.crypto_total);
41+
jQuery('.ca_copy.ca_details_copy').attr('data-tocopy', data.crypto_total);
42+
}
43+
44+
console.log('QR Code Value: ' + data.cryptapi_qr_code_value);
45+
46+
if (data.cryptapi_qr_code_value) {
47+
jQuery('.ca_qrcode.value').attr("src", "data:image/png;base64," + data.cryptapi_qr_code_value);
48+
49+
50+
}
3051
});
3152

3253
setTimeout(status_loop, 5000);

utils/helper.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,33 @@ public function get_qrcode( $value, $size = 300 ) {
9797
return null;
9898
}
9999

100+
public static function get_static_qrcode( $address, $coin, $value, $size = 300 ) {
101+
if ( empty( $address ) ) {
102+
return null;
103+
}
104+
105+
if ( ! empty( $value ) ) {
106+
$params = [
107+
'address' => $address,
108+
'value' => $value,
109+
'size' => $size,
110+
];
111+
} else {
112+
$params = [
113+
'address' => $address,
114+
'size' => $size,
115+
];
116+
}
117+
118+
$response = Helper::_request( $coin, 'qrcode', $params );
119+
120+
if ( $response->status == 'success' ) {
121+
return [ 'qr_code' => $response->qr_code, 'uri' => $response->payment_uri ];
122+
}
123+
124+
return null;
125+
}
126+
100127
public static function get_supported_coins() {
101128
$info = Helper::get_info( null, true );
102129

0 commit comments

Comments
 (0)