Skip to content
Open
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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ This **open-source plugin was developed to help the Sylius community**. If you h
4. Add routing to sylius_shop.yml:
```yaml
sylius_shop_checkout_start:
path: /{_locale}/checkout-start
path: /

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't needed for me

methods: [GET]
defaults:
_controller: bitbag_sylius_amazon_pay_plugin.controller.action.checkout_start
requirements:
_locale: ^[a-z]{2}(?:_[A-Z]{2})?$

```
5. Please add the Webpack build configuration to your `config/packages/webpack_encore.yaml` file:

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Action/AmazonPayStartAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(Environment $templating)
public function __invoke(Request $request): Response
{
return new Response(
$this->templating->render('BitBagSyliusAmazonPayPlugin:AmazonPay:amazonPayStart.html.twig')
$this->templating->render('@BitBagSyliusAmazonPayPlugin/AmazonPay/amazonPayStart.html.twig')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

);
}
}
2 changes: 1 addition & 1 deletion src/Controller/Action/CheckoutStartAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __invoke(Request $request): Response
$order = $this->cartContext->getCart();

/** @var PaymentMethodInterface $paymentMethod */
$paymentMethod = $order->getLastPayment()->getMethod();
$paymentMethod = $order->getLastPayment()?->getMethod();

if (
null !== $paymentMethod &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'assets/shop/js/app.js'} %}
{{ encore_entry_script_tags('app-shop-entry', null, 'app.shop') }}

<link href="{{ asset('bundles/bitbagsyliusamazonpayplugin/css/Widgets.css') }}" rel="stylesheet">

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/AmazonPay/Summary/_widget.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="readOnlyAddressBookWidgetDiv"></div>
<div id="readOnlyWalletWidgetDiv"></div>

{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'assets/shop/js/app.js'} %}
{{ encore_entry_script_tags('app-shop-entry', null, 'app.shop') }}

<link href="{{ asset('bundles/bitbagsyliusamazonpayplugin/css/Widgets.css') }}" rel="stylesheet">

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/AmazonPay/Wallet/_widget.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="walletWidgetDiv"></div>

{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'assets/shop/js/app.js'} %}
{{ encore_entry_script_tags('app-shop-entry', null, 'app.shop') }}

<link href="{{ asset('bundles/bitbagsyliusamazonpayplugin/css/Widgets.css') }}" rel="stylesheet">

Expand Down
16 changes: 9 additions & 7 deletions src/Resources/views/AmazonPay/amazonPayStart.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'assets/shop/js/app.js'} %}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lines should not be removed, but replaced with:

{{ encore_entry_script_tags('shop-entry', null, 'shop') }}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we didn't need the shop javascript here. all the code is plain javascript here without dependencies.
But i can readd it if we need it.


<script>
function getURLParameter(name, source) {
return decodeURIComponent((new RegExp('[?|&|#]' + name + '=' +
Expand All @@ -8,17 +6,21 @@
;
}

let accessToken = getURLParameter("access_token", location.hash);
let accessToken = getURLParameter('access_token', location.hash);

if (typeof accessToken === 'string' && accessToken.match(/^Atza/)) {
document.cookie = "amazon_Login_accessToken=" + accessToken;
}

$.post('{{ path('bitbag_sylius_amazon_pay_initialize') }}', {
accessToken: accessToken
}).done(function (data) {
let formData = new FormData();
formData.append('accessToken', accessToken);

fetch('{{ path('bitbag_sylius_amazon_pay_initialize') }}', {
method: 'POST',
body: formData
}).then(function (data) {
window.location.replace("{{ path('sylius_shop_checkout_address') }}" + location.hash);
}).fail(function (data) {
}).catch(function (data) {
{#window.location.replace("{{ path('sylius_shop_cart_summary') }}");#}
});
</script>
2 changes: 1 addition & 1 deletion src/Twig/Extension/RenderSummaryWidgetExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function renderSummaryWidget(): string
$order = $this->cartContext->getCart();

/** @var PaymentMethod $paymentMethodCurrent */
$paymentMethodCurrent = $order->getLastPayment()->getMethod();
$paymentMethodCurrent = $order->getLastPayment()?->getMethod();

if (
null === $paymentMethodCurrent ||
Expand Down