-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix original payment method on refund page
- Loading branch information
Showing
8 changed files
with
117 additions
and
3 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
features/seeing_original_payment_method_from_completed_payment_on_refund_page.feature
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@refunds | ||
Feature: Seeing an original payment method from completed payment on the refund page | ||
In order to choose proper payment method while refunding | ||
As an Administrator | ||
I want to see the original payment method of completed payment | ||
|
||
Background: | ||
Given the store operates on a single green channel in "United States" | ||
And the store has a product "Mr. Meeseeks T-Shirt" priced at "$10.00" | ||
And the store allows shipping with "Galaxy Post" | ||
And the store allows paying with "Space money" | ||
And the store also allows paying with "Mars money" | ||
And there is a customer "[email protected]" that placed an order "#00000023" | ||
And the customer bought 2 "Mr. Meeseeks T-Shirt" products | ||
And the customer chose "Galaxy Post" shipping method to "United States" with "Space money" payment | ||
And the payment of order "#00000023" failed | ||
And the customer chose "Mars money" payment method | ||
And this payment has been paid | ||
And I am logged in as an administrator | ||
|
||
@ui | ||
Scenario: Seeing original payment method of completed payment | ||
When I want to refund some units of order "#00000023" | ||
Then I should see original payment method "Mars money" |
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
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Sylius\RefundPlugin\Behat\Context\Setup; | ||
|
||
use Behat\Behat\Context\Context; | ||
use SM\Factory\FactoryInterface as StateMachineFactoryInterface; | ||
use Sylius\Behat\Service\SharedStorageInterface; | ||
use Sylius\Component\Core\Model\OrderInterface; | ||
use Sylius\Component\Core\Model\PaymentInterface; | ||
use Sylius\Component\Core\Model\PaymentMethodInterface; | ||
use Sylius\Component\Payment\PaymentTransitions; | ||
|
||
final class PaymentContext implements Context | ||
{ | ||
/** @var StateMachineFactoryInterface */ | ||
private $stateMachineFactory; | ||
|
||
/** @var SharedStorageInterface */ | ||
private $sharedStorage; | ||
|
||
public function __construct(StateMachineFactoryInterface $stateMachineFactory, SharedStorageInterface $sharedStorage) | ||
{ | ||
$this->stateMachineFactory = $stateMachineFactory; | ||
$this->sharedStorage = $sharedStorage; | ||
} | ||
|
||
/** | ||
* @Given the payment of order :order failed | ||
*/ | ||
public function paymentOfOrderFailed(OrderInterface $order): void | ||
{ | ||
$payment = $order->getLastPayment(); | ||
$this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->apply(PaymentTransitions::TRANSITION_FAIL); | ||
} | ||
|
||
/** | ||
* @Given /^the customer chose ("[^"]+" payment) method$/ | ||
*/ | ||
public function theCustomerChosePaymentMethod(PaymentMethodInterface $paymentMethod): void | ||
{ | ||
/** @var OrderInterface $order */ | ||
$order = $this->sharedStorage->get('order'); | ||
|
||
$lastPayment = $order->getLastPayment(); | ||
$lastPayment->setMethod($paymentMethod); | ||
|
||
$this->sharedStorage->set('payment', $lastPayment); | ||
} | ||
|
||
/** | ||
* @Given /^(this payment) has been paid$/ | ||
*/ | ||
public function andThisPaymentHasBeenPaid(PaymentInterface $payment): void | ||
{ | ||
$this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->apply(PaymentTransitions::TRANSITION_COMPLETE); | ||
} | ||
} |
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
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
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
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
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