Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#77 add snippets to payment information link + update position link #78

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Resources/frontend/js/jquery.adyen-payment-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@
* @type {String}
*/
paymentMethodSelector: '.payment--method',
/**
* Selector for the payment method label wrapper.
*
* @type {String}
*/
methodLabelSelector: '.method--label',
/**
* Selector for the payment method component wrapper.
*
Expand All @@ -65,6 +59,12 @@
* @type {string} the group name of Gift card types
*/
giftCardGroupName: 'Gift Card',
/**
* @type {string} Snippets associated with the payment page
*/
adyenSnippets: {
updatePaymentInformation: 'Update your payment information'
}
},

currentSelectedPaymentId: '',
Expand Down Expand Up @@ -254,9 +254,9 @@

me.changeInfosButton = $('<a/>')
.addClass(me.opts.classChangePaymentInfo)
.html('Update your payment information')
.html(me.opts.adyenSnippets.updatePaymentInformation)
.on('click', $.proxy(me.updatePaymentInfo, me));
paymentMethodContainer.find(me.opts.methodLabelSelector).append(me.changeInfosButton);
paymentMethodContainer.find(me.opts.methodBankdataSelector).append(me.changeInfosButton);
},
isPaymentMethodValid: function (paymentMethod) {
var me = this;
Expand Down
1 change: 0 additions & 1 deletion Resources/frontend/less/all.less
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
}
}
.method--change-info {
float: right;
cursor: pointer;
}
}
Expand Down
3 changes: 2 additions & 1 deletion Resources/views/frontend/checkout/change_payment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
data-adyenEnvironment='{$sAdyenConfig.environment}'
data-adyenPaymentMethodsResponse='{$sAdyenConfig.paymentMethods}'
data-resetSessionUrl='{url controller="Adyen" action="ResetValidPaymentSession"}'
{if $mAdyenSnippets}data-adyensnippets="{$mAdyenSnippets}"{/if}
class="adyen-payment-selection">
</div>
{/if}
Expand All @@ -19,7 +20,7 @@
{block name='frontend_checkout_payment_fieldset_input_label'}
{if $payment_mean.image}
<div class="method--image">
<img src="{$payment_mean.image}" alt="{$payment_mean.description}"/>
<img src="{$payment_mean.image}" alt="{$payment_mean.description}"/>
</div>
{/if}
{$smarty.block.parent}
Expand Down
37 changes: 31 additions & 6 deletions Subscriber/CheckoutSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,20 @@ public function checkoutFrontendPreDispatch(Enlight_Event_EventArgs $args)
*/
public function checkoutFrontendPostDispatch(Enlight_Event_EventArgs $args)
{
$subject = $args->getSubject();

$this->checkFirstCheckoutStep($args);
$this->rewritePaymentData($args);
$this->addAdyenConfigOnShipping($args);
$this->addAdyenSnippets($args);
$this->addAdyenGooglePay($args);

if (in_array($subject->Request()->getActionName(), ['shippingPayment', 'saveShippingPayment'])) {
$this->addPaymentSnippets($args);
}

if (in_array($subject->Request()->getActionName(), ['confirm'])) {
$this->addConfirmSnippets($args);
}
}

/**
Expand Down Expand Up @@ -220,15 +229,11 @@ private function addAdyenConfigOnShipping(Enlight_Event_EventArgs $args)
/**
* @param Enlight_Event_EventArgs $args
*/
private function addAdyenSnippets(Enlight_Event_EventArgs $args)
private function addConfirmSnippets(Enlight_Event_EventArgs $args)
{
/** @var Shopware_Controllers_Frontend_Checkout $subject */
$subject = $args->getSubject();

if (!in_array($subject->Request()->getActionName(), ['confirm'])) {
return;
}

$errorSnippets = $this->snippets->getNamespace('adyen/checkout/error');

$snippets = [];
Expand Down Expand Up @@ -261,6 +266,26 @@ private function addAdyenSnippets(Enlight_Event_EventArgs $args)
$subject->View()->assign('mAdyenSnippets', htmlentities(json_encode($snippets)));
}

/**
* @param Enlight_Event_EventArgs $args
*/
private function addPaymentSnippets(Enlight_Event_EventArgs $args)
{
/** @var Shopware_Controllers_Frontend_Checkout $subject */
$subject = $args->getSubject();

$paymentSnippets = $this->snippets->getNamespace('adyen/checkout/payment');

$snippets = [];
$snippets['updatePaymentInformation'] = $paymentSnippets->get(
'updatePaymentInformation',
'Update your payment information',
true
);

$subject->View()->assign('mAdyenSnippets', htmlentities(json_encode($snippets)));
}

/**
* @param Enlight_Event_EventArgs $args
*/
Expand Down