Skip to content

Commit 4bae55a

Browse files
SP-674 Add admin option to allow users to select their BitPay button
1 parent 01b31f7 commit 4bae55a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1428
-59
lines changed

BitPayLib/class-bitpaycancelorder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.0.0
11+
* Version: 5.2.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/

BitPayLib/class-bitpaycart.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.0.0
11+
* Version: 5.2.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/

BitPayLib/class-bitpaycheckouttransactions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: BitPay Checkout for WooCommerce
1212
* Plugin URI: https://www.bitpay.com
1313
* Description: BitPay Checkout Plugin
14-
* Version: 5.0.0
14+
* Version: 5.2.0
1515
* Author: BitPay
1616
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1717
*/

BitPayLib/class-bitpayclientfactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Plugin Name: BitPay Checkout for WooCommerce
1414
* Plugin URI: https://www.bitpay.com
1515
* Description: BitPay Checkout Plugin
16-
* Version: 5.0.0
16+
* Version: 5.2.0
1717
* Author: BitPay
1818
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1919
*/

BitPayLib/class-bitpayinvoicecreate.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Plugin Name: BitPay Checkout for WooCommerce
1414
* Plugin URI: https://www.bitpay.com
1515
* Description: BitPay Checkout Plugin
16-
* Version: 5.0.0
16+
* Version: 5.2.0
1717
* Author: BitPay
1818
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1919
*/
@@ -89,6 +89,7 @@ public function execute(): void {
8989
wp_redirect( $bitpay_invoice->getRedirectURL() ); // phpcs:ignore
9090
exit();
9191
} catch ( BitPayException $e ) {
92+
$this->bitpay_logger->execute( $e->getMessage(), 'NEW BITPAY INVOICE', false, true );
9293
$error_url = get_home_url() . '/' . $bitpay_checkout_options['bitpay_checkout_error'];
9394
$order = new \WC_Order( $order_id );
9495
$items = $order->get_items();
@@ -106,6 +107,7 @@ public function execute(): void {
106107
wp_redirect( $error_url ); // phpcs:ignore
107108
die();
108109
} catch ( \Exception $e ) {
110+
$this->bitpay_logger->execute( $e->getMessage(), 'NEW BITPAY INVOICE', false, true );
109111
global $woocommerce;
110112
$cart_url = $woocommerce->cart->get_cart_url();
111113
wp_redirect( $cart_url ); // phpcs:ignore

BitPayLib/class-bitpayipnprocess.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Plugin Name: BitPay Checkout for WooCommerce
1414
* Plugin URI: https://www.bitpay.com
1515
* Description: BitPay Checkout Plugin
16-
* Version: 5.0.0
16+
* Version: 5.2.0
1717
* Author: BitPay
1818
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1919
*/

BitPayLib/class-bitpaylogger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.0.0
11+
* Version: 5.2.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/

BitPayLib/class-bitpaypages.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
10-
* Version: 5.0.0
10+
* Version: 5.2.0
1111
* Author: BitPay
1212
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1313
*/

BitPayLib/class-bitpaypaymentsettings.php

+15-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.0.0
11+
* Version: 5.2.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/
@@ -137,14 +137,6 @@ public function get_checkout_message(): string {
137137
return $this->get_bitpay_gateway_setting( 'bitpay_checkout_checkout_message', '' );
138138
}
139139

140-
private function get_bitpay_gateway_setting( string $setting_name, $default_value = null ): ?string {
141-
return $this->get_bitpay_gateway_settings()[ $setting_name ] ?? $default_value;
142-
}
143-
144-
private function get_bitpay_gateway_settings(): array {
145-
return get_option( 'woocommerce_bitpay_checkout_gateway_settings', array() );
146-
}
147-
148140
public function get_close_url(): ?string {
149141
return $this->get_bitpay_gateway_setting( 'bitpay_close_url', null );
150142
}
@@ -170,4 +162,18 @@ public function get_checkout_slug(): ?string {
170162

171163
return $slug;
172164
}
165+
166+
public function get_payment_logo_url(): string {
167+
$logo = $this->get_bitpay_gateway_setting( 'bitpay_logo', 'BitPay-Accepted-CardGroup' );
168+
169+
return plugins_url( '../../images/', __FILE__ ) . $logo . '.svg';
170+
}
171+
172+
private function get_bitpay_gateway_setting( string $setting_name, $default_value = null ): ?string {
173+
return $this->get_bitpay_gateway_settings()[ $setting_name ] ?? $default_value;
174+
}
175+
176+
private function get_bitpay_gateway_settings(): array {
177+
return get_option( 'woocommerce_bitpay_checkout_gateway_settings', array() );
178+
}
173179
}

BitPayLib/class-bitpaypluginsetup.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: BitPay Checkout for WooCommerce
1111
* Plugin URI: https://www.bitpay.com
1212
* Description: BitPay Checkout Plugin
13-
* Version: 5.0.0
13+
* Version: 5.2.0
1414
* Author: BitPay
1515
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1616
*/

BitPayLib/class-wcgatewaybitpay.php

+39-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Plugin Name: BitPay Checkout for WooCommerce
99
* Plugin URI: https://www.bitpay.com
1010
* Description: BitPay Checkout Plugin
11-
* Version: 5.0.0
11+
* Version: 5.2.0
1212
* Author: BitPay
1313
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1414
*/
@@ -28,7 +28,6 @@ public function __construct() {
2828

2929
if ( empty( $_GET['woo-bitpay-return'] ) ) { // phpcs:ignore
3030
$this->order_button_text = __( 'Pay with BitPay', 'woocommerce-gateway-bitpay_checkout_gateway' );
31-
3231
}
3332

3433
$this->init_form_fields();
@@ -40,13 +39,15 @@ public function __construct() {
4039

4140
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
4241
add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 );
42+
wp_enqueue_script( 'bitpay_wc_gateway', plugins_url( '../../js/wc_gateway_bitpay.js', __FILE__ ), null, 1, false );
4343
}
4444
public function email_instructions( $order, $sent_to_admin, $plain_text = false ) {
4545
if ( $this->instructions && ! $sent_to_admin && 'bitpay_checkout_gateway' === $order->get_payment_method() && $order->has_status( 'processing' ) ) {
4646
echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
4747
}
4848
}
4949
public function init_form_fields() {
50+
$settings = new BitPayPaymentSettings();
5051
$wc_statuses_arr = wc_get_order_statuses();
5152
unset( $wc_statuses_arr['wc-cancelled'] );
5253
unset( $wc_statuses_arr['wc-refunded'] );
@@ -62,6 +63,39 @@ public function init_form_fields() {
6263
'description' => '',
6364
'default' => 'no',
6465
),
66+
'bitpay_logo' => array(
67+
'title' => __( 'BitPay Logo', 'woocommerce' ),
68+
'type' => 'select',
69+
'description' => '',
70+
'options' => array(
71+
'BitPay-Accepted-CardGroup' => 'BitPay Accepted',
72+
'BitPay-Accepted-CardGroup-DarkMode' => 'BitPay Accepted (Dark mode)',
73+
'Pay-with-BitPay-CardGroup' => 'Pay with BitPay',
74+
'Pay-with-BitPay-CardGroup-DarkMode' => 'Pay with BitPay (Dark mode)',
75+
'BitPay-Accepted-Card-Alt' => 'BitPay Accepted Card - Alt',
76+
'BitPay-Accepted-Card-Alt-DarkMode' => 'BitPay Accepted Card - Alt (Dark mode)',
77+
'BitPay-Accepted-Card' => 'BitPay Accepted Card',
78+
'BitPay-Accepted-Card-DarkMode' => 'BitPay Accepted Card (Dark mode)',
79+
'BitPay-Accepted-Card-GrayScale' => 'BitPay Accepted Card - Grayscale',
80+
'PayWith-BitPay-Card2x' => 'Pay with BitPay Card',
81+
'PayWith-BitPay-Card-Alt' => 'Pay with BitPay Card - Alt',
82+
'PayWith-BitPay-Card-GrayScale' => 'Pay with BitPay Card - Grayscale',
83+
'PayWith-BitPay-Card-DarkMode' => 'Pay with BitPay Card (Dark mode)',
84+
),
85+
'default' => 'BitPay-Accepted-CardGroup',
86+
),
87+
'bitpay_logo_image_white' => array(
88+
'id' => 'bitpay_logo',
89+
'description' => '<img src="' . $settings->get_payment_logo_url()
90+
. '" style="background-color: white;"/>',
91+
'type' => 'title',
92+
),
93+
'bitpay_logo_image_dark' => array(
94+
'id' => 'bitpay_logo',
95+
'description' => '<img src="' . $settings->get_payment_logo_url()
96+
. '" style="background-color: black;"/>',
97+
'type' => 'title',
98+
),
6599
'bitpay_checkout_info' => array(
66100
'description' => __( 'You should not ship any products until BitPay has finalized your transaction.<br>The order will stay in a <b>Hold</b> and/or <b>Processing</b> state, and will automatically change to <b>Completed</b> after the payment has been confirmed.', 'woocommerce' ),
67101
'type' => 'title',
@@ -244,8 +278,9 @@ public function process_payment( $order_id ) {
244278
}
245279

246280
private function get_icon_on_payment_page(): string {
247-
$brand = '//bitpay.com/cdn/merchant-resources/pay-with-bitpay-card-group.svg';
248-
return $brand . '" class="bitpay_logo"';
281+
$settings = new BitPayPaymentSettings();
282+
283+
return $settings->get_payment_logo_url() . '" id="bitpay_logo';
249284
}
250285

251286
private function get_processing_link(): string {

BitPayLib/trait-wpdbhelper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Plugin Name: BitPay Checkout for WooCommerce
1111
* Plugin URI: https://www.bitpay.com
1212
* Description: BitPay Checkout Plugin
13-
* Version: 5.0.0
13+
* Version: 5.2.0
1414
* Author: BitPay
1515
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce
1616
*/

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
# 5.2.0
6+
* Add admin option to allow users to select their BitPay button
7+
* log create invoice issues
8+
9+
# 5.1.0
10+
* Generate vendors to avoid potential conflicts between plugins (inconsistent version of same vendor)
11+
512
# 5.0.1
613
* Fix support for PHP 8.0
14+
715
# 5.0.0
816
* Improve code quality
917
* Use BitPay SDK

0 commit comments

Comments
 (0)