Skip to content

Commit 324e44d

Browse files
committed
META-189: initialize Using simple order response
1 parent 388ea48 commit 324e44d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/initialize/initialize.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
setPublicOrderId,
1010
setShopIdentifier,
1111
checkApiResponse,
12+
IInitializeSimpleOrderResponse,
1213
} from 'src';
1314

1415
/**
@@ -20,12 +21,12 @@ import {
2021
* @param shopIdentifier Identification for the shop in which the order is on
2122
* @param environment Set the environment where the library will be working on.
2223
*/
23-
export async function initialize(initData: IInitializeOrderResponse, shopIdentifier: string, environment: IEnvironment): Promise<IApiReturnObject> {
24+
export async function initialize(initData: IInitializeOrderResponse | IInitializeSimpleOrderResponse, shopIdentifier: string, environment: IEnvironment): Promise<IApiReturnObject> {
2425
const {jwt_token: jwt, public_order_id: publicOrderId} = initData;
2526
const returnObject = {...baseReturnObject};
2627
returnObject.success = true;
2728
returnObject.response = initData;
28-
const keysToCheck = [keysToTestFromResponse.applicationState, keysToTestFromResponse.initial_data, keysToTestFromResponse.jwt_token, keysToTestFromResponse.public_order_id];
29+
const keysToCheck = [keysToTestFromResponse.jwt_token, keysToTestFromResponse.public_order_id];
2930
const returnValue = checkApiResponse(returnObject, keysToCheck);
3031
if(!returnValue.success) {
3132
return returnValue;

src/types/apiInterfaces.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface IApiSuccessResponse {
1414
IDeleteDiscountResponse |
1515
IGetPaymentIframeUrl |
1616
IInitializeOrderResponse |
17+
IInitializeSimpleOrderResponse |
1718
ICssStylingPaymentIframeResponse |
1819
ICheckInventoryResponse |
1920
IAddPaymentResponse |
@@ -121,7 +122,7 @@ export interface IApiReturnObject {
121122
status: number;
122123
success: boolean;
123124
error: null | IFetchError;
124-
response: null | IApiResponse | IApiBatchResponse;
125+
response: null | IApiResponse | IApiBatchResponse | IInitializeSimpleOrderResponse;
125126
}
126127

127128
export interface IFetchCallback extends Function {
@@ -135,6 +136,12 @@ export interface IInitializeOrderResponse {
135136
public_order_id: string
136137
}
137138

139+
export interface IInitializeSimpleOrderResponse {
140+
flow_settings: Record<string, unknown>;
141+
jwt_token: string;
142+
public_order_id: string;
143+
}
144+
138145
export interface ICssStylingPaymentIframeResponse {
139146
style_sheet: IStyleSheet
140147
}

0 commit comments

Comments
 (0)