Skip to content

Commit

Permalink
Merge pull request #143 in PLUG_OPEN/swagpaymentpaypalunified from pt…
Browse files Browse the repository at this point in the history
…-9604/5.2/use-correct-payment-for-plus to master

* commit '424b124c76422e21f5635498d0ee3f54006b94f3':
  PT-9604 - Use correct payment for PayPal Plus if shipping or payment is changed on shippingPayment page
  • Loading branch information
mitelg committed Sep 27, 2018
2 parents 7013f8e + 424b124 commit 3bfcebb
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,14 @@
*
* @type Array
*/
thirdPartyPaymentMethods: []
thirdPartyPaymentMethods: [],

/**
* div element which contains the approval URL
*
* @type string
*/
paypalApprovalUrlSelector: '.paypal-unified--plus-approval-url'
},

/**
Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand Down
11 changes: 0 additions & 11 deletions Resources/views/frontend/checkout/change_payment.tpl
Original file line number Diff line number Diff line change
@@ -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}
<script src="https://www.paypalobjects.com/webstatic/ppplus/ppplus.min.js"></script>
{/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'}
Expand Down
26 changes: 0 additions & 26 deletions Resources/views/frontend/checkout/shipping_payment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 *}
<div id="ppplus" class="method--description">
</div>
{/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}
28 changes: 28 additions & 0 deletions Resources/views/frontend/checkout/shipping_payment_core.tpl
Original file line number Diff line number Diff line change
@@ -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}
<div class="is--hidden paypal-unified--plus-approval-url">{$paypalUnifiedApprovalUrl}</div>
{/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}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<div class="is--hidden"
data-paypaLPaymentWall="true"
data-paypalLanguage="{$paypalUnifiedLanguageIso}"
data-paypalApprovalUrl="{$paypalUnifiedApprovalUrl}"
data-paypalCountryIso="{$sUserData.additional.country.countryiso}"
data-paypalMode="{if $paypalUnifiedModeSandbox}sandbox{else}live{/if}"
data-thirdPartyPaymentMethods="{$paypalUnifiedPlusPaymentMethodsPaymentWall|escapeHtml}">
Expand Down

0 comments on commit 3bfcebb

Please sign in to comment.