Skip to content

Commit

Permalink
[Maintenance] Add sylius/paypal-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojdylak committed Nov 15, 2024
1 parent daad4a5 commit 67b39e0
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
],
"require": {
"php": "^8.1",
"sylius/paypal-plugin": "^1.7.x-dev",
"sylius/sylius": "~1.14.0",
"symfony/dotenv": "^5.4 || ^6.4",
"symfony/flex": "^2.4",
Expand Down
1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
Sylius\PayPalPlugin\SyliusPayPalPlugin::class => ['all' => true],
];
1 change: 1 addition & 0 deletions config/packages/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ imports:
- { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" }

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

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

Expand Down
10 changes: 10 additions & 0 deletions config/packages/http_discovery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
Psr\Http\Message\RequestFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\ResponseFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\ServerRequestFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\StreamFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\UploadedFileFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\UriFactoryInterface: '@http_discovery.psr17_factory'

http_discovery.psr17_factory:
class: Http\Discovery\Psr17Factory
2 changes: 2 additions & 0 deletions config/routes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sylius_paypal_webhook:
resource: "@SyliusPayPalPlugin/Resources/config/webhook_routing.yaml"
4 changes: 4 additions & 0 deletions config/routes/sylius_admin.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
sylius_admin:
resource: "@SyliusAdminBundle/Resources/config/routing.yml"
prefix: '/%sylius_admin.path_name%'

sylius_paypal_admin:
resource: "@SyliusPayPalPlugin/Resources/config/admin_routing.yml"
prefix: '/%sylius_admin.path_name%'
6 changes: 6 additions & 0 deletions config/routes/sylius_shop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ sylius_shop_request_password_reset_token_redirect:
defaults:
route: sylius_shop_request_password_reset_token
permanent: false

sylius_paypal:
resource: "@SyliusPayPalPlugin/Resources/config/shop_routing.yaml"
prefix: /{_locale}
requirements:
_locale: ^[A-Za-z]{2,4}(_([A-Za-z]{4}|[0-9]{3}))?(_([A-Za-z]{2}|[0-9]{3}))?$
15 changes: 15 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,18 @@
"phar-io/version": {
"version": "1.0.1"
},
"php-http/discovery": {
"version": "1.20",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.18",
"ref": "f45b5dd173a27873ab19f5e3180b2f661c21de02"
},
"files": [
"config/packages/http_discovery.yaml"
]
},
"php-http/httplug": {
"version": "v1.1.0"
},
Expand Down Expand Up @@ -518,6 +530,9 @@
"sylius/mailer-bundle": {
"version": "v1.4.4"
},
"sylius/paypal-plugin": {
"version": "1.7.x-dev"
},
"sylius/registry": {
"version": "v1.4.1"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% for name, gateway in gatewayFactories %}
<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 %}>
{{ gateway|trans }}
</a>
{% endfor %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="item" {{ sylius_test_html_attribute('payment-item') }}>
<div class="field">
<div class="ui radio checkbox" {{ sylius_test_html_attribute('payment-method-checkbox') }}>
{{ form_widget(form, sylius_test_form_attribute('payment-method-select')) }}
</div>
</div>
<div class="content">
<a class="header">{{ form_label(form, null, {'label_attr': {'data-test-payment-method-label': ''}}) }}</a>
{% if method.description is not null %}
<div class="description">
<p>{{ method.description }}</p>
</div>
{% endif %}
{% if order.checkoutState != constant('Sylius\\Component\\Core\\OrderCheckoutStates::STATE_COMPLETED') and method.gatewayConfig.factoryName == 'sylius.pay_pal' %}
{{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController::renderPaymentPageButtonsAction', {'orderId': order.id})) }}
{% endif %}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="ui segment">
<div class="ui {% if order.isShippingRequired() %}two{% else %}one{% endif %} column divided stackable grid">
<div class="column" id="sylius-billing-address" {{ sylius_test_html_attribute('billing-address') }}>
<div class="ui small dividing header">{{ 'sylius.ui.billing_address'|trans }}</div>
{% include '@SyliusShop/Common/_address.html.twig' with {'address': order.billingAddress} %}
</div>
{% if order.isShippingRequired() %}
<div class="column" id="sylius-shipping-address" {{ sylius_test_html_attribute('shipping-address') }}>
<div class="ui small dividing header">{{ 'sylius.ui.shipping_address'|trans }}</div>
{% include '@SyliusShop/Common/_address.html.twig' with {'address': order.shippingAddress} %}
</div>
{% endif %}
</div>
</div>
{% if sylius_is_billing_address_missing(order) %}
<div class="ui icon message">
<i class="address card icon"></i>
<div class="content">
<div class="header">{{ 'sylius.pay_pal.missing_billing_address_header'|trans }}</div>
<p>{{ 'sylius.pay_pal.missing_billing_address_content'|trans }}</p>
</div>
</div>
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}

{% set state = order.paymentState %}

{% if state != 'cart' %}
{% include "@SyliusShop/Common/Order/Label/PaymentState/orderPaymentState.html.twig" %}
{% endif %}

{% for payment in order.payments %}
{% set state = payment.state %}

<div class="ui small icon message">
<i class="payment icon"></i>
<div class="content">
<div class="header" id="sylius-payment-method" {{ sylius_test_html_attribute('payment-method') }}>
{{ payment.method }}
</div>
<p {{ sylius_test_html_attribute('payment-price') }}>{{ money.format(payment.amount, payment.currencyCode) }}</p>
{% if payment.amount != payment.order.total and state == 'processing' %}
<i>{{ 'sylius.pay_pal.different_amount'|trans }}</i>
{% endif %}
{% if state != 'cart' %}
<p id="payment-status" {{ sylius_test_html_attribute('payment-state') }}>
{% include "@SyliusShop/Common/Order/Label/PaymentState/singlePaymentState.html.twig" with { 'state': state } %}
</p>
{% endif %}
</div>
</div>
{% endfor %}
40 changes: 40 additions & 0 deletions templates/bundles/SyliusShopBundle/Order/thankYou.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% extends '@SyliusShop/layout.html.twig' %}

{% block content %}
<div class="ui hidden divider"></div>
<div class="ui grid">
<div class="center aligned sixteen wide column">
<h1 class="ui icon header">
{% set lastPayment = order.payments.last() %}
<i class="circular rocket icon"></i>
<div class="content" id="sylius-thank-you" {{ sylius_test_html_attribute('thank-you') }}>
{{ 'sylius.ui.thank_you'|trans }}
<div class="sub header">{{ 'sylius.ui.placed_an_order'|trans }}</div>
</div>
</h1>

{{ sylius_template_event('sylius.shop.order.thank_you.after_message', {'order': order}) }}

{% if lastPayment != false %}
{% if lastPayment.method.instructions is not null %}
<div id="sylius-payment-method-instructions" class="ui segment" {{ sylius_test_html_attribute('payment-method-instructions') }}>
{{ lastPayment.method.instructions }}
</div>
{% endif %}
<div class="ui hidden divider"></div>
{% endif %}

{% if order.customer.user is not null %}
<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>
{% else %}
{% if lastPayment.state != 'completed' %}
<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>
{% endif %}
<a href="{{ path('sylius_shop_register_after_checkout', {'tokenValue': order.tokenValue}) }}" class="ui large green button" {{ sylius_test_html_attribute('create-an-account') }}>
<i class="signup icon"></i>
{{ 'sylius.ui.create_an_account'|trans }}
</a>
{% endif %}
</div>
</div>
{% endblock %}

0 comments on commit 67b39e0

Please sign in to comment.