-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Adyen/feature/AD-334a
AD-334 Add Apple Pay Express Button with Frontend Logic and API Calls…
- Loading branch information
Showing
4 changed files
with
86 additions
and
23 deletions.
There are no files selected for viewing
40 changes: 34 additions & 6 deletions
40
...en-spartacus/src/cart/components/express-checkout-cart/express-checkout-cart.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,49 @@ | ||
import {Component} from '@angular/core'; | ||
import {Component, OnDestroy, OnInit} from '@angular/core'; | ||
import {CheckoutAdyenConfigurationService} from "../../../service/checkout-adyen-configuration.service"; | ||
import {ActiveCartFacade} from '@spartacus/cart/base/root'; | ||
import {UserIdService} from '@spartacus/core'; | ||
import {EventService, UserIdService} from '@spartacus/core'; | ||
import {AdyenExpressConfigData} from "../../../core/models/occ.config.models"; | ||
import {BehaviorSubject, Subscription} from 'rxjs'; | ||
import {CheckoutAdyenConfigurationReloadEvent} from "../../../events/checkout-adyen.events"; | ||
|
||
@Component({ | ||
selector: 'cx-express-checkout-cart', | ||
templateUrl: './express-checkout-cart.component.html', | ||
styleUrl: './express-checkout-cart.component.scss' | ||
}) | ||
export class ExpressCheckoutCartComponent { | ||
export class ExpressCheckoutCartComponent implements OnInit, OnDestroy { | ||
protected subscriptions = new Subscription(); | ||
|
||
configuration$ = this.checkoutAdyenConfigurationService.fetchExpressCheckoutCartConfiguration(); | ||
configuration$ = new BehaviorSubject<AdyenExpressConfigData | null>(null); | ||
|
||
constructor(protected activeCartFacade: ActiveCartFacade, | ||
constructor(protected activeCartFacade: ActiveCartFacade, | ||
protected userIdService: UserIdService, | ||
protected checkoutAdyenConfigurationService: CheckoutAdyenConfigurationService | ||
protected checkoutAdyenConfigurationService: CheckoutAdyenConfigurationService, | ||
protected eventService: EventService | ||
) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.subscriptions.add( | ||
this.eventService.get(CheckoutAdyenConfigurationReloadEvent).subscribe(event => { | ||
console.log(event); | ||
this.configuration$.next(null); | ||
|
||
this.subscriptions.add( | ||
this.checkoutAdyenConfigurationService.fetchExpressCheckoutCartConfiguration().subscribe((configuration: AdyenExpressConfigData) => { | ||
this.configuration$.next(configuration); | ||
})) | ||
}) | ||
); | ||
|
||
this.subscriptions.add( | ||
this.checkoutAdyenConfigurationService.fetchExpressCheckoutCartConfiguration().subscribe((configuration: AdyenExpressConfigData) => { | ||
this.configuration$.next(configuration); | ||
})) | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.subscriptions.unsubscribe() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 34 additions & 4 deletions
38
...cus/src/product/components/express-checkout-product/express-checkout-product.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,55 @@ | ||
import {Component} from '@angular/core'; | ||
import {Component, OnDestroy, OnInit} from '@angular/core'; | ||
import {CurrentProductService} from '@spartacus/storefront'; | ||
import {UserIdService,} from '@spartacus/core'; | ||
import {EventService, UserIdService,} from '@spartacus/core'; | ||
import {ActiveCartFacade} from '@spartacus/cart/base/root'; | ||
import {CheckoutAdyenConfigurationService} from "../../../service/checkout-adyen-configuration.service"; | ||
import {CheckoutAdyenConfigurationReloadEvent} from "../../../events/checkout-adyen.events"; | ||
import {Subject, Subscription} from 'rxjs'; | ||
import {AdyenExpressConfigData} from "../../../core/models/occ.config.models"; | ||
|
||
@Component({ | ||
selector: 'cx-express-checkout-product', | ||
templateUrl: './express-checkout-product.component.html', | ||
styleUrl: './express-checkout-product.component.css' | ||
}) | ||
export class ExpressCheckoutProductComponent { | ||
export class ExpressCheckoutProductComponent implements OnInit, OnDestroy { | ||
protected subscriptions = new Subscription(); | ||
|
||
|
||
product$ = this.currentProductService.getProduct(); | ||
|
||
configuration$= this.checkoutAdyenConfigurationService.fetchExpressCheckoutPDPConfiguration() | ||
configuration$ = new Subject<AdyenExpressConfigData | null>(); | ||
|
||
constructor(protected currentProductService: CurrentProductService, | ||
protected activeCartFacade: ActiveCartFacade, | ||
protected userIdService: UserIdService, | ||
protected checkoutAdyenConfigurationService: CheckoutAdyenConfigurationService, | ||
protected eventService: EventService | ||
) { | ||
} | ||
|
||
|
||
ngOnInit(): void { | ||
this.subscriptions.add( | ||
this.eventService.get(CheckoutAdyenConfigurationReloadEvent).subscribe(event => { | ||
this.configuration$.next(null); | ||
|
||
this.subscriptions.add( | ||
this.checkoutAdyenConfigurationService.fetchExpressCheckoutPDPConfiguration().subscribe((configuration: AdyenExpressConfigData) => { | ||
this.configuration$.next(configuration); | ||
}) | ||
) | ||
}) | ||
); | ||
|
||
this.subscriptions.add( | ||
this.checkoutAdyenConfigurationService.fetchExpressCheckoutPDPConfiguration().subscribe((configuration: AdyenExpressConfigData) => { | ||
this.configuration$.next(configuration); | ||
})) | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.subscriptions.unsubscribe() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters