Skip to content

Commit

Permalink
Merge pull request #30 from Adyen/feature/AD-291_v13.1.0
Browse files Browse the repository at this point in the history
AD-291: Update `checkout-adyen-payment-method.component.ts` to includ…
  • Loading branch information
kpieloch authored Dec 24, 2024
2 parents cb2cd7c + 1798a7d commit 5f31218
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {ActionHandledReturnObject} from "@adyen/adyen-web";
import {PlaceOrderResponse} from "../core/models/occ.order.models";
import {AdyenOrderService} from "../service/adyen-order.service";
import {CheckoutAdyenConfigurationReloadEvent} from "../events/checkout-adyen.events";
import {CoreConfiguration, DropinConfiguration, UIElement} from "@adyen/adyen-web";
import {CoreConfiguration, DropinConfiguration, UIElement, SubmitActions, AdditionalDetailsActions} from "@adyen/adyen-web";
import { AdyenCheckout, Dropin,AdyenCheckoutError } from '@adyen/adyen-web/auto'
import {AdyenExpressOrderService} from "../service/adyen-express-order.service";

Expand Down Expand Up @@ -151,8 +151,8 @@ export class CheckoutAdyenPaymentMethodComponent implements OnInit, OnDestroy {
enabled: true
},
onError: (error: AdyenCheckoutError) => this.handleError(error),
onSubmit: (state: any, element: UIElement) => this.handlePayment(state.data),
onAdditionalDetails: (state: any, element?: UIElement) => this.handleAdditionalDetails(state.data),
onSubmit: (state: any, element: UIElement, actions: SubmitActions) => this.handlePayment(state.data,actions),
onAdditionalDetails: (state: any, element: UIElement, actions: AdditionalDetailsActions ) => this.handleAdditionalDetails(state.data,actions),
onActionHandled(data: ActionHandledReturnObject) {
console.log("onActionHandled", data);
}
Expand Down Expand Up @@ -213,28 +213,31 @@ export class CheckoutAdyenPaymentMethodComponent implements OnInit, OnDestroy {
this.billingAddress = address;
}

private handlePayment(paymentData: any) {
private handlePayment(paymentData: any, actions: SubmitActions) {
this.adyenOrderService.adyenPlaceOrder(paymentData, this.billingAddress).subscribe(
result => {
this.handleResponse(result);
this.handleResponse(result, actions);
}
);
}

private handleAdditionalDetails(details: any) {
private handleAdditionalDetails(details: any, actions: AdditionalDetailsActions) {
this.adyenOrderService.sendAdditionalDetails(details).subscribe(
result => {
this.handleResponse(result);
this.handleResponse(result, actions);
}
);
}

private handleResponse(response: PlaceOrderResponse | void) {
private handleResponse(response: PlaceOrderResponse | void, actions: SubmitActions) {
if (!!response) {
if (response.success) {
if (response.executeAction && response.paymentsAction !== undefined) {
this.dropIn.handleAction(response.paymentsAction)
} else {
actions.resolve({
resultCode: 'Authorised'
});
this.onSuccess();
}
} else {
Expand Down

0 comments on commit 5f31218

Please sign in to comment.