Skip to content

Commit

Permalink
Pay previously canceled payment scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Feb 6, 2024
1 parent 99c3022 commit 8441e74
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
14 changes: 14 additions & 0 deletions features/paying_with_pagolight_during_checkout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,17 @@ Feature: Paying with Pagolight during checkout
And I cancel the payment on Pagolight
Then I should be notified that my payment has been cancelled
And I should be able to pay again

@ui @javascript
Scenario: Retrying the payment with success
Given I added product "PHP T-Shirt" to the cart
And I am at the checkout addressing step
And I specify the billing address as "Via Franceschini 3", "Casalgrande", "42013", "Italy" for "Mario Rossi"
And I complete the addressing step
And I proceeded with "Free" shipping method and "Pagolight" payment
And I have confirmed order
But I have cancelled Pagolight payment
When I try to pay again with Pagolight
And Pagolight notify the store about the successful payment
Then I should be redirected to the thank you page
And I should be notified that my payment has been completed
14 changes: 13 additions & 1 deletion tests/Behat/Context/Ui/PagolightContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Behat\Behat\Context\Context;
use Behat\Mink\Session;
use Sylius\Behat\Page\Shop\Order\ShowPageInterface;
use Sylius\Behat\Page\Shop\Order\ThankYouPageInterface;
use Sylius\Bundle\PayumBundle\Model\PaymentSecurityTokenInterface;
use Sylius\Component\Core\Repository\PaymentRepositoryInterface;
Expand All @@ -30,6 +31,7 @@ public function __construct(
private readonly Session $session,
private readonly PayumCaptureDoPageInterface $payumCaptureDoPage,
private readonly ThankYouPageInterface $thankYouPage,
private readonly ShowPageInterface $orderShowPage,
) {
// TODO: Why config parameters are not loaded?
$this->urlGenerator->setContext(new RequestContext('', 'GET', '127.0.0.1:8080', 'https'));
Expand All @@ -48,7 +50,8 @@ public function iCompleteThePaymentOnPagolight(): void
}

/**
* @Given I cancel the payment on Pagolight
* @Given I have cancelled Pagolight payment
* @When I cancel the payment on Pagolight
*/
public function iCancelThePaymentOnPagolight(): void
{
Expand Down Expand Up @@ -81,6 +84,15 @@ public function iShouldBeRedirectedToTheThankYouPage(): void
Assert::true($this->thankYouPage->hasThankYouMessage());
}

/**
* @When I try to pay again with Pagolight
*/
public function iTryToPayAgainWithPagolight(): void
{
$this->orderShowPage->pay();
$this->iCompleteThePaymentOnPagolight();
}

protected function getPaymentRepository(): PaymentRepositoryInterface
{
return $this->paymentRepository;
Expand Down
2 changes: 1 addition & 1 deletion tests/Behat/Page/Shop/Payum/Capture/PayumCaptureDoPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function getRouteName(): string

public function waitForRedirect(): void
{
$this->getDocument()->waitFor(5, function (DocumentElement $document) {
$this->getDocument()->waitFor(6, function (DocumentElement $document) {
return !str_contains($document->getContent(), 'Stiamo processando il tuo pagamento');
});
}
Expand Down
1 change: 1 addition & 0 deletions tests/Behat/Resources/services/ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
service('behat.mink.default_session'),
service('webgriffe_sylius_pagolight.behat.page.shop.payum.capture.do'),
service('sylius.behat.page.shop.order.thank_you'),
service('sylius.behat.page.shop.order.show'),
])
;
};

0 comments on commit 8441e74

Please sign in to comment.