Skip to content
Merged
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
8 changes: 1 addition & 7 deletions modules/ppcp-api-client/src/Factory/ReturnUrlFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ public function from_context(
array $request_data = array(),
array $custom_query_args = array()
): string {
return add_query_arg(
array_merge(
array( self::PCP_QUERY_ARG => 'button' ),
$custom_query_args
),
$this->wc_url_from_context( $context, $request_data )
);
return $this->wc_url_from_context( $context, $request_data );
}

protected function wc_url_from_context( string $context, array $request_data = array() ): string {
Expand Down
19 changes: 5 additions & 14 deletions tests/PHPUnit/ApiClient/Factory/ReturnUrlFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testFromContextReturnsCartUrl(string $context)

$result = $this->testee->from_context($context);

$this->assertEquals('https://example.com/cart?pcp-return=button', $result);
$this->assertEquals('https://example.com/cart', $result);
}

public function testFromContextProductReturnsProductUrl()
Expand All @@ -56,7 +56,7 @@ public function testFromContextProductReturnsProductUrl()

$result = $this->testee->from_context('product', $request_data);

$this->assertEquals('https://example.com/product/123?pcp-return=button', $result);
$this->assertEquals('https://example.com/product/123', $result);
}

public function testFromContextProductThrowsExceptionWhenNoUrl()
Expand Down Expand Up @@ -90,7 +90,7 @@ public function testFromContextPayNowReturnsOrderPaymentUrl()

$result = $this->testee->from_context('pay-now', $request_data);

$this->assertEquals('https://example.com/checkout/pay/123?key=abc&pcp-return=button', $result);
$this->assertEquals('https://example.com/checkout/pay/123?key=abc', $result);
}

public function testFromContextPayNowThrowsExceptionWhenOrderNotFound()
Expand All @@ -110,7 +110,7 @@ public function testFromContextCheckoutReturnsCheckoutUrl()

$result = $this->testee->from_context('checkout');

$this->assertEquals('https://example.com/checkout?pcp-return=button', $result);
$this->assertEquals('https://example.com/checkout', $result);
}

public function testFromContextDefaultReturnsCheckoutUrl()
Expand All @@ -119,18 +119,9 @@ public function testFromContextDefaultReturnsCheckoutUrl()

$result = $this->testee->from_context('unknown-context');

$this->assertEquals('https://example.com/checkout?pcp-return=button', $result);
$this->assertEquals('https://example.com/checkout', $result);
}

public function testFromContextReturnsCartUrlWithCustomArgs()
{
when('wc_get_cart_url')->justReturn('https://example.com/cart');

$result = $this->testee->from_context('cart', [], ['session' => '123']);

$this->assertEquals('https://example.com/cart?pcp-return=button&session=123', $result);
}

public function cartContextProvider(): array
{
return [
Expand Down
Loading