From 8328364608231dcdce796e9a83b9dce2b6d202f1 Mon Sep 17 00:00:00 2001 From: maxperei Date: Mon, 13 Feb 2023 10:02:06 +0100 Subject: [PATCH 01/12] fix: css fine-tuning payment methods `label > img` --- src/Resources/dev/pages/payment/index.scss | 33 ++++--------------- .../public/assets/oney/payment/index.css | 2 +- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/Resources/dev/pages/payment/index.scss b/src/Resources/dev/pages/payment/index.scss index e7862c25..bf3f1bac 100644 --- a/src/Resources/dev/pages/payment/index.scss +++ b/src/Resources/dev/pages/payment/index.scss @@ -144,35 +144,14 @@ .apple-pay-method, .american-express-method { label { - display: flex !important; - align-items: flex-start; - } - } - - .bancontact-method { - .bancontact-logo { - margin-left: 0.5em; - position: relative; - top: -12px; - } - } - - .american-express-method { - .american-express-logo { - margin-left: 0.5em; position: relative; - top: -12px; - } - } - - .apple-pay-method { - label { - height: 45px; - } - .apple-pay-logo { - margin-left: 0.5em; - transform: translateY(-12px); + img { + position: absolute; + left: 100%; + margin-left: 0.5em; + top: -12px; + } } } } diff --git a/src/Resources/public/assets/oney/payment/index.css b/src/Resources/public/assets/oney/payment/index.css index adfe5822..1ca41c46 100644 --- a/src/Resources/public/assets/oney/payment/index.css +++ b/src/Resources/public/assets/oney/payment/index.css @@ -1 +1 @@ -.oney-payment-choice__item label,.payplug-payment-choice__item label{margin-top:0!important;padding:1em!important;display:flex!important}.oney-payment-choice,.payplug-payment-choice{display:none}.oney-payment-choice__container,.payplug-payment-choice__container{margin:1rem 0;display:flex}.oney-payment-choice__header p,.payplug-payment-choice__header p{color:#000;margin:.5em 0!important}.oney-payment-choice__item,.payplug-payment-choice__item{flex:auto}.oney-payment-choice__item--oney_x3_with_fees,.oney-payment-choice__item--oney_x3_without_fees,.payplug-payment-choice__item--oney_x3_with_fees,.payplug-payment-choice__item--oney_x3_without_fees{margin-right:1em}.oney-payment-choice__item input,.payplug-payment-choice__item input{display:none}.oney-payment-choice__item input:checked+label,.payplug-payment-choice__item input:checked+label{background-color:#81bc0021;border-color:#81bc00}.oney-payment-choice__item input:checked+label.payplug-payment-choice__label,.payplug-payment-choice__item input:checked+label.payplug-payment-choice__label{background-color:#8fd2b821;border-color:#8fd2b8}.oney-payment-choice__item label,.payplug-payment-choice__item label{width:100%;height:100%;cursor:pointer;border:1px solid #ccc;border-radius:.285714rem;flex-direction:column;transition:border-color,background-color .3s ease-in-out;position:relative;box-shadow:0 1px 2px #22242626}.oney-payment-choice__item label img,.payplug-payment-choice__item label img{vertical-align:text-bottom}.oney-payment-choice__content,.payplug-payment-choice__content{display:contents}.oney-payment-choice__content p,.payplug-payment-choice__content p{color:#000;border-bottom:1px solid #ccc;flex-wrap:wrap;justify-content:space-between;display:flex;margin:0!important;padding:.75rem 0!important}.oney-payment-choice__content p:nth-last-of-type(2),.payplug-payment-choice__content p:nth-last-of-type(2){margin-bottom:1rem!important}.oney-payment-choice__content p:last-of-type,.payplug-payment-choice__content p:last-of-type{border:none;margin-top:auto!important;margin-bottom:0!important}.oney-payment-choice__content p.oney-without-fees-financing,.payplug-payment-choice__content p.oney-without-fees-financing{display:inline-block}.oney-payment-choice__content small,.payplug-payment-choice__content small{margin-top:.5rem;font-size:80%}.oney-payment-choice__tab{display:none}.oney-payment-choice__header{text-align:center;margin:0 auto}[data-gateway=oney]{margin-top:10px!important;padding:0!important}.payment-item .oney-logo[src*=without-fees]{max-width:200px}.payment-item apple-pay-button{--apple-pay-button-width:222px;--apple-pay-button-height:40px;--apple-pay-button-border-radius:4px;--apple-pay-button-padding:4px 4px;--apple-pay-button-box-sizing:border-box;min-width:140px;max-width:100%;transition:background-color .3s ease-in-out;display:none}.payment-item apple-pay-button.enabled{display:block}.payment-item label{cursor:pointer}.payment-item .bancontact-method label,.payment-item .apple-pay-method label,.payment-item .american-express-method label{align-items:flex-start;display:flex!important}.payment-item .bancontact-method .bancontact-logo,.payment-item .american-express-method .american-express-logo{margin-left:.5em;position:relative;top:-12px}.payment-item .apple-pay-method label{height:45px}.payment-item .apple-pay-method .apple-pay-logo{margin-left:.5em;transform:translateY(-12px)}.payplug-payment-choice__container{flex-direction:column}.payplug-payment-choice__item{margin-bottom:1em}.payplug-payment-choice__header{justify-content:space-between;align-items:center;display:flex}.payplug-payment-choice__header .card-expiry span{font-weight:700}.oney-complete-info-popin{text-align:center;max-width:480px;z-index:4;top:50%;left:0;right:0;transform:translateY(-50%);margin:auto!important;position:fixed!important}.oney-complete-info-popin__header{text-align:right}.oney-complete-info-popin__header a.close>span{width:15px;height:2px;background-color:#0000000d;border-radius:0;margin:0;position:absolute;top:1em;right:.5em}.oney-complete-info-popin__header a.close>span:first-of-type{transform:rotate(45deg)}.oney-complete-info-popin__header a.close>span:last-of-type{transform:rotate(-45deg)}.oney-complete-info-popin__content{text-align:left}.oney-complete-info-popin__content ul{padding:0;list-style:none}.oney-complete-info-popin__content ul li{color:#fff;background-color:#db2828;border-color:#db2828;border-radius:.285714rem;margin:0 .142857em;padding:.5833em .833em;font-size:.857143rem;font-weight:700;display:inline-block}.oney-complete-info-popin__success{display:none}.oney-complete-info-popin__success i.icon{color:#21ba45;display:inline-block!important}.ui.container{position:relative}.inactive{pointer-events:none}.overlay{width:100%;height:100%;z-index:3;background:#00000040;display:block;position:absolute}@media screen and (max-width:991px){.oney-payment-choice__container,.payplug-payment-choice__container{display:block}.oney-payment-choice__content small,.payplug-payment-choice__content small{width:100%}.oney-payment-choice__tab{justify-content:space-between;display:flex}.oney-payment-choice__tab .tablink{text-align:center;border:1px solid #ccc;border-bottom:0;flex:1;padding:1rem 0}.oney-payment-choice__tab .tablink.active{border-bottom:5px solid #81bc00}.oney-payment-choice__tab .tablink p{color:#000}.oney-payment-choice__tab .tablink:first-of-type{border-right:0}.oney-payment-choice__tab .tablink>.oney-payment__image{max-width:120px}.oney-payment-choice__header,.oney-payment-choice__item{display:none}.oney-payment-choice__item input:checked+label{background-color:#fff;border-color:#ccc}.oney-payment-choice__item label{border-top-left-radius:0;border-top-right-radius:0}.oney-payment-choice__item--oney_x3_with_fees,.oney-payment-choice__item--oney_x3_without_fees{margin-bottom:1rem;margin-right:0;display:block}}@media screen and (max-width:480px){.payplug-payment-choice__header,.payplug-payment-choice__header .card-type,.payplug-payment-choice__header .card-expiry{display:block}} \ No newline at end of file +.oney-payment-choice__item label,.payplug-payment-choice__item label{margin-top:0!important;padding:1em!important;display:flex!important}.oney-payment-choice,.payplug-payment-choice{display:none}.oney-payment-choice__container,.payplug-payment-choice__container{margin:1rem 0;display:flex}.oney-payment-choice__header p,.payplug-payment-choice__header p{color:#000;margin:.5em 0!important}.oney-payment-choice__item,.payplug-payment-choice__item{flex:auto}.oney-payment-choice__item--oney_x3_with_fees,.oney-payment-choice__item--oney_x3_without_fees,.payplug-payment-choice__item--oney_x3_with_fees,.payplug-payment-choice__item--oney_x3_without_fees{margin-right:1em}.oney-payment-choice__item input,.payplug-payment-choice__item input{display:none}.oney-payment-choice__item input:checked+label,.payplug-payment-choice__item input:checked+label{background-color:#81bc0021;border-color:#81bc00}.oney-payment-choice__item input:checked+label.payplug-payment-choice__label,.payplug-payment-choice__item input:checked+label.payplug-payment-choice__label{background-color:#8fd2b821;border-color:#8fd2b8}.oney-payment-choice__item label,.payplug-payment-choice__item label{width:100%;height:100%;cursor:pointer;border:1px solid #ccc;border-radius:.285714rem;flex-direction:column;transition:border-color,background-color .3s ease-in-out;position:relative;box-shadow:0 1px 2px #22242626}.oney-payment-choice__item label img,.payplug-payment-choice__item label img{vertical-align:text-bottom}.oney-payment-choice__content,.payplug-payment-choice__content{display:contents}.oney-payment-choice__content p,.payplug-payment-choice__content p{color:#000;border-bottom:1px solid #ccc;flex-wrap:wrap;justify-content:space-between;display:flex;margin:0!important;padding:.75rem 0!important}.oney-payment-choice__content p:nth-last-of-type(2),.payplug-payment-choice__content p:nth-last-of-type(2){margin-bottom:1rem!important}.oney-payment-choice__content p:last-of-type,.payplug-payment-choice__content p:last-of-type{border:none;margin-top:auto!important;margin-bottom:0!important}.oney-payment-choice__content p.oney-without-fees-financing,.payplug-payment-choice__content p.oney-without-fees-financing{display:inline-block}.oney-payment-choice__content small,.payplug-payment-choice__content small{margin-top:.5rem;font-size:80%}.oney-payment-choice__tab{display:none}.oney-payment-choice__header{text-align:center;margin:0 auto}[data-gateway=oney]{margin-top:10px!important;padding:0!important}.payment-item .oney-logo[src*=without-fees]{max-width:200px}.payment-item apple-pay-button{--apple-pay-button-width:222px;--apple-pay-button-height:40px;--apple-pay-button-border-radius:4px;--apple-pay-button-padding:4px 4px;--apple-pay-button-box-sizing:border-box;min-width:140px;max-width:100%;transition:background-color .3s ease-in-out;display:none}.payment-item apple-pay-button.enabled{display:block}.payment-item label{cursor:pointer}.payment-item .bancontact-method label,.payment-item .apple-pay-method label,.payment-item .american-express-method label{position:relative}.payment-item .bancontact-method label img,.payment-item .apple-pay-method label img,.payment-item .american-express-method label img{margin-left:.5em;position:absolute;top:-12px;left:100%}.payplug-payment-choice__container{flex-direction:column}.payplug-payment-choice__item{margin-bottom:1em}.payplug-payment-choice__header{justify-content:space-between;align-items:center;display:flex}.payplug-payment-choice__header .card-expiry span{font-weight:700}.oney-complete-info-popin{text-align:center;max-width:480px;z-index:4;top:50%;left:0;right:0;transform:translateY(-50%);margin:auto!important;position:fixed!important}.oney-complete-info-popin__header{text-align:right}.oney-complete-info-popin__header a.close>span{width:15px;height:2px;background-color:#0000000d;border-radius:0;margin:0;position:absolute;top:1em;right:.5em}.oney-complete-info-popin__header a.close>span:first-of-type{transform:rotate(45deg)}.oney-complete-info-popin__header a.close>span:last-of-type{transform:rotate(-45deg)}.oney-complete-info-popin__content{text-align:left}.oney-complete-info-popin__content ul{padding:0;list-style:none}.oney-complete-info-popin__content ul li{color:#fff;background-color:#db2828;border-color:#db2828;border-radius:.285714rem;margin:0 .142857em;padding:.5833em .833em;font-size:.857143rem;font-weight:700;display:inline-block}.oney-complete-info-popin__success{display:none}.oney-complete-info-popin__success i.icon{color:#21ba45;display:inline-block!important}.ui.container{position:relative}.inactive{pointer-events:none}.overlay{width:100%;height:100%;z-index:3;background:#00000040;display:block;position:absolute}@media screen and (max-width:991px){.oney-payment-choice__container,.payplug-payment-choice__container{display:block}.oney-payment-choice__content small,.payplug-payment-choice__content small{width:100%}.oney-payment-choice__tab{justify-content:space-between;display:flex}.oney-payment-choice__tab .tablink{text-align:center;border:1px solid #ccc;border-bottom:0;flex:1;padding:1rem 0}.oney-payment-choice__tab .tablink.active{border-bottom:5px solid #81bc00}.oney-payment-choice__tab .tablink p{color:#000}.oney-payment-choice__tab .tablink:first-of-type{border-right:0}.oney-payment-choice__tab .tablink>.oney-payment__image{max-width:120px}.oney-payment-choice__header,.oney-payment-choice__item{display:none}.oney-payment-choice__item input:checked+label{background-color:#fff;border-color:#ccc}.oney-payment-choice__item label{border-top-left-radius:0;border-top-right-radius:0}.oney-payment-choice__item--oney_x3_with_fees,.oney-payment-choice__item--oney_x3_without_fees{margin-bottom:1rem;margin-right:0;display:block}}@media screen and (max-width:480px){.payplug-payment-choice__header,.payplug-payment-choice__header .card-type,.payplug-payment-choice__header .card-expiry{display:block}} \ No newline at end of file From be079bdfd730d6d5107863ccc7a27029684d070b Mon Sep 17 00:00:00 2001 From: maxperei Date: Thu, 23 Feb 2023 11:19:52 +0100 Subject: [PATCH 02/12] fix: globalize flashbag link styles ina di admin payment method --- src/Resources/config/ui.yaml | 5 +++++ src/Resources/dev/admin/payment_method/index.scss | 8 ++++++++ src/Resources/dev/package.json | 2 ++ .../public/assets/admin/payment_method/index.css | 1 + src/Resources/translations/messages.en.yml | 3 ++- src/Resources/translations/messages.fr.yml | 3 ++- src/Resources/translations/messages.it.yml | 3 ++- src/Resources/translations/validators.en.yml | 8 ++++---- src/Resources/translations/validators.fr.yml | 4 ++-- src/Resources/translations/validators.it.yml | 6 +++--- .../views/stylesheets/payment_method_css.html.twig | 1 + 11 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 src/Resources/dev/admin/payment_method/index.scss create mode 100644 src/Resources/public/assets/admin/payment_method/index.css create mode 100644 src/Resources/views/stylesheets/payment_method_css.html.twig diff --git a/src/Resources/config/ui.yaml b/src/Resources/config/ui.yaml index 7596cba1..8bde6483 100644 --- a/src/Resources/config/ui.yaml +++ b/src/Resources/config/ui.yaml @@ -49,3 +49,8 @@ sylius_ui: priority: 5 context: event: sylius.shop.account.order.index.after_grid + sylius.admin.payment_method.create.stylesheets: &cssEvt + blocks: + payment_methods_css: + template: '@PayPlugSyliusPayPlugPlugin/stylesheets/payment_method_css.html.twig' + sylius.admin.payment_method.update.stylesheets: *cssEvt diff --git a/src/Resources/dev/admin/payment_method/index.scss b/src/Resources/dev/admin/payment_method/index.scss new file mode 100644 index 00000000..9f3cf3a1 --- /dev/null +++ b/src/Resources/dev/admin/payment_method/index.scss @@ -0,0 +1,8 @@ +.ui.label > a { + opacity: 1; + color: black; + + &:hover { + text-decoration: underline; + } +} \ No newline at end of file diff --git a/src/Resources/dev/package.json b/src/Resources/dev/package.json index 7703c78c..d2d1fef7 100644 --- a/src/Resources/dev/package.json +++ b/src/Resources/dev/package.json @@ -5,7 +5,9 @@ "source": "src/index.js", "scripts": { "build": "parcel build pages/**/* --dist-dir ../public/assets/oney --no-source-maps", + "build:admin": "parcel build admin/**/* --dist-dir ../public/assets/admin --no-source-maps", "dev": "parcel watch pages/**/* --dist-dir ../public/assets/oney --no-hmr", + "dev:admin": "parcel watch admin/**/* --dist-dir ../public/assets/admin --no-hmr", "eslint": "eslint -c .eslintrc ./", "fix-eslint": "eslint -c .eslintrc ./ --fix", "test": "echo \"Error: no test specified\" && exit 1" diff --git a/src/Resources/public/assets/admin/payment_method/index.css b/src/Resources/public/assets/admin/payment_method/index.css new file mode 100644 index 00000000..e3f88634 --- /dev/null +++ b/src/Resources/public/assets/admin/payment_method/index.css @@ -0,0 +1 @@ +.ui.label>a{opacity:1;color:#000}.ui.label>a:hover{text-decoration:underline} \ No newline at end of file diff --git a/src/Resources/translations/messages.en.yml b/src/Resources/translations/messages.en.yml index 267fb8e6..d816a39d 100644 --- a/src/Resources/translations/messages.en.yml +++ b/src/Resources/translations/messages.en.yml @@ -105,7 +105,8 @@ payplug_sylius_payplug_plugin: submit: Confirm and continue base_currency_not_euro: | Channel #channel_code#: #payment_method# is only available on channels with EURO as a currency - only_one_gateway_allowed: Please note that the %gateway_title% payment method has already been set. To change it, go to your payment methods. + only_one_gateway_allowed: | + Please note that the %gateway_title% payment method has already been set. To change it, go to your payment methods. one_click_enable: Enable One click one_click_help: | Allow your customers to save their credit card details for later diff --git a/src/Resources/translations/messages.fr.yml b/src/Resources/translations/messages.fr.yml index adb4f43e..a0e35e54 100644 --- a/src/Resources/translations/messages.fr.yml +++ b/src/Resources/translations/messages.fr.yml @@ -123,7 +123,8 @@ payplug_sylius_payplug_plugin: submit: Valider et continuer base_currency_not_euro: | Canal #channel_code# : #payment_method# n’est disponible que sur des canaux dont la devise est l’EURO - only_one_gateway_allowed: Attention, le moyen de paiement %gateway_title% existe déjà. Pour le modifier, rendez-vous sur vos moyens de paiement. + only_one_gateway_allowed: | + Attention, le moyen de paiement %gateway_title% existe déjà. Pour le modifier, rendez-vous sur vos moyens de paiement. one_click_enable: Activer le One click one_click_help: | Permettez à vos clients d'enregistrer leurs coordonnées de carte de paiement pour effectuer ultérieurement diff --git a/src/Resources/translations/messages.it.yml b/src/Resources/translations/messages.it.yml index b11445bf..e83d2456 100644 --- a/src/Resources/translations/messages.it.yml +++ b/src/Resources/translations/messages.it.yml @@ -105,7 +105,8 @@ payplug_sylius_payplug_plugin: submit: Convalida e continua base_currency_not_euro: | Il canale #channel_code# : #payment_method# è disponibile solo per i canali la cui valuta è in EURO - only_one_gateway_allowed: 'Attenzione: il metodo di pagamento %gateway_title% è già definito. Per modificarlo, vai ai tuoi metodi di pagamento.' + only_one_gateway_allowed: | + Attenzione: il metodo di pagamento %gateway_title% è già definito. Per modificarlo, vai ai tuoi metodi di pagamento. one_click_enable: Attiva un clic one_click_help: | Consenti ai tuoi clienti di salvare i dettagli della loro carta di credito per dopo diff --git a/src/Resources/translations/validators.en.yml b/src/Resources/translations/validators.en.yml index 24b1d8f9..86aa248c 100644 --- a/src/Resources/translations/validators.en.yml +++ b/src/Resources/translations/validators.en.yml @@ -10,7 +10,7 @@ payplug_sylius_payplug_plugin: one_click: can_not_save_cards: | You do not have access to this feature. For more information, - please contact us at: support@payplug.com + please contact us at: support@payplug.com bancontact: can_not_save_method_with_test_key: | The Bancontact payment method is not available for the TEST mode. @@ -18,7 +18,7 @@ payplug_sylius_payplug_plugin: can_not_save_method_no_access: | You don't have access to this feature yet. To activate Bancontact, please fill in - this form + this form and activate the LIVE mode. apple_pay: can_not_save_method_with_test_key: | @@ -26,7 +26,7 @@ payplug_sylius_payplug_plugin: can_not_save_method_no_access: | You don't have access to this feature yet. To activate Apple Pay, please fill in - this form + this form and activate the LIVE mode. american_express: can_not_save_method_with_test_key: | @@ -34,5 +34,5 @@ payplug_sylius_payplug_plugin: can_not_save_method_no_access: | You don't have access to this feature yet. To activate American Express, please fill in - this form + this form and activate the LIVE mode. diff --git a/src/Resources/translations/validators.fr.yml b/src/Resources/translations/validators.fr.yml index 7088c59e..a56c8b87 100644 --- a/src/Resources/translations/validators.fr.yml +++ b/src/Resources/translations/validators.fr.yml @@ -26,7 +26,7 @@ payplug_sylius_payplug_plugin: can_not_save_method_no_access: | Vous n'avez pas accès à cette fonctionnalité. Pour activer Apple Pay, rendez-vous sur - ce formulaire + ce formulaire et activez le mode LIVE. american_express: can_not_save_method_with_test_key: | @@ -34,5 +34,5 @@ payplug_sylius_payplug_plugin: can_not_save_method_no_access: | Vous n'avez pas accès à cette fonctionnalité. Pour activer American Express, rendez-vous sur - ce formulaire + ce formulaire et activez le mode LIVE. diff --git a/src/Resources/translations/validators.it.yml b/src/Resources/translations/validators.it.yml index f68b71a0..90eb31d8 100644 --- a/src/Resources/translations/validators.it.yml +++ b/src/Resources/translations/validators.it.yml @@ -18,7 +18,7 @@ payplug_sylius_payplug_plugin: can_not_save_method_no_access: | Non puoi ancora accedere a questa funzionalità. Per attivare Bancontact, compila - questo modulo + questo modulo e attiva la modalità LIVE. apple_pay: can_not_save_method_with_test_key: | @@ -26,7 +26,7 @@ payplug_sylius_payplug_plugin: can_not_save_method_no_access: | Non puoi ancora accedere a questa funzionalità. Per attivare Apple Pay, compila - questo modulo + questo modulo e attiva la modalità LIVE. american_express: can_not_save_method_with_test_key: | @@ -34,5 +34,5 @@ payplug_sylius_payplug_plugin: can_not_save_method_no_access: | Non puoi ancora accedere a questa funzionalità. Per attivare American Express, compila - questo modulo + questo modulo e attiva la modalità LIVE. diff --git a/src/Resources/views/stylesheets/payment_method_css.html.twig b/src/Resources/views/stylesheets/payment_method_css.html.twig new file mode 100644 index 00000000..a3a71c36 --- /dev/null +++ b/src/Resources/views/stylesheets/payment_method_css.html.twig @@ -0,0 +1 @@ +{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/admin/payment_method/index.css'} %} From 3443207a1d145cb10878075cd3bff4543ca31471 Mon Sep 17 00:00:00 2001 From: maxperei Date: Mon, 6 Mar 2023 11:39:36 +0100 Subject: [PATCH 03/12] refactor: blob assets and split properly because this is not only about `oney` payment method --- src/Resources/dev/package.json | 4 ++-- src/Resources/dev/{pages => shop}/account/index.scss | 0 src/Resources/dev/{pages/cart => shop/oney_cart}/index.js | 0 .../dev/{pages/common => shop/oney_common}/index.js | 0 .../dev/{pages/common => shop/oney_common}/index.scss | 2 +- src/Resources/dev/{pages/popin => shop/oney_popin}/index.js | 0 .../dev/{pages/popin => shop/oney_popin}/index.scss | 0 src/Resources/dev/{pages => shop}/payment/index.js | 0 src/Resources/dev/{pages => shop}/payment/index.scss | 0 src/Resources/public/assets/oney/common/index.css | 1 - .../public/assets/{oney => shop}/account/index.css | 0 .../public/assets/{oney/cart => shop/oney_cart}/index.js | 0 src/Resources/public/assets/shop/oney_common/index.css | 1 + .../assets/{oney/common => shop/oney_common}/index.js | 0 .../public/assets/{oney/popin => shop/oney_popin}/index.css | 0 .../public/assets/{oney/popin => shop/oney_popin}/index.js | 0 .../public/assets/{oney => shop}/payment/index.css | 0 src/Resources/public/assets/{oney => shop}/payment/index.js | 0 src/Resources/views/javascripts/oney_common.html.twig | 2 +- src/Resources/views/oney/cart/pay_with_oney.html.twig | 6 +++--- src/Resources/views/oney/product/pay_with_oney.html.twig | 4 ++-- src/Resources/views/stylesheets/oney_common.html.twig | 2 +- src/Resources/views/stylesheets/saved_cards.html.twig | 2 +- 23 files changed, 12 insertions(+), 12 deletions(-) rename src/Resources/dev/{pages => shop}/account/index.scss (100%) rename src/Resources/dev/{pages/cart => shop/oney_cart}/index.js (100%) rename src/Resources/dev/{pages/common => shop/oney_common}/index.js (100%) rename src/Resources/dev/{pages/common => shop/oney_common}/index.scss (93%) rename src/Resources/dev/{pages/popin => shop/oney_popin}/index.js (100%) rename src/Resources/dev/{pages/popin => shop/oney_popin}/index.scss (100%) rename src/Resources/dev/{pages => shop}/payment/index.js (100%) rename src/Resources/dev/{pages => shop}/payment/index.scss (100%) delete mode 100644 src/Resources/public/assets/oney/common/index.css rename src/Resources/public/assets/{oney => shop}/account/index.css (100%) rename src/Resources/public/assets/{oney/cart => shop/oney_cart}/index.js (100%) create mode 100644 src/Resources/public/assets/shop/oney_common/index.css rename src/Resources/public/assets/{oney/common => shop/oney_common}/index.js (100%) rename src/Resources/public/assets/{oney/popin => shop/oney_popin}/index.css (100%) rename src/Resources/public/assets/{oney/popin => shop/oney_popin}/index.js (100%) rename src/Resources/public/assets/{oney => shop}/payment/index.css (100%) rename src/Resources/public/assets/{oney => shop}/payment/index.js (100%) diff --git a/src/Resources/dev/package.json b/src/Resources/dev/package.json index 5cbf3467..de06b76a 100644 --- a/src/Resources/dev/package.json +++ b/src/Resources/dev/package.json @@ -4,9 +4,9 @@ "description": "Sylius Payplug Plugin", "source": "src/index.js", "scripts": { - "build": "parcel build pages/**/* --dist-dir ../public/assets/oney --no-source-maps", + "build": "parcel build shop/**/* --dist-dir ../public/assets/shop --no-source-maps", "build:admin": "parcel build admin/**/* --dist-dir ../public/assets/admin --no-source-maps", - "dev": "parcel watch pages/**/* --dist-dir ../public/assets/oney --no-hmr", + "dev": "parcel watch shop/**/* --dist-dir ../public/assets/shop --no-hmr", "dev:admin": "parcel watch admin/**/* --dist-dir ../public/assets/admin --no-hmr", "eslint": "eslint -c .eslintrc ./", "fix-eslint": "eslint -c .eslintrc ./ --fix", diff --git a/src/Resources/dev/pages/account/index.scss b/src/Resources/dev/shop/account/index.scss similarity index 100% rename from src/Resources/dev/pages/account/index.scss rename to src/Resources/dev/shop/account/index.scss diff --git a/src/Resources/dev/pages/cart/index.js b/src/Resources/dev/shop/oney_cart/index.js similarity index 100% rename from src/Resources/dev/pages/cart/index.js rename to src/Resources/dev/shop/oney_cart/index.js diff --git a/src/Resources/dev/pages/common/index.js b/src/Resources/dev/shop/oney_common/index.js similarity index 100% rename from src/Resources/dev/pages/common/index.js rename to src/Resources/dev/shop/oney_common/index.js diff --git a/src/Resources/dev/pages/common/index.scss b/src/Resources/dev/shop/oney_common/index.scss similarity index 93% rename from src/Resources/dev/pages/common/index.scss rename to src/Resources/dev/shop/oney_common/index.scss index 2b1d7226..c4dbc21e 100644 --- a/src/Resources/dev/pages/common/index.scss +++ b/src/Resources/dev/shop/oney_common/index.scss @@ -2,7 +2,7 @@ [class*=oney] * { font: { - family: Poppins, Arial, sans-serif; + family: Poppins, Arial, sans-serif !important; } line-height: 1.25; diff --git a/src/Resources/dev/pages/popin/index.js b/src/Resources/dev/shop/oney_popin/index.js similarity index 100% rename from src/Resources/dev/pages/popin/index.js rename to src/Resources/dev/shop/oney_popin/index.js diff --git a/src/Resources/dev/pages/popin/index.scss b/src/Resources/dev/shop/oney_popin/index.scss similarity index 100% rename from src/Resources/dev/pages/popin/index.scss rename to src/Resources/dev/shop/oney_popin/index.scss diff --git a/src/Resources/dev/pages/payment/index.js b/src/Resources/dev/shop/payment/index.js similarity index 100% rename from src/Resources/dev/pages/payment/index.js rename to src/Resources/dev/shop/payment/index.js diff --git a/src/Resources/dev/pages/payment/index.scss b/src/Resources/dev/shop/payment/index.scss similarity index 100% rename from src/Resources/dev/pages/payment/index.scss rename to src/Resources/dev/shop/payment/index.scss diff --git a/src/Resources/public/assets/oney/common/index.css b/src/Resources/public/assets/oney/common/index.css deleted file mode 100644 index 9330684b..00000000 --- a/src/Resources/public/assets/oney/common/index.css +++ /dev/null @@ -1 +0,0 @@ -[class*=oney] *{font-family:Poppins,Arial,sans-serif;line-height:1.25}[class*=oney] * p{color:#66727f;margin:0}[class*=oney] * small{font-size:90%}.oney-info{margin:1em auto .5em;display:inline-block;position:relative}.oney-info span{vertical-align:text-bottom;text-transform:uppercase;font-size:16px}.oney-info>img{cursor:pointer;vertical-align:middle;margin:0 4px}.oney-info.loading{pointer-events:none}.oney-logo[src*=without-fees]{max-width:190px}@media screen and (max-width:768px){.oney-logo{max-width:230px}} \ No newline at end of file diff --git a/src/Resources/public/assets/oney/account/index.css b/src/Resources/public/assets/shop/account/index.css similarity index 100% rename from src/Resources/public/assets/oney/account/index.css rename to src/Resources/public/assets/shop/account/index.css diff --git a/src/Resources/public/assets/oney/cart/index.js b/src/Resources/public/assets/shop/oney_cart/index.js similarity index 100% rename from src/Resources/public/assets/oney/cart/index.js rename to src/Resources/public/assets/shop/oney_cart/index.js diff --git a/src/Resources/public/assets/shop/oney_common/index.css b/src/Resources/public/assets/shop/oney_common/index.css new file mode 100644 index 00000000..84b84648 --- /dev/null +++ b/src/Resources/public/assets/shop/oney_common/index.css @@ -0,0 +1 @@ +[class*=oney] *{line-height:1.25;font-family:Poppins,Arial,sans-serif!important}[class*=oney] * p{color:#66727f;margin:0}[class*=oney] * small{font-size:90%}.oney-info{margin:1em auto .5em;display:inline-block;position:relative}.oney-info span{vertical-align:text-bottom;text-transform:uppercase;font-size:16px}.oney-info>img{cursor:pointer;vertical-align:middle;margin:0 4px}.oney-info.loading{pointer-events:none}.oney-logo[src*=without-fees]{max-width:190px}@media screen and (max-width:768px){.oney-logo{max-width:230px}} \ No newline at end of file diff --git a/src/Resources/public/assets/oney/common/index.js b/src/Resources/public/assets/shop/oney_common/index.js similarity index 100% rename from src/Resources/public/assets/oney/common/index.js rename to src/Resources/public/assets/shop/oney_common/index.js diff --git a/src/Resources/public/assets/oney/popin/index.css b/src/Resources/public/assets/shop/oney_popin/index.css similarity index 100% rename from src/Resources/public/assets/oney/popin/index.css rename to src/Resources/public/assets/shop/oney_popin/index.css diff --git a/src/Resources/public/assets/oney/popin/index.js b/src/Resources/public/assets/shop/oney_popin/index.js similarity index 100% rename from src/Resources/public/assets/oney/popin/index.js rename to src/Resources/public/assets/shop/oney_popin/index.js diff --git a/src/Resources/public/assets/oney/payment/index.css b/src/Resources/public/assets/shop/payment/index.css similarity index 100% rename from src/Resources/public/assets/oney/payment/index.css rename to src/Resources/public/assets/shop/payment/index.css diff --git a/src/Resources/public/assets/oney/payment/index.js b/src/Resources/public/assets/shop/payment/index.js similarity index 100% rename from src/Resources/public/assets/oney/payment/index.js rename to src/Resources/public/assets/shop/payment/index.js diff --git a/src/Resources/views/javascripts/oney_common.html.twig b/src/Resources/views/javascripts/oney_common.html.twig index d40a7e8e..6370e61a 100644 --- a/src/Resources/views/javascripts/oney_common.html.twig +++ b/src/Resources/views/javascripts/oney_common.html.twig @@ -1 +1 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/oney/common/index.js'} %} +{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/oney_common/index.js'} %} diff --git a/src/Resources/views/oney/cart/pay_with_oney.html.twig b/src/Resources/views/oney/cart/pay_with_oney.html.twig index e9dbc142..f22394dd 100644 --- a/src/Resources/views/oney/cart/pay_with_oney.html.twig +++ b/src/Resources/views/oney/cart/pay_with_oney.html.twig @@ -34,8 +34,8 @@ {% endfor %} {% endif %} - - + + - + {% endif %} diff --git a/src/Resources/views/oney/product/pay_with_oney.html.twig b/src/Resources/views/oney/product/pay_with_oney.html.twig index cc16e5b4..fc01aa50 100644 --- a/src/Resources/views/oney/product/pay_with_oney.html.twig +++ b/src/Resources/views/oney/product/pay_with_oney.html.twig @@ -23,8 +23,8 @@ data-popin-url="{{ path('payplug_sylius_oney_simulation_popin') }}"> - - + +
{% for variantCodes in sylius_product_variant_codes(product, sylius.channel) %}
diff --git a/src/Resources/views/stylesheets/oney_common.html.twig b/src/Resources/views/stylesheets/oney_common.html.twig index cee58d85..c55ea177 100644 --- a/src/Resources/views/stylesheets/oney_common.html.twig +++ b/src/Resources/views/stylesheets/oney_common.html.twig @@ -1 +1 @@ -{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/oney/common/index.css'} %} +{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/oney_common/index.css'} %} diff --git a/src/Resources/views/stylesheets/saved_cards.html.twig b/src/Resources/views/stylesheets/saved_cards.html.twig index c793b091..f027c015 100644 --- a/src/Resources/views/stylesheets/saved_cards.html.twig +++ b/src/Resources/views/stylesheets/saved_cards.html.twig @@ -1 +1 @@ -{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/oney/account/index.css'} %} \ No newline at end of file +{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/account/index.css'} %} \ No newline at end of file From 0fe6237720c4282c8d64c5dbe973ec0a96e0a8be Mon Sep 17 00:00:00 2001 From: maxperei Date: Mon, 6 Mar 2023 11:45:40 +0100 Subject: [PATCH 04/12] fix: sylius shop templates must not be overwritten in plugins prefer template-events instead this resolves payplug/SyliusPayplugPlugin#199 by reverting commit ef1b1cc2 partially --- src/Resources/config/ui.yaml | 6 ++++++ src/Resources/views/SyliusShopBundle/_scripts.html.twig | 3 --- src/Resources/views/SyliusShopBundle/_styles.html.twig | 2 -- src/Resources/views/javascripts/select_payment_js.html.twig | 1 + .../views/stylesheets/select_payment_css.html.twig | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 src/Resources/views/SyliusShopBundle/_scripts.html.twig delete mode 100644 src/Resources/views/SyliusShopBundle/_styles.html.twig create mode 100644 src/Resources/views/javascripts/select_payment_js.html.twig create mode 100644 src/Resources/views/stylesheets/select_payment_css.html.twig diff --git a/src/Resources/config/ui.yaml b/src/Resources/config/ui.yaml index 8bde6483..a781e1af 100644 --- a/src/Resources/config/ui.yaml +++ b/src/Resources/config/ui.yaml @@ -54,3 +54,9 @@ sylius_ui: payment_methods_css: template: '@PayPlugSyliusPayPlugPlugin/stylesheets/payment_method_css.html.twig' sylius.admin.payment_method.update.stylesheets: *cssEvt + sylius.shop.checkout.select_payment.before_form: + blocks: + select_payment_css: + template: '@PayPlugSyliusPayPlugPlugin/stylesheets/select_payment_css.html.twig' + select_payment_js: + template: '@PayPlugSyliusPayPlugPlugin/javascripts/select_payment_js.html.twig' \ No newline at end of file diff --git a/src/Resources/views/SyliusShopBundle/_scripts.html.twig b/src/Resources/views/SyliusShopBundle/_scripts.html.twig deleted file mode 100644 index db8d4a8d..00000000 --- a/src/Resources/views/SyliusShopBundle/_scripts.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'assets/shop/js/app.js'} %} -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/oney/payment/index.js'} %} - diff --git a/src/Resources/views/SyliusShopBundle/_styles.html.twig b/src/Resources/views/SyliusShopBundle/_styles.html.twig deleted file mode 100644 index 75c68235..00000000 --- a/src/Resources/views/SyliusShopBundle/_styles.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'assets/shop/css/style.css'} %} -{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/oney/payment/index.css'} %} diff --git a/src/Resources/views/javascripts/select_payment_js.html.twig b/src/Resources/views/javascripts/select_payment_js.html.twig new file mode 100644 index 00000000..84d44572 --- /dev/null +++ b/src/Resources/views/javascripts/select_payment_js.html.twig @@ -0,0 +1 @@ +{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/payment/index.js'} %} diff --git a/src/Resources/views/stylesheets/select_payment_css.html.twig b/src/Resources/views/stylesheets/select_payment_css.html.twig new file mode 100644 index 00000000..55cfa340 --- /dev/null +++ b/src/Resources/views/stylesheets/select_payment_css.html.twig @@ -0,0 +1 @@ +{% include '@SyliusUi/_stylesheets.html.twig' with {'path': 'bundles/payplugsyliuspayplugplugin/assets/shop/payment/index.css'} %} From f25656a56a8ab6162f56614a53b624827e669dbe Mon Sep 17 00:00:00 2001 From: Nicolas MELONI Date: Wed, 1 Mar 2023 11:08:43 +0100 Subject: [PATCH 05/12] fix SYL-207 - apple pay payment when using two tabs --- src/Controller/IpnAction.php | 5 + src/Controller/OrderController.php | 17 +++- src/Processor/OrderPaymentProcessor.php | 66 ------------- .../Payment/ApplePayPaymentProvider.php | 95 ++++++++++++++----- src/Resources/config/services.xml | 8 -- 5 files changed, 90 insertions(+), 101 deletions(-) delete mode 100644 src/Processor/OrderPaymentProcessor.php diff --git a/src/Controller/IpnAction.php b/src/Controller/IpnAction.php index 476f32c3..96476050 100644 --- a/src/Controller/IpnAction.php +++ b/src/Controller/IpnAction.php @@ -67,6 +67,11 @@ public function __invoke(Request $request): JsonResponse $content = json_decode($input, true); $details = ArrayObject::ensureArrayObject($content); + // if we are too fast canceling a payment before we got an answer from PayPlug gateway + if (null === $details['payment_id']) { + return new JsonResponse(null, Response::HTTP_UNAUTHORIZED); + } + $payment = $this->paymentRepository->findOneByPayPlugPaymentId($details['payment_id']); $paymentMethod = $payment->getMethod(); diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index f64070f3..51a1adff 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -24,7 +24,9 @@ use Sylius\Bundle\ResourceBundle\Controller\ViewHandlerInterface; use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent; use Sylius\Component\Core\Model\OrderInterface; +use Sylius\Component\Core\OrderCheckoutStates; use Sylius\Component\Core\OrderCheckoutTransitions; +use Sylius\Component\Core\OrderPaymentStates; use Sylius\Component\Payment\Model\PaymentInterface; use Sylius\Component\Resource\Exception\UpdateHandlingException; use Sylius\Component\Resource\Factory\FactoryInterface; @@ -36,6 +38,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\Lock\LockFactory; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Webmozart\Assert\Assert; final class OrderController extends BaseOrderController @@ -105,6 +108,10 @@ public function initiateApplePaySessionAction(Request $request): Response /** @var OrderInterface $resource */ $resource = $this->findOr404($configuration); + if (OrderPaymentStates::STATE_PAID === $resource->getPaymentState()) { + throw new AccessDeniedException(); + } + /** @var ResourceControllerEvent $event */ $event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::UPDATE, $configuration, $resource); @@ -173,7 +180,7 @@ public function initiateApplePaySessionAction(Request $request): Response ]); } - $this->addFlash('error', 'sylius.payment.cancelled'); + $request->getSession()->getFlashBag()->add('error', 'sylius.payment.cancelled'); $dataResponse = []; $redirect = $this->redirectToRoute('sylius_shop_checkout_select_payment'); $dataResponse['returnUrl'] = $redirect->getTargetUrl(); @@ -231,7 +238,7 @@ public function confirmApplePayPaymentAction(Request $request): Response ]); } - $this->addFlash('error', 'sylius.payment.cancelled'); + $request->getSession()->getFlashBag()->add('error', 'sylius.payment.cancelled'); $redirect = $this->redirectToRoute('sylius_shop_checkout_select_payment'); $dataResponse = []; $dataResponse['returnUrl'] = $redirect->getTargetUrl(); @@ -351,12 +358,12 @@ public function cancelApplePaySessionAction(Request $request): Response $this->manager->flush(); - $this->addFlash('error', 'sylius.payment.cancelled'); + $request->getSession()->getFlashBag()->add('error', 'sylius.payment.cancelled'); $dataResponse = []; $redirect = $this->redirectToRoute('sylius_shop_checkout_select_payment', ['_locale' => $resource->getLocaleCode()]); - if (OrderInterface::STATE_NEW === $resource->getState()) { + if (OrderCheckoutStates::STATE_COMPLETED === $resource->getCheckoutState()) { $redirect = $this->redirectToRoute('sylius_shop_order_show', [ 'tokenValue' => $resource->getTokenValue(), '_locale' => $resource->getLocaleCode(), @@ -391,7 +398,7 @@ public function cancelApplePaySessionAction(Request $request): Response 'trace' => $exception->getTraceAsString(), ]); - $this->addFlash('error', 'sylius.payment.cancelled'); + $request->getSession()->getFlashBag()->add('error', 'sylius.payment.cancelled'); $dataResponse = []; diff --git a/src/Processor/OrderPaymentProcessor.php b/src/Processor/OrderPaymentProcessor.php deleted file mode 100644 index cb85e045..00000000 --- a/src/Processor/OrderPaymentProcessor.php +++ /dev/null @@ -1,66 +0,0 @@ -baseOrderPaymentProcessor = $baseOrderPaymentProcessor; - $this->stateMachineFactory = $stateMachineFactory; - } - - public function process(OrderInterface $order): void - { - Assert::isInstanceOf($order, \Sylius\Component\Core\Model\OrderInterface::class); - - /** @var PaymentInterface|null $payment */ - $payment = $order->getLastPayment(PaymentInterface::STATE_NEW); - - if ( - null !== $payment && - PaymentInterface::STATE_COMPLETED === $payment->getDetails()['status'] && - ApplePayGatewayFactory::FACTORY_NAME === $this->getFactoryName($payment) - ) { - return; - } - - if ( - null !== $payment && - ApplePayGatewayFactory::FACTORY_NAME !== $this->getFactoryName($payment) - ) { - $stateMachine = $this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH); - $stateMachine->apply(PaymentTransitions::TRANSITION_CANCEL); - } - - $this->baseOrderPaymentProcessor->process($order); - } - - private function getFactoryName(PaymentInterface $payment): string - { - /** @var PaymentMethodInterface $paymentMethod */ - $paymentMethod = $payment->getMethod(); - /** @var GatewayConfigInterface $gatewayConfig */ - $gatewayConfig = $paymentMethod->getGatewayConfig(); - - return $gatewayConfig->getFactoryName(); - } -} diff --git a/src/Provider/Payment/ApplePayPaymentProvider.php b/src/Provider/Payment/ApplePayPaymentProvider.php index 9cf7e366..39b8d889 100644 --- a/src/Provider/Payment/ApplePayPaymentProvider.php +++ b/src/Provider/Payment/ApplePayPaymentProvider.php @@ -22,6 +22,10 @@ use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Core\Model\PaymentInterface; use Sylius\Component\Core\Model\PaymentMethodInterface; +use Sylius\Component\Core\OrderCheckoutStates; +use Sylius\Component\Core\OrderCheckoutTransitions; +use Sylius\Component\Core\OrderPaymentStates; +use Sylius\Component\Core\OrderPaymentTransitions; use Sylius\Component\Core\Payment\Exception\NotProvidedOrderPaymentException; use Sylius\Component\Core\TokenAssigner\OrderTokenAssignerInterface; use Sylius\Component\Payment\Factory\PaymentFactoryInterface; @@ -70,7 +74,15 @@ public function provide(Request $request, OrderInterface $order): PaymentInterfa throw new LogicException('Apple Pay is not enabled'); } - $payment = $this->initApplePaySyliusPaymentState($order, PaymentInterface::STATE_NEW); + $state = PaymentInterface::STATE_CART; + + if ($order->getPayments()->filter(function (PaymentInterface $payment): bool { + return PaymentInterface::STATE_FAILED === $payment->getState() || PaymentInterface::STATE_CANCELLED === $payment->getState(); + })->count() > 0) { + $state = PaymentInterface::STATE_NEW; + } + + $payment = $this->initApplePaySyliusPaymentState($order, $state); Assert::notNull($order->getBillingAddress()); if (null !== $customer = $order->getBillingAddress()->getCustomer()) { @@ -105,7 +117,10 @@ public function provide(Request $request, OrderInterface $order): PaymentInterfa $details['is_live'] = $paymentResource->is_live; $payment->setDetails($details); - $this->applyRequiredTransition($payment, PaymentInterface::STATE_NEW); + $this->applyRequiredPaymentTransition($payment, PaymentInterface::STATE_NEW); + $this->applyRequiredOrderPaymentTransition($order, OrderPaymentStates::STATE_AWAITING_PAYMENT); + $this->applyRequiredOrderCheckoutTransition($order, OrderCheckoutStates::STATE_COMPLETED); + $this->entityManager->flush(); return $payment; @@ -116,32 +131,34 @@ public function provide(Request $request, OrderInterface $order): PaymentInterfa */ private function initApplePaySyliusPaymentState(OrderInterface $order, string $targetState): PaymentInterface { - $order->getPayments()->clear(); - Assert::notNull($order->getCurrencyCode()); - /** @var PaymentInterface $payment */ - $payment = $this->paymentFactory->createWithAmountAndCurrencyCode($order->getTotal(), $order->getCurrencyCode()); - $paymentMethod = $this->paymentMethodRepository->findOneByGatewayName(ApplePayGatewayFactory::FACTORY_NAME); - $lastPayment = $this->getLastPayment($order); - - if (null !== $lastPayment) { - $paymentMethod = $lastPayment->getMethod(); - } - - if (null === $paymentMethod) { - throw new NotProvidedOrderPaymentException(); - } + $payment = $this->getPayment($order); + $paymentMethod = $this->paymentMethodRepository->findOneByGatewayName(ApplePayGatewayFactory::FACTORY_NAME); $payment->setMethod($paymentMethod); - $this->applyRequiredTransition($payment, $targetState); $order->addPayment($payment); $this->entityManager->flush(); return $payment; } - public function applyRequiredTransition(PaymentInterface $payment, string $targetState): void + private function getPayment(OrderInterface $order): PaymentInterface + { + $lastPayment = $order->getLastPayment(); + + if ($lastPayment instanceof PaymentInterface && PaymentInterface::STATE_CART === $lastPayment->getState()) { + return $lastPayment; + } + + if ($lastPayment instanceof PaymentInterface && OrderInterface::STATE_NEW === $order->getState() && PaymentInterface::STATE_NEW === $lastPayment->getState()) { + return $lastPayment; + } + + return $this->paymentFactory->createWithAmountAndCurrencyCode($order->getTotal(), $order->getCurrencyCode()); + } + + public function applyRequiredPaymentTransition(PaymentInterface $payment, string $targetState): void { if ($targetState === $payment->getState()) { return; @@ -158,6 +175,40 @@ public function applyRequiredTransition(PaymentInterface $payment, string $targe } } + public function applyRequiredOrderPaymentTransition(OrderInterface $order, string $targetState): void + { + if ($targetState === $order->getPaymentState()) { + return; + } + + /** @var StateMachineInterface $stateMachine */ + $stateMachine = $this->stateMachineFactory->get($order, OrderPaymentTransitions::GRAPH); + + /** @phpstan-ignore-next-line */ + $targetTransition = $stateMachine->getTransitionToState($targetState); + + if (null !== $targetTransition) { + $stateMachine->apply($targetTransition); + } + } + + public function applyRequiredOrderCheckoutTransition(OrderInterface $order, string $targetState): void + { + if ($targetState === $order->getPaymentState()) { + return; + } + + /** @var StateMachineInterface $stateMachine */ + $stateMachine = $this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH); + + /** @phpstan-ignore-next-line */ + $targetTransition = $stateMachine->getTransitionToState($targetState); + + if (null !== $targetTransition) { + $stateMachine->apply($targetTransition); + } + } + private function getLastPayment(OrderInterface $order): ?PaymentInterface { $lastCancelledPayment = $order->getLastPayment(PaymentInterface::STATE_CANCELLED); @@ -201,7 +252,7 @@ public function patch(Request $request, OrderInterface $order): PaymentInterface $details = $lastPayment->getDetails(); if (!$response->is_paid) { - $this->applyRequiredTransition($lastPayment, PaymentInterface::STATE_FAILED); + $this->applyRequiredPaymentTransition($lastPayment, PaymentInterface::STATE_FAILED); throw new PaymentNotCompletedException(); } @@ -216,7 +267,7 @@ public function patch(Request $request, OrderInterface $order): PaymentInterface $this->entityManager->flush(); - $this->applyRequiredTransition($lastPayment, PaymentInterface::STATE_COMPLETED); + $this->applyRequiredPaymentTransition($lastPayment, PaymentInterface::STATE_COMPLETED); if ($this->isResourceIsAuthorized($response)) { $details['status'] = PayPlugApiClientInterface::STATUS_AUTHORIZED; @@ -227,7 +278,7 @@ public function patch(Request $request, OrderInterface $order): PaymentInterface return $lastPayment; } catch (\Exception $exception) { $paymentResource->abort(); - $this->applyRequiredTransition($lastPayment, PaymentInterface::STATE_FAILED); + $this->applyRequiredPaymentTransition($lastPayment, PaymentInterface::STATE_FAILED); throw new PaymentNotCompletedException(); } @@ -275,7 +326,7 @@ public function cancel(OrderInterface $order): void throw new LogicException(); } - $this->applyRequiredTransition($lastPayment, PaymentInterface::STATE_CANCELLED); + $this->applyRequiredPaymentTransition($lastPayment, PaymentInterface::STATE_CANCELLED); $this->entityManager->flush(); } } diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 851e15e4..e61eaef6 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -37,14 +37,6 @@ - - - - - From d62467b9eb61bc8725d2a7b9dc6fe3f6c26e8241 Mon Sep 17 00:00:00 2001 From: Nicolas MELONI Date: Thu, 2 Mar 2023 09:08:07 +0100 Subject: [PATCH 06/12] remove invalid values from payment details when changing payment method --- .github/workflows/ci.yaml | 0 .../config/packages/config_test.yml | 4 ++ spec/Action/CaptureActionSpec.php | 8 ++- src/Action/CaptureAction.php | 24 +++++-- src/Processor/OrderPaymentProcessor.php | 66 +++++++++++++++++++ .../Payment/ApplePayPaymentProvider.php | 10 ++- src/Resources/config/services.xml | 8 +++ 7 files changed, 111 insertions(+), 9 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 install/Application/config/packages/config_test.yml create mode 100644 src/Processor/OrderPaymentProcessor.php diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index e69de29b..00000000 diff --git a/install/Application/config/packages/config_test.yml b/install/Application/config/packages/config_test.yml new file mode 100644 index 00000000..ccaea7bd --- /dev/null +++ b/install/Application/config/packages/config_test.yml @@ -0,0 +1,4 @@ +doctrine: + dbal: + options: + 1002: 'SET SESSION wait_timeout=300' diff --git a/spec/Action/CaptureActionSpec.php b/spec/Action/CaptureActionSpec.php index c2679fc3..02a7ad36 100644 --- a/spec/Action/CaptureActionSpec.php +++ b/spec/Action/CaptureActionSpec.php @@ -33,8 +33,7 @@ public function let( AbortPaymentProcessor $abortPaymentProcessor, RequestStack $requestStack, RepositoryInterface $payplugCardRepository - ): void - { + ): void { $this->beConstructedWith($logger, $translator, $abortPaymentProcessor, $requestStack, $payplugCardRepository); } @@ -108,6 +107,11 @@ public function it_executes( $arrayObject->offsetSet('is_live', true)->shouldBeCalled(); $arrayObject->offsetSet('status', PayPlugApiClientInterface::STATUS_CREATED)->shouldBeCalled(); + // Apple Pay cleanup + $arrayObject->offsetGet('payment_method')->shouldBeCalled(); + $arrayObject->offsetUnset('payment_context')->shouldBeCalled(); + $arrayObject->offsetUnset('merchant_session')->shouldBeCalled(); + $this ->shouldThrow(HttpRedirect::class) ->during('execute', [$request]) diff --git a/src/Action/CaptureAction.php b/src/Action/CaptureAction.php index 080c21b7..b9a8b169 100644 --- a/src/Action/CaptureAction.php +++ b/src/Action/CaptureAction.php @@ -12,6 +12,7 @@ use PayPlug\SyliusPayPlugPlugin\ApiClient\PayPlugApiClientInterface; use PayPlug\SyliusPayPlugPlugin\Entity\Card; use PayPlug\SyliusPayPlugPlugin\Exception\UnknownApiErrorException; +use PayPlug\SyliusPayPlugPlugin\Gateway\ApplePayGatewayFactory; use PayPlug\SyliusPayPlugPlugin\Gateway\PayPlugGatewayFactory; use PayPlug\SyliusPayPlugPlugin\PaymentProcessing\AbortPaymentProcessor; use Payum\Core\Action\ActionInterface; @@ -79,8 +80,19 @@ public function execute($request): void Assert::isInstanceOf($this->tokenFactory, GenericTokenFactoryInterface::class); RequestNotSupportedException::assertSupports($this, $request); + $paymentModel = $request->getFirstModel(); + Assert::isInstanceOf($paymentModel, PaymentInterface::class); + $details = ArrayObject::ensureArrayObject($request->getModel()); + if (isset($details['payment_method']) && + ApplePayGatewayFactory::PAYMENT_METHOD_APPLE_PAY === $details['payment_method']) { + $this->abortPaymentProcessor->process($paymentModel); + $details['status'] = PayPlugApiClientInterface::STATUS_CANCELED; + + return; + } + if (isset($details['status']) && PayPlugApiClientInterface::FAILED === $details['status']) { // Unset current status to allow to use payplug to change payment method unset($details['status']); @@ -93,12 +105,9 @@ public function execute($request): void return; } - $paymentModel = $request->getFirstModel(); - Assert::isInstanceOf($paymentModel, PaymentInterface::class); - - /** @var Capture $request */ + /* @var Capture $request */ if (array_key_exists('status', $paymentModel->getDetails()) - && $paymentModel->getDetails()['status'] === PayPlugApiClientInterface::STATUS_CAPTURED) { + && PayPlugApiClientInterface::STATUS_CAPTURED === $paymentModel->getDetails()['status']) { return; } @@ -118,6 +127,11 @@ public function execute($request): void unset($details['status']); } + if (ApplePayGatewayFactory::PAYMENT_METHOD_APPLE_PAY !== $details['payment_method']) { + // clean other detail values + unset($details['payment_context'], $details['merchant_session']); + } + try { // gateway payplug case: open many browsers and pay by save card in any of these browsers $cardId = $this->requestStack->getSession()->get('payplug_payment_method'); diff --git a/src/Processor/OrderPaymentProcessor.php b/src/Processor/OrderPaymentProcessor.php new file mode 100644 index 00000000..cb85e045 --- /dev/null +++ b/src/Processor/OrderPaymentProcessor.php @@ -0,0 +1,66 @@ +baseOrderPaymentProcessor = $baseOrderPaymentProcessor; + $this->stateMachineFactory = $stateMachineFactory; + } + + public function process(OrderInterface $order): void + { + Assert::isInstanceOf($order, \Sylius\Component\Core\Model\OrderInterface::class); + + /** @var PaymentInterface|null $payment */ + $payment = $order->getLastPayment(PaymentInterface::STATE_NEW); + + if ( + null !== $payment && + PaymentInterface::STATE_COMPLETED === $payment->getDetails()['status'] && + ApplePayGatewayFactory::FACTORY_NAME === $this->getFactoryName($payment) + ) { + return; + } + + if ( + null !== $payment && + ApplePayGatewayFactory::FACTORY_NAME !== $this->getFactoryName($payment) + ) { + $stateMachine = $this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH); + $stateMachine->apply(PaymentTransitions::TRANSITION_CANCEL); + } + + $this->baseOrderPaymentProcessor->process($order); + } + + private function getFactoryName(PaymentInterface $payment): string + { + /** @var PaymentMethodInterface $paymentMethod */ + $paymentMethod = $payment->getMethod(); + /** @var GatewayConfigInterface $gatewayConfig */ + $gatewayConfig = $paymentMethod->getGatewayConfig(); + + return $gatewayConfig->getFactoryName(); + } +} diff --git a/src/Provider/Payment/ApplePayPaymentProvider.php b/src/Provider/Payment/ApplePayPaymentProvider.php index 39b8d889..e16a5040 100644 --- a/src/Provider/Payment/ApplePayPaymentProvider.php +++ b/src/Provider/Payment/ApplePayPaymentProvider.php @@ -76,6 +76,7 @@ public function provide(Request $request, OrderInterface $order): PaymentInterfa $state = PaymentInterface::STATE_CART; + /** @phpstan-ignore-next-line */ if ($order->getPayments()->filter(function (PaymentInterface $payment): bool { return PaymentInterface::STATE_FAILED === $payment->getState() || PaymentInterface::STATE_CANCELLED === $payment->getState(); })->count() > 0) { @@ -147,14 +148,19 @@ private function getPayment(OrderInterface $order): PaymentInterface { $lastPayment = $order->getLastPayment(); - if ($lastPayment instanceof PaymentInterface && PaymentInterface::STATE_CART === $lastPayment->getState()) { + if ($lastPayment instanceof PaymentInterface && + PaymentInterface::STATE_CART === $lastPayment->getState()) { return $lastPayment; } - if ($lastPayment instanceof PaymentInterface && OrderInterface::STATE_NEW === $order->getState() && PaymentInterface::STATE_NEW === $lastPayment->getState()) { + if ($lastPayment instanceof PaymentInterface && OrderInterface::STATE_NEW === $order->getState() && + PaymentInterface::STATE_NEW === $lastPayment->getState()) { return $lastPayment; } + Assert::string($order->getCurrencyCode()); + + /** @phpstan-ignore-next-line */ return $this->paymentFactory->createWithAmountAndCurrencyCode($order->getTotal(), $order->getCurrencyCode()); } diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index e61eaef6..851e15e4 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -37,6 +37,14 @@ + + + + + From dbd59c277f04ead9f36bfcf5793e74a45f7058cc Mon Sep 17 00:00:00 2001 From: Nicolas MELONI Date: Mon, 6 Mar 2023 16:18:28 +0100 Subject: [PATCH 07/12] fix tests --- .../config/packages/config_test.yml | 4 - spec/Action/CaptureActionSpec.php | 128 ------------------ src/Action/CaptureAction.php | 12 +- .../Behat/Context/Ui/Shop/CheckoutContext.php | 16 ++- tests/Behat/Mocker/PayPlugApiMocker.php | 27 +++- 5 files changed, 45 insertions(+), 142 deletions(-) delete mode 100644 install/Application/config/packages/config_test.yml delete mode 100644 spec/Action/CaptureActionSpec.php diff --git a/install/Application/config/packages/config_test.yml b/install/Application/config/packages/config_test.yml deleted file mode 100644 index ccaea7bd..00000000 --- a/install/Application/config/packages/config_test.yml +++ /dev/null @@ -1,4 +0,0 @@ -doctrine: - dbal: - options: - 1002: 'SET SESSION wait_timeout=300' diff --git a/spec/Action/CaptureActionSpec.php b/spec/Action/CaptureActionSpec.php deleted file mode 100644 index 02a7ad36..00000000 --- a/spec/Action/CaptureActionSpec.php +++ /dev/null @@ -1,128 +0,0 @@ -beConstructedWith($logger, $translator, $abortPaymentProcessor, $requestStack, $payplugCardRepository); - } - - public function it_is_initializable(): void - { - $this->shouldHaveType(CaptureAction::class); - } - - public function it_implements_action_interface(): void - { - $this->shouldHaveType(ActionInterface::class); - } - - public function it_implements_api_aware_interface(): void - { - $this->shouldHaveType(ApiAwareInterface::class); - } - - public function it_implements_gateway_aware_interface(): void - { - $this->shouldHaveType(GatewayAwareInterface::class); - } - - public function it_executes( - Capture $request, - ArrayObject $arrayObject, - TokenInterface $token, - GatewayInterface $gateway, - PayPlugApiClientInterface $payPlugApiClient, - GenericTokenFactory $genericTokenFactory, - TokenInterface $notifyToken, - PaymentInterface $payment, - RequestStack $requestStack - ): void { - $requestStack->getSession()->willReturn(new Session()); - $payplugPayment = \Mockery::mock('payment', Payment::class); - - $payplugPayment->id = 1; - $payplugPayment->is_live = true; - $payplugPayment->hosted_payment = (object) [ - 'payment_url' => 'test', - ]; - - $this->setGateway($gateway); - $this->setApi($payPlugApiClient); - $this->setGenericTokenFactory($genericTokenFactory); - - $arrayObject->getArrayCopy()->willReturn([]); - $request->getModel()->willReturn($arrayObject); - - $request->getFirstModel()->willReturn($payment); - $payment->getDetails()->willReturn(['status' => PayPlugApiClientInterface::STATUS_CREATED]); - - $request->getToken()->willReturn($token); - $token->getTargetUrl()->willReturn('url'); - $token->getAfterUrl()->willReturn('url'); - $token->getGatewayName()->willReturn('test'); - $token->getDetails()->willReturn([]); - $genericTokenFactory->createNotifyToken('test', [])->willReturn($notifyToken); - $notifyToken->getTargetUrl()->willReturn('url'); - $notifyToken->getHash()->willReturn('test'); - $payPlugApiClient->createPayment([])->willReturn($payplugPayment); - $arrayObject->offsetGet('order_number')->willReturn('000001'); - $arrayObject->offsetGet('initiator')->shouldBeCalled(); - - $arrayObject->offsetExists('payment_id')->shouldBeCalled(); - $arrayObject->offsetExists('status')->shouldBeCalled(); - $arrayObject->offsetSet('hosted_payment', ['return_url' => 'url', 'cancel_url' => 'url?&status=canceled'])->shouldBeCalled(); - $arrayObject->offsetSet('notification_url', 'url')->shouldBeCalled(); - $arrayObject->offsetSet('payment_id', 1)->shouldBeCalled(); - $arrayObject->offsetSet('is_live', true)->shouldBeCalled(); - $arrayObject->offsetSet('status', PayPlugApiClientInterface::STATUS_CREATED)->shouldBeCalled(); - - // Apple Pay cleanup - $arrayObject->offsetGet('payment_method')->shouldBeCalled(); - $arrayObject->offsetUnset('payment_context')->shouldBeCalled(); - $arrayObject->offsetUnset('merchant_session')->shouldBeCalled(); - - $this - ->shouldThrow(HttpRedirect::class) - ->during('execute', [$request]) - ; - } - - public function it_supports_only_capture_request_and_array_access( - Capture $request, - \ArrayAccess $arrayAccess - ): void { - $request->getModel()->willReturn($arrayAccess); - $this->supports($request)->shouldReturn(true); - } -} diff --git a/src/Action/CaptureAction.php b/src/Action/CaptureAction.php index b9a8b169..9a30269c 100644 --- a/src/Action/CaptureAction.php +++ b/src/Action/CaptureAction.php @@ -129,7 +129,13 @@ public function execute($request): void if (ApplePayGatewayFactory::PAYMENT_METHOD_APPLE_PAY !== $details['payment_method']) { // clean other detail values - unset($details['payment_context'], $details['merchant_session']); + if ($details->offsetExists('payment_context')) { + unset($details['payment_context']); + } + + if ($details->offsetExists('merchant_session')) { + unset($details['merchant_session']); + } } try { @@ -247,7 +253,9 @@ private function createPayment(ArrayObject $details, PaymentInterface $paymentMo { try { if ($details->offsetExists('payment_id') - && $details->offsetExists('status')) { + && $details->offsetExists('status') + && $details->offsetExists('is_live') + ) { $this->abortPaymentProcessor->process($paymentModel); unset($details['status'], $details['payment_id'], $details['is_live']); // the parameter allow_save_card must be false when payment_method parameter is provided diff --git a/tests/Behat/Context/Ui/Shop/CheckoutContext.php b/tests/Behat/Context/Ui/Shop/CheckoutContext.php index f10c5c2f..20ea7e36 100644 --- a/tests/Behat/Context/Ui/Shop/CheckoutContext.php +++ b/tests/Behat/Context/Ui/Shop/CheckoutContext.php @@ -57,10 +57,12 @@ public function iConfirmMyOrderWithPayPlugPayment(): void */ public function iSignInToPayPlugAndPaySuccessfully(): void { - $this->payPlugApiMocker->mockPayPlugApiGetGatewayFactoryName(function () { - $this->payPlugApiMocker->mockApiSuccessfulPayment(function () { - $this->paymentPage->notify(['id' => 1]); - $this->paymentPage->capture(); + $this->payPlugApiMocker->mockMultipleApiCancelledPayment(function () { + $this->payPlugApiMocker->mockPayPlugApiGetGatewayFactoryName(function () { + $this->payPlugApiMocker->mockApiSuccessfulPayment(function () { + $this->paymentPage->notify(['id' => 1]); + $this->paymentPage->capture(); + }); }); }); } @@ -70,7 +72,7 @@ public function iSignInToPayPlugAndPaySuccessfully(): void */ public function iHaveFailedPayPlugPayment() { - $this->payPlugApiMocker->mockApiCancelledPayment(function () { + $this->payPlugApiMocker->mockMultipleApiCancelledPayment(function () { $this->payPlugApiMocker->mockApiFailedPayment(function () { $this->paymentPage->notify(['id' => 1]); $this->paymentPage->capture(); @@ -84,7 +86,7 @@ public function iHaveFailedPayPlugPayment() */ public function iCancelMyPayPlugPayment(): void { - $this->payPlugApiMocker->mockApiCancelledPayment(function () { + $this->payPlugApiMocker->mockMultipleApiCancelledPayment(function () { $this->paymentPage->capture(['status' => PayPlugApiClientInterface::STATUS_CANCELED]); }); } @@ -115,7 +117,7 @@ public function PayPlugExpiredThePayment(): void */ public function iTryToPayAgainPayPlugPayment(): void { - $this->payPlugApiMocker->mockApiCancelledPayment(function () { + $this->payPlugApiMocker->mockMultipleApiCancelledPayment(function () { $this->payPlugApiMocker->mockPayPlugApiGetGatewayFactoryName(function () { $this->payPlugApiMocker->mockApiCreatePayment(function () { $this->orderDetails->pay(); diff --git a/tests/Behat/Mocker/PayPlugApiMocker.php b/tests/Behat/Mocker/PayPlugApiMocker.php index f79a569e..5911e536 100644 --- a/tests/Behat/Mocker/PayPlugApiMocker.php +++ b/tests/Behat/Mocker/PayPlugApiMocker.php @@ -157,6 +157,7 @@ public function mockApiFailedPayment(callable $action): void ->shouldReceive('initialise') ; $payment = \Mockery::mock('payment', Payment::class); + $payment->id = 'pay_1'; $payment->is_paid = false; $mock ->shouldReceive('treat') @@ -173,6 +174,7 @@ public function mockApiExpiredPayment(callable $action): void ->shouldReceive('initialise') ; $payment = \Mockery::mock('payment', Payment::class); + $payment->id = 'pay_1'; $payment->status = 'failure'; $payment->is_paid = false; $failure = new \stdClass(); @@ -213,12 +215,35 @@ public function mockApiCancelledPayment(callable $action): void ; $payment = \Mockery::mock('payment', Payment::class); + $payment->id = 'pay_1'; $payment->state = 'abort'; $payment->is_paid = false; $mock ->shouldReceive('abortPayment')->once() - ->withArgs(['123456']) + ->withArgs(['pay_1']) + ->andReturn($payment) + ; + + $action(); + $this->mocker->unmockAll(); + } + + public function mockMultipleApiCancelledPayment(callable $action): void + { + $mock = $this->mocker->mockService('payplug_sylius_payplug_plugin.api_client.payplug', PayPlugApiClientInterface::class); + $mock + ->shouldReceive('initialise') + ; + + $payment = \Mockery::mock('payment', Payment::class); + $payment->id = 'pay_1'; + $payment->state = 'abort'; + $payment->is_paid = false; + + $mock + ->shouldReceive('abortPayment') + ->withArgs(['pay_1']) ->andReturn($payment) ; From 9ad01a8f02b0460004f9997ba4711dcfaba0ac5f Mon Sep 17 00:00:00 2001 From: Nicolas MELONI Date: Wed, 29 Mar 2023 12:02:00 +0200 Subject: [PATCH 08/12] add missing asset event --- src/Resources/config/ui.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Resources/config/ui.yaml b/src/Resources/config/ui.yaml index a781e1af..d50e2e08 100644 --- a/src/Resources/config/ui.yaml +++ b/src/Resources/config/ui.yaml @@ -17,10 +17,14 @@ sylius_ui: template: '@PayPlugSyliusPayPlugPlugin/javascripts/webfont_loader.html.twig' oney_common: template: '@PayPlugSyliusPayPlugPlugin/javascripts/oney_common.html.twig' + select_payment_js: + template: '@PayPlugSyliusPayPlugPlugin/javascripts/select_payment_js.html.twig' sylius.shop.layout.stylesheets: blocks: oney_common: template: '@PayPlugSyliusPayPlugPlugin/stylesheets/oney_common.html.twig' + select_payment_css: + template: '@PayPlugSyliusPayPlugPlugin/stylesheets/select_payment_css.html.twig' sylius.shop.account.saved_cards.index.header.content: blocks: legacy: @@ -59,4 +63,4 @@ sylius_ui: select_payment_css: template: '@PayPlugSyliusPayPlugPlugin/stylesheets/select_payment_css.html.twig' select_payment_js: - template: '@PayPlugSyliusPayPlugPlugin/javascripts/select_payment_js.html.twig' \ No newline at end of file + template: '@PayPlugSyliusPayPlugPlugin/javascripts/select_payment_js.html.twig' From 543945c62f4d0a3882db78a34b843e949c6931c7 Mon Sep 17 00:00:00 2001 From: Nicolas MELONI Date: Fri, 31 Mar 2023 16:23:49 +0200 Subject: [PATCH 09/12] SYL-213 - double js event --- src/Resources/config/ui.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Resources/config/ui.yaml b/src/Resources/config/ui.yaml index d50e2e08..1b8b9db7 100644 --- a/src/Resources/config/ui.yaml +++ b/src/Resources/config/ui.yaml @@ -58,9 +58,3 @@ sylius_ui: payment_methods_css: template: '@PayPlugSyliusPayPlugPlugin/stylesheets/payment_method_css.html.twig' sylius.admin.payment_method.update.stylesheets: *cssEvt - sylius.shop.checkout.select_payment.before_form: - blocks: - select_payment_css: - template: '@PayPlugSyliusPayPlugPlugin/stylesheets/select_payment_css.html.twig' - select_payment_js: - template: '@PayPlugSyliusPayPlugPlugin/javascripts/select_payment_js.html.twig' From e3b0c597977fdd418575ed61f57783198dd59001 Mon Sep 17 00:00:00 2001 From: Nicolas MELONI Date: Wed, 12 Apr 2023 09:51:16 +0200 Subject: [PATCH 10/12] SYL-214 - fix cannot pay using oney --- src/Action/CaptureAction.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Action/CaptureAction.php b/src/Action/CaptureAction.php index 9a30269c..3179190d 100644 --- a/src/Action/CaptureAction.php +++ b/src/Action/CaptureAction.php @@ -13,6 +13,7 @@ use PayPlug\SyliusPayPlugPlugin\Entity\Card; use PayPlug\SyliusPayPlugPlugin\Exception\UnknownApiErrorException; use PayPlug\SyliusPayPlugPlugin\Gateway\ApplePayGatewayFactory; +use PayPlug\SyliusPayPlugPlugin\Gateway\OneyGatewayFactory; use PayPlug\SyliusPayPlugPlugin\Gateway\PayPlugGatewayFactory; use PayPlug\SyliusPayPlugPlugin\PaymentProcessing\AbortPaymentProcessor; use Payum\Core\Action\ActionInterface; @@ -127,7 +128,14 @@ public function execute($request): void unset($details['status']); } - if (ApplePayGatewayFactory::PAYMENT_METHOD_APPLE_PAY !== $details['payment_method']) { + if (!in_array( + $details['payment_method'], + array_merge( + [ApplePayGatewayFactory::PAYMENT_METHOD_APPLE_PAY], + OneyGatewayFactory::PAYMENT_CHOICES + ), + true + )) { // clean other detail values if ($details->offsetExists('payment_context')) { unset($details['payment_context']); From 2e98179472f95698d9bc7f68e5e99516eb451b28 Mon Sep 17 00:00:00 2001 From: maxperei Date: Wed, 19 Apr 2023 16:12:09 +0200 Subject: [PATCH 11/12] fix: resize apple pay logo to match w/ other payment method --- src/Resources/public/assets/apple-pay/logo.svg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Resources/public/assets/apple-pay/logo.svg b/src/Resources/public/assets/apple-pay/logo.svg index ca4777cd..1240e7d4 100644 --- a/src/Resources/public/assets/apple-pay/logo.svg +++ b/src/Resources/public/assets/apple-pay/logo.svg @@ -1 +1,5 @@ - + + + + + \ No newline at end of file From d0ef7bb9a02374cf442d91ac724a88ecad6af810 Mon Sep 17 00:00:00 2001 From: Edouard Lacan Date: Thu, 27 Apr 2023 17:17:45 +0200 Subject: [PATCH 12/12] udpate version to 1.9.1 --- src/PayPlugSyliusPayPlugPlugin.php | 2 +- src/Resources/dev/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PayPlugSyliusPayPlugPlugin.php b/src/PayPlugSyliusPayPlugPlugin.php index 4d46f939..a2a8a400 100644 --- a/src/PayPlugSyliusPayPlugPlugin.php +++ b/src/PayPlugSyliusPayPlugPlugin.php @@ -9,7 +9,7 @@ final class PayPlugSyliusPayPlugPlugin extends Bundle { - public const VERSION = '1.9.0'; + public const VERSION = '1.9.1'; use SyliusPluginTrait; } diff --git a/src/Resources/dev/package.json b/src/Resources/dev/package.json index de06b76a..2f92e08e 100644 --- a/src/Resources/dev/package.json +++ b/src/Resources/dev/package.json @@ -1,6 +1,6 @@ { "name": "sylius-payplug-plugin", - "version": "1.9.0", + "version": "1.9.1", "description": "Sylius Payplug Plugin", "source": "src/index.js", "scripts": {