Skip to content

Commit 67b39e0

Browse files
committed
[Maintenance] Add sylius/paypal-plugin
1 parent daad4a5 commit 67b39e0

File tree

13 files changed

+155
-0
lines changed

13 files changed

+155
-0
lines changed

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
],
2626
"require": {
2727
"php": "^8.1",
28+
"sylius/paypal-plugin": "^1.7.x-dev",
2829
"sylius/sylius": "~1.14.0",
2930
"symfony/dotenv": "^5.4 || ^6.4",
3031
"symfony/flex": "^2.4",

config/bundles.php

+1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@
6060
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
6161
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
6262
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
63+
Sylius\PayPalPlugin\SyliusPayPalPlugin::class => ['all' => true],
6364
];

config/packages/_sylius.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ imports:
55
- { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" }
66

77
- { resource: "@SyliusShopBundle/Resources/config/app/config.yml" }
8+
- { resource: "@SyliusPayPalPlugin/Resources/config/config.yaml" }
89

910
- { resource: "../parameters.yaml" }
1011

config/packages/http_discovery.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
Psr\Http\Message\RequestFactoryInterface: '@http_discovery.psr17_factory'
3+
Psr\Http\Message\ResponseFactoryInterface: '@http_discovery.psr17_factory'
4+
Psr\Http\Message\ServerRequestFactoryInterface: '@http_discovery.psr17_factory'
5+
Psr\Http\Message\StreamFactoryInterface: '@http_discovery.psr17_factory'
6+
Psr\Http\Message\UploadedFileFactoryInterface: '@http_discovery.psr17_factory'
7+
Psr\Http\Message\UriFactoryInterface: '@http_discovery.psr17_factory'
8+
9+
http_discovery.psr17_factory:
10+
class: Http\Discovery\Psr17Factory

config/routes.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sylius_paypal_webhook:
2+
resource: "@SyliusPayPalPlugin/Resources/config/webhook_routing.yaml"

config/routes/sylius_admin.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
sylius_admin:
22
resource: "@SyliusAdminBundle/Resources/config/routing.yml"
33
prefix: '/%sylius_admin.path_name%'
4+
5+
sylius_paypal_admin:
6+
resource: "@SyliusPayPalPlugin/Resources/config/admin_routing.yml"
7+
prefix: '/%sylius_admin.path_name%'

config/routes/sylius_shop.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ sylius_shop_request_password_reset_token_redirect:
2121
defaults:
2222
route: sylius_shop_request_password_reset_token
2323
permanent: false
24+
25+
sylius_paypal:
26+
resource: "@SyliusPayPalPlugin/Resources/config/shop_routing.yaml"
27+
prefix: /{_locale}
28+
requirements:
29+
_locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$

symfony.lock

+15
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,18 @@
326326
"phar-io/version": {
327327
"version": "1.0.1"
328328
},
329+
"php-http/discovery": {
330+
"version": "1.20",
331+
"recipe": {
332+
"repo": "github.com/symfony/recipes",
333+
"branch": "main",
334+
"version": "1.18",
335+
"ref": "f45b5dd173a27873ab19f5e3180b2f661c21de02"
336+
},
337+
"files": [
338+
"config/packages/http_discovery.yaml"
339+
]
340+
},
329341
"php-http/httplug": {
330342
"version": "v1.1.0"
331343
},
@@ -518,6 +530,9 @@
518530
"sylius/mailer-bundle": {
519531
"version": "v1.4.4"
520532
},
533+
"sylius/paypal-plugin": {
534+
"version": "1.7.x-dev"
535+
},
521536
"sylius/registry": {
522537
"version": "v1.4.1"
523538
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% for name, gateway in gatewayFactories %}
2+
<a href="{{ url('sylius_admin_payment_method_create', { 'factory': name }) }}" id="{{ name }}" class="item" {% if name == 'sylius.pay_pal' %}data-confirm-pay-pal-consent{% endif %}>
3+
{{ gateway|trans }}
4+
</a>
5+
{% endfor %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div class="item" {{ sylius_test_html_attribute('payment-item') }}>
2+
<div class="field">
3+
<div class="ui radio checkbox" {{ sylius_test_html_attribute('payment-method-checkbox') }}>
4+
{{ form_widget(form, sylius_test_form_attribute('payment-method-select')) }}
5+
</div>
6+
</div>
7+
<div class="content">
8+
<a class="header">{{ form_label(form, null, {'label_attr': {'data-test-payment-method-label': ''}}) }}</a>
9+
{% if method.description is not null %}
10+
<div class="description">
11+
<p>{{ method.description }}</p>
12+
</div>
13+
{% endif %}
14+
{% if order.checkoutState != constant('Sylius\\Component\\Core\\OrderCheckoutStates::STATE_COMPLETED') and method.gatewayConfig.factoryName == 'sylius.pay_pal' %}
15+
{{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController::renderPaymentPageButtonsAction', {'orderId': order.id})) }}
16+
{% endif %}
17+
</div>
18+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<div class="ui segment">
2+
<div class="ui {% if order.isShippingRequired() %}two{% else %}one{% endif %} column divided stackable grid">
3+
<div class="column" id="sylius-billing-address" {{ sylius_test_html_attribute('billing-address') }}>
4+
<div class="ui small dividing header">{{ 'sylius.ui.billing_address'|trans }}</div>
5+
{% include '@SyliusShop/Common/_address.html.twig' with {'address': order.billingAddress} %}
6+
</div>
7+
{% if order.isShippingRequired() %}
8+
<div class="column" id="sylius-shipping-address" {{ sylius_test_html_attribute('shipping-address') }}>
9+
<div class="ui small dividing header">{{ 'sylius.ui.shipping_address'|trans }}</div>
10+
{% include '@SyliusShop/Common/_address.html.twig' with {'address': order.shippingAddress} %}
11+
</div>
12+
{% endif %}
13+
</div>
14+
</div>
15+
{% if sylius_is_billing_address_missing(order) %}
16+
<div class="ui icon message">
17+
<i class="address card icon"></i>
18+
<div class="content">
19+
<div class="header">{{ 'sylius.pay_pal.missing_billing_address_header'|trans }}</div>
20+
<p>{{ 'sylius.pay_pal.missing_billing_address_content'|trans }}</p>
21+
</div>
22+
</div>
23+
{% endif %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
2+
3+
{% set state = order.paymentState %}
4+
5+
{% if state != 'cart' %}
6+
{% include "@SyliusShop/Common/Order/Label/PaymentState/orderPaymentState.html.twig" %}
7+
{% endif %}
8+
9+
{% for payment in order.payments %}
10+
{% set state = payment.state %}
11+
12+
<div class="ui small icon message">
13+
<i class="payment icon"></i>
14+
<div class="content">
15+
<div class="header" id="sylius-payment-method" {{ sylius_test_html_attribute('payment-method') }}>
16+
{{ payment.method }}
17+
</div>
18+
<p {{ sylius_test_html_attribute('payment-price') }}>{{ money.format(payment.amount, payment.currencyCode) }}</p>
19+
{% if payment.amount != payment.order.total and state == 'processing' %}
20+
<i>{{ 'sylius.pay_pal.different_amount'|trans }}</i>
21+
{% endif %}
22+
{% if state != 'cart' %}
23+
<p id="payment-status" {{ sylius_test_html_attribute('payment-state') }}>
24+
{% include "@SyliusShop/Common/Order/Label/PaymentState/singlePaymentState.html.twig" with { 'state': state } %}
25+
</p>
26+
{% endif %}
27+
</div>
28+
</div>
29+
{% endfor %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{% extends '@SyliusShop/layout.html.twig' %}
2+
3+
{% block content %}
4+
<div class="ui hidden divider"></div>
5+
<div class="ui grid">
6+
<div class="center aligned sixteen wide column">
7+
<h1 class="ui icon header">
8+
{% set lastPayment = order.payments.last() %}
9+
<i class="circular rocket icon"></i>
10+
<div class="content" id="sylius-thank-you" {{ sylius_test_html_attribute('thank-you') }}>
11+
{{ 'sylius.ui.thank_you'|trans }}
12+
<div class="sub header">{{ 'sylius.ui.placed_an_order'|trans }}</div>
13+
</div>
14+
</h1>
15+
16+
{{ sylius_template_event('sylius.shop.order.thank_you.after_message', {'order': order}) }}
17+
18+
{% if lastPayment != false %}
19+
{% if lastPayment.method.instructions is not null %}
20+
<div id="sylius-payment-method-instructions" class="ui segment" {{ sylius_test_html_attribute('payment-method-instructions') }}>
21+
{{ lastPayment.method.instructions }}
22+
</div>
23+
{% endif %}
24+
<div class="ui hidden divider"></div>
25+
{% endif %}
26+
27+
{% if order.customer.user is not null %}
28+
<a href="{{ path('sylius_shop_account_order_show', {'number': order.number}) }}" id="sylius-show-order-in-account" class="ui large blue button" {{ sylius_test_html_attribute('show-order-in-account') }}>{{ 'sylius.ui.view_order'|trans }}</a>
29+
{% else %}
30+
{% if lastPayment.state != 'completed' %}
31+
<a href="{{ path('sylius_shop_order_show', {'tokenValue': order.tokenValue}) }}" id="payment-method-page" class="ui large blue button" {{ sylius_test_html_attribute('payment-method-page') }}>{{ 'sylius.ui.change_payment_method'|trans }}</a>
32+
{% endif %}
33+
<a href="{{ path('sylius_shop_register_after_checkout', {'tokenValue': order.tokenValue}) }}" class="ui large green button" {{ sylius_test_html_attribute('create-an-account') }}>
34+
<i class="signup icon"></i>
35+
{{ 'sylius.ui.create_an_account'|trans }}
36+
</a>
37+
{% endif %}
38+
</div>
39+
</div>
40+
{% endblock %}

0 commit comments

Comments
 (0)