From 424b124c76422e21f5635498d0ee3f54006b94f3 Mon Sep 17 00:00:00 2001 From: Michael Telgmann Date: Thu, 27 Sep 2018 15:21:21 +0200 Subject: [PATCH] PT-9604 - Use correct payment for PayPal Plus if shipping or payment is changed on shippingPayment page --- ...jquery.swag-paypal-unified.payment-wall.js | 19 +++++++++++-- .../frontend/checkout/change_payment.tpl | 11 -------- .../frontend/checkout/shipping_payment.tpl | 26 ----------------- .../checkout/shipping_payment_core.tpl | 28 +++++++++++++++++++ .../payment_wall_shipping_payment.tpl | 1 - 5 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 Resources/views/frontend/checkout/shipping_payment_core.tpl diff --git a/Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.payment-wall.js b/Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.payment-wall.js index 89699d29..964ad4b9 100644 --- a/Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.payment-wall.js +++ b/Resources/views/frontend/_public/src/js/jquery.swag-paypal-unified.payment-wall.js @@ -135,7 +135,14 @@ * * @type Array */ - thirdPartyPaymentMethods: [] + thirdPartyPaymentMethods: [], + + /** + * div element which contains the approval URL + * + * @type string + */ + paypalApprovalUrlSelector: '.paypal-unified--plus-approval-url' }, /** @@ -182,7 +189,13 @@ * @param {String} parent */ createPaymentWall: function(parent) { - var me = this; + var me = this, + approvalUrl = $(me.opts.paypalApprovalUrlSelector).text(); + + // PaymentWall on Confirm page + if (approvalUrl === '') { + approvalUrl = me.opts.paypalApprovalUrl; + } me.loaded = false; me.placeholder = parent; @@ -192,7 +205,7 @@ $.publish('plugin/swagPayPalUnifiedPaymentWall/beforeCreate', me); me.paymentWall = PAYPAL.apps.PPP({ - approvalUrl: me.opts.paypalApprovalUrl, + approvalUrl: approvalUrl, placeholder: parent, country: me.opts.paypalCountryIso, mode: me.opts.paypalMode, diff --git a/Resources/views/frontend/checkout/change_payment.tpl b/Resources/views/frontend/checkout/change_payment.tpl index 9a314eca..5de20cb4 100644 --- a/Resources/views/frontend/checkout/change_payment.tpl +++ b/Resources/views/frontend/checkout/change_payment.tpl @@ -1,16 +1,5 @@ {extends file='parent:frontend/checkout/change_payment.tpl'} -{* PayPal Plus integration *} -{block name='frontend_index_header_javascript_jquery_lib'} - {block name='frontend_index_header_javascript_jquery_lib_paypal_unified_plus'} - {if $paypalUnifiedUsePlus && $paypalUnifiedApprovalUrl} - - {/if} - {/block} - - {$smarty.block.parent} -{/block} - {* PayPal Plus integration *} {block name='frontend_checkout_payment_fieldset_description'} {block name='frontend_checkout_payment_fieldset_description_paypal_unified_plus'} diff --git a/Resources/views/frontend/checkout/shipping_payment.tpl b/Resources/views/frontend/checkout/shipping_payment.tpl index 06bb1758..8f5a31bc 100644 --- a/Resources/views/frontend/checkout/shipping_payment.tpl +++ b/Resources/views/frontend/checkout/shipping_payment.tpl @@ -26,29 +26,3 @@ {$smarty.block.parent} {/block} - -{* PayPal Plus integration *} -{block name='frontend_checkout_payment_fieldset_description'} - {block name='frontend_checkout_payment_fieldset_description_paypal_unified_plus'} - {if $paypalUnifiedUsePlus && $paypalUnifiedApprovalUrl && $payment_mean.id == $paypalUnifiedPaymentId} - {block name='frontend_checkout_shipping_payment_paypal_unified_payment_wall'} - {* This is the placeholder for the payment wall *} -
-
- {/block} - {else} - {$smarty.block.parent} - {/if} - {/block} -{/block} - -{* All integrations *} -{block name='frontend_account_payment_error_messages'} - {block name='frontend_account_payment_error_messages_paypal_unified_errors'} - {if $paypalUnifiedErrorCode} - {include file='frontend/paypal_unified/checkout/error_message.tpl'} - {/if} - {/block} - - {$smarty.block.parent} -{/block} diff --git a/Resources/views/frontend/checkout/shipping_payment_core.tpl b/Resources/views/frontend/checkout/shipping_payment_core.tpl new file mode 100644 index 00000000..cf10490e --- /dev/null +++ b/Resources/views/frontend/checkout/shipping_payment_core.tpl @@ -0,0 +1,28 @@ +{extends file='parent:frontend/checkout/shipping_payment_core.tpl'} + +{* + PayPal Plus integration + + Since the created payment changes on every payment or shipping selection change, we have to use the correct + approval URL. Otherwise the initial URL will always be used, which is wrong +*} +{block name='frontend_checkout_shipping_payment_core_buttons_top'} + {block name='frontend_checkout_shipping_payment_core_buttons_top_paypal_unified_plus'} + {if $paypalUnifiedUsePlus && $paypalUnifiedApprovalUrl} +
{$paypalUnifiedApprovalUrl}
+ {/if} + {/block} + + {$smarty.block.parent} +{/block} + +{* All integrations *} +{block name='frontend_account_payment_error_messages'} + {block name='frontend_account_payment_error_messages_paypal_unified_errors'} + {if $paypalUnifiedErrorCode} + {include file='frontend/paypal_unified/checkout/error_message.tpl'} + {/if} + {/block} + + {$smarty.block.parent} +{/block} diff --git a/Resources/views/frontend/paypal_unified/plus/checkout/payment_wall_shipping_payment.tpl b/Resources/views/frontend/paypal_unified/plus/checkout/payment_wall_shipping_payment.tpl index aa889eab..61270770 100644 --- a/Resources/views/frontend/paypal_unified/plus/checkout/payment_wall_shipping_payment.tpl +++ b/Resources/views/frontend/paypal_unified/plus/checkout/payment_wall_shipping_payment.tpl @@ -3,7 +3,6 @@