File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { CustomFields } from '../utils/constant.utils' ;
2
2
import { createApiRoot } from '../client/create.client' ;
3
3
import { FieldDefinition , TypeUpdateAction } from '@commercetools/platform-sdk' ;
4
- import { readConfiguration } from '../utils/config.utils' ;
5
4
const PAYMENT_TYPE_KEY = 'sctm-payment-custom-type' ;
6
5
7
6
export async function createCustomPaymentType ( ) : Promise < void > {
@@ -239,9 +238,8 @@ export async function createCustomPaymentInterfaceInteractionType(): Promise<voi
239
238
240
239
export async function createCustomTransactionType ( ) : Promise < void > {
241
240
const transactionCustomTypeKey =
242
- readConfiguration ( ) . commerceTools . transactionCustomTypeKey &&
243
- readConfiguration ( ) . commerceTools . transactionCustomTypeKey . length > 0
244
- ? readConfiguration ( ) . commerceTools . transactionCustomTypeKey
241
+ process . env ?. CTP_TRANSACTION_CUSTOM_TYPE_KEY && process . env . CTP_TRANSACTION_CUSTOM_TYPE_KEY ?. length > 0
242
+ ? process . env . CTP_TRANSACTION_CUSTOM_TYPE_KEY
245
243
: CustomFields . transactions . defaultCustomTypeKey ;
246
244
247
245
const apiRoot = createApiRoot ( ) ;
Original file line number Diff line number Diff line change @@ -8,10 +8,15 @@ import { getAccessToken } from '../commercetools/auth.commercetools';
8
8
9
9
export const createExtensionAndCustomFields = async ( extensionUrl : string ) : Promise < void > => {
10
10
const response = await getAccessToken ( ) ;
11
- await createPaymentExtension ( extensionUrl , response ?. access_token as string ) ;
12
- await createCustomPaymentType ( ) ;
13
- await createCustomPaymentInterfaceInteractionType ( ) ;
14
- await createCustomTransactionType ( ) ;
11
+ try {
12
+ await createPaymentExtension ( extensionUrl , response ?. access_token as string ) ;
13
+ await createCustomPaymentType ( ) ;
14
+ await createCustomPaymentInterfaceInteractionType ( ) ;
15
+ await createCustomTransactionType ( ) ;
16
+ } catch ( error ) {
17
+ const errorMessage = error instanceof Error ? error . message : 'Unknown error' ;
18
+ throw new Error ( `Failed to create extension and custom fields: ${ errorMessage } ` ) ;
19
+ }
15
20
} ;
16
21
17
22
export const removeExtension = async ( ) : Promise < void > => {
You can’t perform that action at this time.
0 commit comments