-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from mwarzybok-sumoheavy/feature/SP-674
SP-674 Add admin option to allow users to select their BitPay button
- Loading branch information
Showing
49 changed files
with
1,483 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
@@ -89,6 +89,7 @@ public function execute(): void { | |
wp_redirect( $bitpay_invoice->getRedirectURL() ); // phpcs:ignore | ||
exit(); | ||
} catch ( BitPayException $e ) { | ||
$this->bitpay_logger->execute( $e->getMessage(), 'NEW BITPAY INVOICE', false, true ); | ||
$error_url = get_home_url() . '/' . $bitpay_checkout_options['bitpay_checkout_error']; | ||
$order = new \WC_Order( $order_id ); | ||
$items = $order->get_items(); | ||
|
@@ -106,6 +107,7 @@ public function execute(): void { | |
wp_redirect( $error_url ); // phpcs:ignore | ||
die(); | ||
} catch ( \Exception $e ) { | ||
$this->bitpay_logger->execute( $e->getMessage(), 'NEW BITPAY INVOICE', false, true ); | ||
global $woocommerce; | ||
$cart_url = $woocommerce->cart->get_cart_url(); | ||
wp_redirect( $cart_url ); // phpcs:ignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
/** | ||
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
@@ -137,14 +137,6 @@ public function get_checkout_message(): string { | |
return $this->get_bitpay_gateway_setting( 'bitpay_checkout_checkout_message', '' ); | ||
} | ||
|
||
private function get_bitpay_gateway_setting( string $setting_name, $default_value = null ): ?string { | ||
return $this->get_bitpay_gateway_settings()[ $setting_name ] ?? $default_value; | ||
} | ||
|
||
private function get_bitpay_gateway_settings(): array { | ||
return get_option( 'woocommerce_bitpay_checkout_gateway_settings', array() ); | ||
} | ||
|
||
public function get_close_url(): ?string { | ||
return $this->get_bitpay_gateway_setting( 'bitpay_close_url', null ); | ||
} | ||
|
@@ -170,4 +162,18 @@ public function get_checkout_slug(): ?string { | |
|
||
return $slug; | ||
} | ||
|
||
public function get_payment_logo_url(): string { | ||
$logo = $this->get_bitpay_gateway_setting( 'bitpay_logo', 'BitPay-Accepted-CardGroup' ); | ||
|
||
return plugins_url( '../../images/', __FILE__ ) . $logo . '.svg'; | ||
} | ||
|
||
private function get_bitpay_gateway_setting( string $setting_name, $default_value = null ): ?string { | ||
return $this->get_bitpay_gateway_settings()[ $setting_name ] ?? $default_value; | ||
} | ||
|
||
private function get_bitpay_gateway_settings(): array { | ||
return get_option( 'woocommerce_bitpay_checkout_gateway_settings', array() ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
@@ -28,7 +28,6 @@ public function __construct() { | |
|
||
if ( empty( $_GET['woo-bitpay-return'] ) ) { // phpcs:ignore | ||
$this->order_button_text = __( 'Pay with BitPay', 'woocommerce-gateway-bitpay_checkout_gateway' ); | ||
|
||
} | ||
|
||
$this->init_form_fields(); | ||
|
@@ -40,13 +39,15 @@ public function __construct() { | |
|
||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); | ||
add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 ); | ||
wp_enqueue_script( 'bitpay_wc_gateway', plugins_url( '../../js/wc_gateway_bitpay.js', __FILE__ ), null, 1, false ); | ||
} | ||
public function email_instructions( $order, $sent_to_admin, $plain_text = false ) { | ||
if ( $this->instructions && ! $sent_to_admin && 'bitpay_checkout_gateway' === $order->get_payment_method() && $order->has_status( 'processing' ) ) { | ||
echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); | ||
} | ||
} | ||
public function init_form_fields() { | ||
$settings = new BitPayPaymentSettings(); | ||
$wc_statuses_arr = wc_get_order_statuses(); | ||
unset( $wc_statuses_arr['wc-cancelled'] ); | ||
unset( $wc_statuses_arr['wc-refunded'] ); | ||
|
@@ -62,6 +63,39 @@ public function init_form_fields() { | |
'description' => '', | ||
'default' => 'no', | ||
), | ||
'bitpay_logo' => array( | ||
'title' => __( 'BitPay Logo', 'woocommerce' ), | ||
'type' => 'select', | ||
'description' => '', | ||
'options' => array( | ||
'BitPay-Accepted-CardGroup' => 'BitPay Accepted', | ||
'BitPay-Accepted-CardGroup-DarkMode' => 'BitPay Accepted (Dark mode)', | ||
'Pay-with-BitPay-CardGroup' => 'Pay with BitPay', | ||
'Pay-with-BitPay-CardGroup-DarkMode' => 'Pay with BitPay (Dark mode)', | ||
'BitPay-Accepted-Card-Alt' => 'BitPay Accepted Card - Alt', | ||
'BitPay-Accepted-Card-Alt-DarkMode' => 'BitPay Accepted Card - Alt (Dark mode)', | ||
'BitPay-Accepted-Card' => 'BitPay Accepted Card', | ||
'BitPay-Accepted-Card-DarkMode' => 'BitPay Accepted Card (Dark mode)', | ||
'BitPay-Accepted-Card-GrayScale' => 'BitPay Accepted Card - Grayscale', | ||
'PayWith-BitPay-Card2x' => 'Pay with BitPay Card', | ||
'PayWith-BitPay-Card-Alt' => 'Pay with BitPay Card - Alt', | ||
'PayWith-BitPay-Card-GrayScale' => 'Pay with BitPay Card - Grayscale', | ||
'PayWith-BitPay-Card-DarkMode' => 'Pay with BitPay Card (Dark mode)', | ||
), | ||
'default' => 'BitPay-Accepted-CardGroup', | ||
), | ||
'bitpay_logo_image_white' => array( | ||
'id' => 'bitpay_logo', | ||
'description' => '<img src="' . $settings->get_payment_logo_url() | ||
. '" style="background-color: white;"/>', | ||
'type' => 'title', | ||
), | ||
'bitpay_logo_image_dark' => array( | ||
'id' => 'bitpay_logo', | ||
'description' => '<img src="' . $settings->get_payment_logo_url() | ||
. '" style="background-color: black;"/>', | ||
'type' => 'title', | ||
), | ||
'bitpay_checkout_info' => array( | ||
'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' ), | ||
'type' => 'title', | ||
|
@@ -244,8 +278,9 @@ public function process_payment( $order_id ) { | |
} | ||
|
||
private function get_icon_on_payment_page(): string { | ||
$brand = '//bitpay.com/cdn/merchant-resources/pay-with-bitpay-card-group.svg'; | ||
return $brand . '" class="bitpay_logo"'; | ||
$settings = new BitPayPaymentSettings(); | ||
|
||
return $settings->get_payment_logo_url() . '" id="bitpay_logo'; | ||
} | ||
|
||
private function get_processing_link(): string { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
* Plugin Name: BitPay Checkout for WooCommerce | ||
* Plugin URI: https://www.bitpay.com | ||
* Description: BitPay Checkout Plugin | ||
* Version: 5.1.0 | ||
* Version: 5.2.0 | ||
* Author: BitPay | ||
* Author URI: mailto:[email protected]?subject=BitPay Checkout for WooCommerce | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.