Skip to content

Commit 21c4b3b

Browse files
feat(payment): PI-3501 [FE] SPIKE
1 parent 1e6d9cd commit 21c4b3b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/klarna-integration/src/klarnav2/klarnav2-payment-strategy.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class KlarnaV2PaymentStrategy {
4646
options: PaymentInitializeOptions & WithKlarnaV2PaymentInitializeOptions,
4747
): Promise<void> {
4848
this.klarnaPayments = await this.klarnav2ScriptLoader.load();
49-
49+
console.log('Klarna Initialize ===');
5050
this.unsubscribe = this.paymentIntegrationService.subscribe(
5151
(state) => {
5252
if (
@@ -82,6 +82,7 @@ export default class KlarnaV2PaymentStrategy {
8282
}
8383

8484
async execute(payload: OrderRequestBody, options?: PaymentRequestOptions): Promise<void> {
85+
console.log('execute payload ===>', payload);
8586
if (!payload.payment) {
8687
throw new InvalidArgumentError(
8788
'Unable to proceed because "payload.payment" argument is not provided.',
@@ -105,7 +106,7 @@ export default class KlarnaV2PaymentStrategy {
105106

106107
await this.klarnav2TokenUpdater.klarnaOrderInitialization(cartId, clientToken);
107108

108-
const { authorization_token: authorizationToken } = await this.authorizeOrThrow(methodId);
109+
const { authorization_token: authorizationToken } = await this.authorizeOrThrow(gatewayId);
109110

110111
await this.paymentIntegrationService.initializePayment(gatewayId, {
111112
authorizationToken,
@@ -153,17 +154,17 @@ export default class KlarnaV2PaymentStrategy {
153154
await this.klarnav2TokenUpdater.updateClientToken(gatewayId, { params }).catch(() => {
154155
throw new MissingDataError(MissingDataErrorType.MissingPaymentMethod);
155156
});
156-
157157
return new Promise<KlarnaLoadResponse>((resolve) => {
158158
const paymentMethod = state.getPaymentMethodOrThrow(methodId);
159-
159+
console.log('paymentMethod.gateway ===>', paymentMethod.gateway);
160+
160161
if (!this.klarnaPayments || !paymentMethod.clientToken) {
161162
throw new NotInitializedError(NotInitializedErrorType.PaymentNotInitialized);
162163
}
163164

164165
this.klarnaPayments.init({ client_token: paymentMethod.clientToken });
165166
this.klarnaPayments.load(
166-
{ container, payment_method_category: paymentMethod.id },
167+
{ container, payment_method_category: paymentMethod.gateway },
167168
(response) => {
168169
if (onLoad) {
169170
onLoad(response);
@@ -228,7 +229,7 @@ export default class KlarnaV2PaymentStrategy {
228229
return klarnaAddress;
229230
}
230231

231-
private async authorizeOrThrow(methodId: string): Promise<KlarnaAuthorizationResponse> {
232+
private async authorizeOrThrow(gatewayId: string): Promise<KlarnaAuthorizationResponse> {
232233
await this.paymentIntegrationService.loadCheckout();
233234

234235
const state = this.paymentIntegrationService.getState();
@@ -245,7 +246,7 @@ export default class KlarnaV2PaymentStrategy {
245246
}
246247

247248
this.klarnaPayments.authorize(
248-
{ payment_method_category: methodId },
249+
{ payment_method_category: gatewayId },
249250
updateSessionData,
250251
(res) => {
251252
if (res.approved) {

0 commit comments

Comments
 (0)