Skip to content

Commit

Permalink
#31: Refresh card brands when switching addresses for customer
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarjan-onestic committed Mar 24, 2024
1 parent 077d122 commit 5f139f8
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Magewire/Payment/Method/AdyenPaymentComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public function __construct(
'coupon_code_revoked' => 'refreshProperties',
'shipping_address_saved' => 'refreshProperties',
'billing_address_saved' => 'refreshProperties',
'shipping_address_submitted' => 'refreshProperties',
'billing_address_submitted' => 'refreshProperties',
'shipping_address_activated' => 'refreshProperties',
'billing_address_activated' => 'refreshProperties',
];

/**
Expand Down
1 change: 0 additions & 1 deletion Magewire/Payment/Method/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
class CreditCard extends AdyenPaymentComponent
{
const METHOD_CC = 'adyen_cc';

public ?string $cardBrands = null;

public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use Adyen\Hyva\Magewire\Payment\Method\ApplePay;

async function init(methodCode) {
try {
clearContainer('ApplePayActionContainer');
let wire = Magewire.find('checkout.payment.method.' + methodCode);
let applePayHandler = new applePayComponentHandler(
methodCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use Adyen\Hyva\Magewire\Payment\Method\CreditCard;

async function init(methodCode) {
try {
clearContainer('CreditCardActionContainer');
let wire = Magewire.find('checkout.payment.method.' + methodCode);
let creditCardHandler = new componentHandler(
methodCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ $storedCard = $this->getData(ProcessingMetadataInterface::BLOCK_PROPERTY_STORED_

async function init(cardLayoutId) {
try {
clearContainer(cardLayoutId + '_ActionContainer');
let magewireMethodCode = '<?= $escaper->escapeJs($magewire->getMethodCode()) ?>';
let wire = Magewire.find(cardLayoutId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use Adyen\Hyva\Magewire\Payment\Method\GooglePay;

async function init(methodCode) {
try {
clearContainer('GooglePayActionContainer');
let wire = Magewire.find('checkout.payment.method.' + methodCode);
let googlePayHandler = new googlePayComponentHandler(
methodCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use Adyen\Hyva\Magewire\Payment\Method\Paypal;

async function init(methodCode) {
try {
clearContainer('PaypalActionContainer');
let wire = Magewire.find('checkout.payment.method.' + methodCode);
let paypalHandler = new paypalComponentHandler(
methodCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ $billingAddress = $block->getQuoteBillingAddress();
</div>

<script>
function clearContainer(id) {
document.getElementById(id).innerHTML = '';
}

function showPrimaryButton() {
let elements = document.getElementsByClassName('btn-primary');

Expand Down

0 comments on commit 5f139f8

Please sign in to comment.