@@ -46,7 +46,7 @@ export default class KlarnaV2PaymentStrategy {
46
46
options : PaymentInitializeOptions & WithKlarnaV2PaymentInitializeOptions ,
47
47
) : Promise < void > {
48
48
this . klarnaPayments = await this . klarnav2ScriptLoader . load ( ) ;
49
-
49
+ console . log ( 'Klarna Initialize ===' ) ;
50
50
this . unsubscribe = this . paymentIntegrationService . subscribe (
51
51
( state ) => {
52
52
if (
@@ -82,6 +82,7 @@ export default class KlarnaV2PaymentStrategy {
82
82
}
83
83
84
84
async execute ( payload : OrderRequestBody , options ?: PaymentRequestOptions ) : Promise < void > {
85
+ console . log ( 'execute payload ===>' , payload ) ;
85
86
if ( ! payload . payment ) {
86
87
throw new InvalidArgumentError (
87
88
'Unable to proceed because "payload.payment" argument is not provided.' ,
@@ -105,7 +106,7 @@ export default class KlarnaV2PaymentStrategy {
105
106
106
107
await this . klarnav2TokenUpdater . klarnaOrderInitialization ( cartId , clientToken ) ;
107
108
108
- const { authorization_token : authorizationToken } = await this . authorizeOrThrow ( methodId ) ;
109
+ const { authorization_token : authorizationToken } = await this . authorizeOrThrow ( gatewayId ) ;
109
110
110
111
await this . paymentIntegrationService . initializePayment ( gatewayId , {
111
112
authorizationToken,
@@ -153,17 +154,17 @@ export default class KlarnaV2PaymentStrategy {
153
154
await this . klarnav2TokenUpdater . updateClientToken ( gatewayId , { params } ) . catch ( ( ) => {
154
155
throw new MissingDataError ( MissingDataErrorType . MissingPaymentMethod ) ;
155
156
} ) ;
156
-
157
157
return new Promise < KlarnaLoadResponse > ( ( resolve ) => {
158
158
const paymentMethod = state . getPaymentMethodOrThrow ( methodId ) ;
159
-
159
+ console . log ( 'paymentMethod.gateway ===>' , paymentMethod . gateway ) ;
160
+
160
161
if ( ! this . klarnaPayments || ! paymentMethod . clientToken ) {
161
162
throw new NotInitializedError ( NotInitializedErrorType . PaymentNotInitialized ) ;
162
163
}
163
164
164
165
this . klarnaPayments . init ( { client_token : paymentMethod . clientToken } ) ;
165
166
this . klarnaPayments . load (
166
- { container, payment_method_category : paymentMethod . id } ,
167
+ { container, payment_method_category : paymentMethod . gateway } ,
167
168
( response ) => {
168
169
if ( onLoad ) {
169
170
onLoad ( response ) ;
@@ -228,7 +229,7 @@ export default class KlarnaV2PaymentStrategy {
228
229
return klarnaAddress ;
229
230
}
230
231
231
- private async authorizeOrThrow ( methodId : string ) : Promise < KlarnaAuthorizationResponse > {
232
+ private async authorizeOrThrow ( gatewayId : string ) : Promise < KlarnaAuthorizationResponse > {
232
233
await this . paymentIntegrationService . loadCheckout ( ) ;
233
234
234
235
const state = this . paymentIntegrationService . getState ( ) ;
@@ -245,7 +246,7 @@ export default class KlarnaV2PaymentStrategy {
245
246
}
246
247
247
248
this . klarnaPayments . authorize (
248
- { payment_method_category : methodId } ,
249
+ { payment_method_category : gatewayId } ,
249
250
updateSessionData ,
250
251
( res ) => {
251
252
if ( res . approved ) {
0 commit comments