@@ -38,8 +38,10 @@ import {
3838 switchMap ,
3939 take ,
4040 tap ,
41+ withLatestFrom ,
4142} from 'rxjs/operators' ;
4243import { OpfCheckoutPaymentWrapperService } from '../opf-checkout-payment-wrapper' ;
44+ import { OpfPaymentEventsService } from '@spartacus/opf/payment/root' ;
4345
4446@Injectable ( )
4547export class OpfCheckoutBillingAddressFormService {
@@ -69,7 +71,7 @@ export class OpfCheckoutBillingAddressFormService {
6971 isSameAsDelivery$ = this . _$isSameAsDelivery . asObservable ( ) ;
7072 protected readonly _$paymentOptionsDisabled = new BehaviorSubject ( false ) ;
7173 paymentOptionsDisabled$ = this . _$paymentOptionsDisabled . asObservable ( ) ;
72-
74+ protected opfPaymentEventsService = inject ( OpfPaymentEventsService ) ;
7375 get pickupNoDefaultAddress$ ( ) : Observable < void > {
7476 return this . _noDefaultAddressFoundForPickupMode$ . asObservable ( ) ;
7577 }
@@ -180,15 +182,20 @@ export class OpfCheckoutBillingAddressFormService {
180182 } ) ,
181183 filter ( ( isStable : boolean ) => isStable ) ,
182184 switchMap ( ( ) => this . getPaymentAddress ( ) ) ,
183-
184- tap ( ( billingAddress : Address | undefined ) => {
185+ withLatestFrom (
186+ this . opfPaymentEventsService . isGiftCardCoveredTotalAmountEvent$
187+ ) ,
188+ tap ( ( [ billingAddress , isGiftCardCovered ] ) => {
185189 if ( ! ! billingAddress && ! ! billingAddress . id ) {
186190 this . billingAddressId = billingAddress . id ;
187191
188192 this . _$billingAddressSub . next ( billingAddress ) ;
189- this . opfCheckoutPaymentWrapperService . reloadPaymentMode ( ) ;
193+ if ( ! isGiftCardCovered ) {
194+ this . opfCheckoutPaymentWrapperService . reloadPaymentMode ( ) ;
195+ }
190196 }
191197 } ) ,
198+ map ( ( [ billingAddress ] ) => billingAddress ) ,
192199 catchError ( ( error : HttpErrorModel ) => {
193200 this . globalMessageService . add (
194201 { key : 'opfCheckout.errors.updateBillingAddress' } ,
0 commit comments