-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NTR: PIHPS-205 - add new payment method blik (#701)
* NTR: PIHPS-205 - add new payment method blik * NTR: merge master commit 3a0f05d Author: Vitalij Mik <[email protected]> Date: Fri Feb 9 12:28:17 2024 +0100 NTR: test SW 6.5.8.4 (#703) Co-authored-by: Vitalij Mik <[email protected]> commit f8390b3 Author: Vitalij Mik <[email protected]> Date: Fri Feb 9 11:29:47 2024 +0100 NTR: new shopware version (#702) Co-authored-by: Vitalij Mik <[email protected]> * NTR: set billing address from cart * NTR: change text * NTR: change name --------- Co-authored-by: Vitalij Mik <[email protected]>
- Loading branch information
1 parent
3a0f05d
commit 1914194
Showing
15 changed files
with
201 additions
and
21 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
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,32 @@ | ||
<?php | ||
|
||
namespace Kiener\MolliePayments\Handler\Method; | ||
|
||
use Kiener\MolliePayments\Handler\PaymentHandler; | ||
use Mollie\Api\Types\PaymentMethod; | ||
use Shopware\Core\Checkout\Customer\CustomerEntity; | ||
use Shopware\Core\Checkout\Order\OrderEntity; | ||
use Shopware\Core\System\Locale\LocaleEntity; | ||
use Shopware\Core\System\SalesChannel\SalesChannelContext; | ||
|
||
class BlikPayment extends PaymentHandler | ||
{ | ||
public const PAYMENT_METHOD_NAME = 'blik'; | ||
public const PAYMENT_METHOD_DESCRIPTION = 'Blik'; | ||
|
||
/** @var string */ | ||
protected $paymentMethod = self::PAYMENT_METHOD_NAME; | ||
|
||
|
||
/** | ||
* @param array<mixed> $orderData | ||
* @param OrderEntity $orderEntity | ||
* @param SalesChannelContext $salesChannelContext | ||
* @param CustomerEntity $customer | ||
* @return array<mixed> | ||
*/ | ||
public function processPaymentMethodSpecificParameters(array $orderData, OrderEntity $orderEntity, SalesChannelContext $salesChannelContext, CustomerEntity $customer): array | ||
{ | ||
return $orderData; | ||
} | ||
} |
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
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
43 changes: 43 additions & 0 deletions
43
tests/Cypress/cypress/e2e/storefront/payment-methods/blik.cy.js
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,43 @@ | ||
import Devices from "Services/utils/Devices"; | ||
import Session from "Services/utils/Session" | ||
// ------------------------------------------------------ | ||
import PaymentAction from "Actions/storefront/checkout/PaymentAction"; | ||
import DummyBasketScenario from "Scenarios/DummyBasketScenario"; | ||
// ------------------------------------------------------ | ||
|
||
|
||
const devices = new Devices(); | ||
const session = new Session(); | ||
|
||
const paymentAction = new PaymentAction(); | ||
const scenarioDummyBasket = new DummyBasketScenario(1); | ||
|
||
const device = devices.getFirstDevice(); | ||
|
||
|
||
describe('Blik payment method', () => { | ||
|
||
context(devices.getDescription(device), () => { | ||
|
||
before(function () { | ||
devices.setDevice(device); | ||
}) | ||
|
||
beforeEach(() => { | ||
session.resetBrowserSession(); | ||
devices.setDevice(device); | ||
}); | ||
|
||
it('Blik is existing in checkout', () => { | ||
|
||
scenarioDummyBasket.execute(); | ||
|
||
paymentAction.switchPaymentMethod('Blik'); | ||
|
||
// payment would only work using currency CHF which cannot be done at the moment | ||
}) | ||
|
||
}) | ||
|
||
}) | ||
|
68 changes: 68 additions & 0 deletions
68
tests/PHPUnit/Service/MollieApi/Builder/Payments/BlikOrderBuilderTest.php
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 declare(strict_types=1); | ||
|
||
namespace MolliePayments\Tests\Service\MollieApi\Builder\Payments; | ||
|
||
use DateTime; | ||
use DateTimeZone; | ||
use Faker\Extension\Container; | ||
use Kiener\MolliePayments\Handler\Method\BlikPayment; | ||
use Kiener\MolliePayments\Handler\Method\KlarnaPayLaterPayment; | ||
use Kiener\MolliePayments\Handler\Method\TwintPayment; | ||
use Kiener\MolliePayments\Service\MollieApi\Builder\MollieOrderPriceBuilder; | ||
use Mollie\Api\Types\PaymentMethod; | ||
use MolliePayments\Tests\Fakes\FakeContainer; | ||
use MolliePayments\Tests\Service\MollieApi\Builder\AbstractMollieOrderBuilder; | ||
use Shopware\Core\Checkout\Cart\Price\Struct\CartPrice; | ||
use Shopware\Core\Framework\Uuid\Uuid; | ||
use Shopware\Core\System\Currency\CurrencyEntity; | ||
|
||
class BlikOrderBuilderTest extends AbstractMollieOrderBuilder | ||
{ | ||
public function testOrderBuild(): void | ||
{ | ||
$redirectWebhookUrl = 'https://foo'; | ||
$this->router->method('generate')->willReturn($redirectWebhookUrl); | ||
|
||
|
||
$this->paymentHandler = new BlikPayment( | ||
$this->loggerService, | ||
new FakeContainer() | ||
); | ||
|
||
$transactionId = Uuid::randomHex(); | ||
$amountTotal = 27.0; | ||
$taxStatus = CartPrice::TAX_STATE_GROSS; | ||
$currencyISO = 'EUR'; | ||
|
||
$currency = new CurrencyEntity(); | ||
$currency->setId(Uuid::randomHex()); | ||
$currency->setIsoCode($currencyISO); | ||
|
||
$orderNumber = 'foo number'; | ||
$lineItems = $this->getDummyLineItems(); | ||
|
||
$order = $this->getOrderEntity($amountTotal, $taxStatus, $currencyISO, $lineItems, $orderNumber); | ||
|
||
$actual = $this->builder->buildOrderPayload($order, $transactionId, $this->paymentHandler::PAYMENT_METHOD_NAME, $this->salesChannelContext, $this->paymentHandler, []); | ||
|
||
$expectedOrderLifeTime = (new DateTime())->setTimezone(new DateTimeZone('UTC')) | ||
->modify(sprintf('+%d day', $this->expiresAt)) | ||
->format('Y-m-d'); | ||
|
||
$expected = [ | ||
'amount' => (new MollieOrderPriceBuilder())->build($amountTotal, $currencyISO), | ||
'locale' => $this->localeCode, | ||
'method' => $this->paymentHandler::PAYMENT_METHOD_NAME, | ||
'orderNumber' => $orderNumber, | ||
'payment' => ['webhookUrl' => $redirectWebhookUrl], | ||
'redirectUrl' => $redirectWebhookUrl, | ||
'webhookUrl' => $redirectWebhookUrl, | ||
'lines' => $this->getExpectedLineItems($taxStatus, $lineItems, $currency), | ||
'billingAddress' => $this->getExpectedTestAddress($this->address, $this->email), | ||
'shippingAddress' => $this->getExpectedTestAddress($this->address, $this->email), | ||
'expiresAt' => $expectedOrderLifeTime | ||
]; | ||
|
||
self::assertSame($expected, $actual); | ||
} | ||
} |
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