Skip to content

Commit

Permalink
SP-1103 Updating tests, revmoing modal flow type related settings, PH…
Browse files Browse the repository at this point in the history
…PCBF
  • Loading branch information
m-kwiatkowski committed Nov 27, 2024
1 parent 18fc854 commit 740e6eb
Show file tree
Hide file tree
Showing 16 changed files with 556 additions and 583 deletions.
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpayinvoicecreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function execute(): void {

$this->bitpay_checkout_insert_order_note( $order_id, $invoice_id );

wp_redirect( $bitpay_invoice->getUrl() ); // phpcs:ignore
wp_redirect( $bitpay_invoice->getURL() ); // phpcs:ignore
exit();
} catch ( BitPayException $e ) {
$this->bitpay_logger->execute( $e->getMessage(), 'NEW BITPAY INVOICE', false, true );
Expand Down
7 changes: 1 addition & 6 deletions BitPayLib/class-bitpayinvoicefactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ private function get_redirect_url( \WC_Order $order ): string {
return $custom_redirect_page . '?custompage=true';
}

$url_suffix = '?key=' . $order->get_order_key() . '&redirect=false';
$checkout_slug = $this->bitpay_payment_settings->get_checkout_slug();
if ( $checkout_slug ) {
return get_home_url() . DIRECTORY_SEPARATOR . $checkout_slug . '/order-received/'
. $order->get_id() . DIRECTORY_SEPARATOR . $url_suffix;
}
$url_suffix = '?key=' . $order->get_order_key() . '&redirect=false';

return $this->wordpress_helper->get_endpoint_url(
'order-received',
Expand Down
2 changes: 1 addition & 1 deletion BitPayLib/class-bitpaypages.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct( BitPayPaymentSettings $bitpay_payment_settings ) {

public function checkout_thank_you( int $order_id ): void {
global $woocommerce;
$order = new \WC_Order( $order_id );
$order = new \WC_Order( $order_id );
if ( $order->get_payment_method() !== 'bitpay_checkout_gateway' ) {
return;
}
Expand Down
18 changes: 0 additions & 18 deletions BitPayLib/class-bitpaypaymentsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public function redirect_after_purchase( int $order_id ): void {
return;
}

$checkout_message = $this->get_checkout_message();
if ( $order->get_status() === 'pending' ) {
$close_url = $this->get_close_url();

Expand All @@ -71,10 +70,6 @@ public function redirect_after_purchase( int $order_id ): void {
die();
}
}

if ( '' !== $checkout_message ) {
echo '<hr><b>' . $checkout_message . '</b><br><br><hr>'; // phpcs:ignore
}
}

public function check_token(): void {
Expand Down Expand Up @@ -114,10 +109,6 @@ public function get_bitpay_token(): ?string {
return $this->get_bitpay_gateway_setting( 'bitpay_checkout_token_' . $suffix, null );
}

public function get_checkout_message(): string {
return $this->get_bitpay_gateway_setting( 'bitpay_checkout_checkout_message', '' );
}

public function get_close_url(): ?string {
return $this->get_bitpay_gateway_setting( 'bitpay_close_url', null );
}
Expand All @@ -135,15 +126,6 @@ public function get_custom_redirect_page(): ?string {
return $custom_redirect_page;
}

public function get_checkout_slug(): ?string {
$slug = $this->get_bitpay_gateway_setting( 'bitpay_checkout_slug', null );
if ( '' === $slug ) {
return null;
}

return $slug;
}

public function get_payment_logo_url(): string {
$logo = $this->get_bitpay_gateway_setting( 'bitpay_logo', 'BitPay-Accepted-CardGroup' );

Expand Down
14 changes: 2 additions & 12 deletions BitPayLib/class-wcgatewaybitpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,6 @@ public function init_form_fields() {
),
'default' => 'test',
),

'bitpay_checkout_slug' => array(
'title' => __( 'Checkout Page', 'woocommerce' ),
'type' => 'text',
'description' => __( 'If you have a different custom checkout page, enter the <b>page slug</b>. <br>ie. ' . get_home_url() . '/<b>checkout</b><br><br>View your pages <a target = "_blank" href = "/wp-admin/edit.php?post_type=page">here</a>, your current checkout page should have <b>Checkout Page</b> next to the title.<br><br>Click the "quick edit" and copy and paste a custom slug here if needed.', 'woocommerce' ), // phpcs:ignore
),
'bitpay_custom_redirect' => array(
'title' => __( 'Custom Redirect Page', 'woocommerce' ),
'type' => 'text',
Expand Down Expand Up @@ -193,18 +187,14 @@ public function init_form_fields() {
),
'default' => '1',
),
'bitpay_checkout_checkout_message' => array(
'title' => __( 'Checkout Message', 'woocommerce' ),
'type' => 'textarea',
'description' => __( 'Insert your custom message for the <b>Order Received</b> page, so the customer knows that the order will not be completed until BitPay releases the funds.', 'woocommerce' ),
'default' => 'Thank you. We will notify you when BitPay has processed your transaction.',
),

'bitpay_checkout_error' => array(
'title' => __( 'Error handling', 'woocommerce' ),
'type' => 'text',
'description' => __( 'If there is an error with creating the invoice, enter the <b>page slug</b>. <br>ie. ' . get_home_url() . '/<b>error</b><br><br>View your pages <a target = "_blank" href = "/wp-admin/edit.php?post_type=page">here</a>,.<br><br>Click the "quick edit" and copy and paste a custom slug here.', 'woocommerce' ), // phpcs:ignore

),

'bitpay_checkout_error_message' => array(
'title' => __( 'Error Message', 'woocommerce' ),
'type' => 'textarea',
Expand Down
104 changes: 54 additions & 50 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,58 @@

use Isolated\Symfony\Component\Finder\Finder;

$excludedFiles = [];
$excludedFiles = array();

return [
'prefix' => 'BitPayVendor',
'finders' => [
Finder::create()->files()->in('BitPayLib'),
Finder::create()->files()->in('vendor')
->ignoreVCS(true)
->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/')
->exclude([
'humbug'
]),
Finder::create()->append([
'composer.json',
]),
],
'exclude-files' => [
...$excludedFiles,
],
'patchers' => [
static function (string $filePath, string $prefix, string $contents): string {
return $contents;
},
],
'exclude-namespaces' => [
'Humbug\PhpScoper',
'PHP_CodeSniffer',
'PHPCSUtils'
],
'exclude-classes' => [
'WC',
'WC_Payment_Gateway',
'WP_User',
'WC_Order',
'WP_REST_Request',
'WC_Admin_Settings',
'Automattic\WooCommerce\Blocks\Package',
'Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry',
'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType',
'wpdb'
],
'exclude-functions' => [],
'exclude-constants' => [],
'expose-global-constants' => true,
'expose-global-classes' => true,
'expose-global-functions' => true,
'expose-namespaces' => [],
'expose-classes' => [],
'expose-functions' => [],
'expose-constants' => [],
];
return array(
'prefix' => 'BitPayVendor',
'finders' => array(
Finder::create()->files()->in( 'BitPayLib' ),
Finder::create()->files()->in( 'vendor' )
->ignoreVCS( true )
->notName( '/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/' )
->exclude(
array(
'humbug',
)
),
Finder::create()->append(
array(
'composer.json',
)
),
),
'exclude-files' => array(
...$excludedFiles,
),
'patchers' => array(
static function ( string $filePath, string $prefix, string $contents ): string {
return $contents;
},
),
'exclude-namespaces' => array(
'Humbug\PhpScoper',
'PHP_CodeSniffer',
'PHPCSUtils',
),
'exclude-classes' => array(
'WC',
'WC_Payment_Gateway',
'WP_User',
'WC_Order',
'WP_REST_Request',
'WC_Admin_Settings',
'Automattic\WooCommerce\Blocks\Package',
'Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry',
'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType',
'wpdb',
),
'exclude-functions' => array(),
'exclude-constants' => array(),
'expose-global-constants' => true,
'expose-global-classes' => true,
'expose-global-functions' => true,
'expose-namespaces' => array(),
'expose-classes' => array(),
'expose-functions' => array(),
'expose-constants' => array(),
);
1 change: 0 additions & 1 deletion tests/EndToEnd.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ modules:
capabilities:
"goog:chromeOptions":
args:
- "--headless"
- "--disable-gpu"
- "--disable-dev-shm-usage"
- "--proxy-server='direct://'"
Expand Down
24 changes: 12 additions & 12 deletions tests/EndToEnd/BitPayAdminSettingsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

class BitPayAdminSettingsCest {

public function it_should_shows_the_description_on_the_frontend(EndToEndTester $i): void {
$expectedDescription = 'Pay with BitPay using one of the supported cryptocurrencies ' . rand();
public function it_should_show_the_description_on_the_frontend( EndToEndTester $i ): void {
$expectedDescription = 'Pay with BitPay using one of the supported cryptocurrencies ' . rand();

$i->loginAsAdmin();
$i->amOnBitPayAdminSettings();
$i->resetBitPayAdminSettings();
$i->fillField('#woocommerce_bitpay_checkout_gateway_description', $expectedDescription);
$i->saveBitPayAdminSettings();
$i->prepareDataToMakeAnOrder();
$i->amOnOrderPage();
$i->selectBitPayPaymentMethod();
$i->seeInSource($expectedDescription);
}
$i->loginAsAdmin();
$i->amOnBitPayAdminSettings();
$i->resetBitPayAdminSettings();
$i->fillField( '#woocommerce_bitpay_checkout_gateway_description', $expectedDescription );
$i->saveBitPayAdminSettings();
$i->prepareDataToMakeAnOrder();
$i->amOnOrderPage();
$i->selectBitPayPaymentMethod();
$i->seeInSource( $expectedDescription );
}
}
14 changes: 12 additions & 2 deletions tests/EndToEnd/CreateOrderWithBitPayCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

use BitPayLib\Tests\EndToEnd\Support\EndToEndTester;

class CreateOrderWithBitPayCest
{
class CreateOrderWithBitPayCest {

public function it_should_use_redirect_flow_for_create_invoice( EndToEndTester $i ): void {
$i->loginAsAdmin();
$i->amOnBitPayAdminSettings();
$i->resetBitPayAdminSettings();
$i->saveBitPayAdminSettings();
$i->prepareDataToMakeAnOrder();
$i->placeOrder();
$i->wait( 5 );
$i->seeInTitle( 'BitPay Invoice' );
}
}
Loading

0 comments on commit 740e6eb

Please sign in to comment.