Skip to content

Commit

Permalink
feat(payment): PAYPAL-4937 updates after review
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-nick committed Dec 23, 2024
1 parent 508e965 commit 7afaa0f
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/common/http-request/responses.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Response } from '@bigcommerce/request-sender';
import { ErrorResponseBody } from '@bigcommerce/checkout-sdk/payment-integration-api';

import { HeadlessPaymentMethodResponse, PaymentResponse } from '../../payment';
import HeadlessPaymentMethod from '../../payment/headless-payment-method';
import { HeadlessPaymentMethod } from '../../payment/headless-payment';

export function getResponse<T>(
body: T,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/payment/headless-payment-methods.mock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HeadlessPaymentMethod from './headless-payment-method';
import { HeadlessPaymentMethod } from './headless-payment';

export const initializationData = {
merchantId: '100000',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RequestOptions } from '../common/http-request';
import { RequestOptions } from '../../common/http-request';

export default interface HeadlessPaymentRequestOptions extends RequestOptions {
body?: { query: string };
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/payment/headless-payment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { default as HeadlessPaymentMethod } from './headless-payment-method';
export { default as HeadlessPaymentMethodConfig } from './headless-payment-method-config';
export { default as HeadlessPaymentRequestOptions } from './headless-payment-request-options';

export { HeadlessPaymentMethodType } from './headless-payment-method-type';
export { HeadlessPaymentMethodResponse } from './headless-payment-method-response';
11 changes: 6 additions & 5 deletions packages/core/src/payment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export {
export * from './payment-method-actions';
export * from './payment-method-types';
export * from './payment-status-types';
export * from './headless-payment-method-type';

export {
default as PaymentAdditionalAction,
Expand All @@ -19,6 +18,12 @@ export { default as isHostedInstrumentLike } from './is-hosted-intrument-like';
export { default as isNonceLike } from './is-nonce-like';
export { default as isVaultedInstrument } from './is-vaulted-instrument';
export { default as PaymentActionCreator } from './payment-action-creator';
export {
HeadlessPaymentMethod,
HeadlessPaymentMethodConfig,
HeadlessPaymentRequestOptions,
HeadlessPaymentMethodResponse,
} from './headless-payment';
export {
default as Payment,
CreditCardInstrument,
Expand All @@ -38,15 +43,12 @@ export {
WithMollieIssuerInstrument,
} from './payment';
export { default as PaymentMethod } from './payment-method';
export { default as HeadlessPaymentMethod } from './headless-payment-method';
export { default as PaymentMethodMeta } from './payment-method-meta';
export { default as PaymentMethodConfig } from './payment-method-config';
export { default as HeadlessPaymentMethodConfig } from './headless-payment-method-config';
export { default as InitializationStrategy } from './payment-method-initialization-strategy';
export { default as PaymentMethodActionCreator } from './payment-method-action-creator';
export { default as paymentMethodReducer } from './payment-method-reducer';
export { default as PaymentMethodRequestSender } from './payment-method-request-sender';
export { default as HeadlessPaymentRequestOptions } from './headless-payment-request-options';
export {
default as PaymentMethodSelector,
PaymentMethodSelectorFactory,
Expand All @@ -59,7 +61,6 @@ export { default as PaymentRequestSender } from './payment-request-sender';
export { default as PaymentRequestTransformer } from './payment-request-transformer';
export { default as PaymentResponse } from './payment-response';
export { default as PaymentResponseBody } from './payment-response-body';
export { HeadlessPaymentMethodResponse } from './headless-payment-method-response';
export {
default as PaymentSelector,
PaymentSelectorFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { ContentType, INTERNAL_USE_ONLY, SDK_VERSION_HEADERS } from '../common/http-request';
import { getHeadlessPaymentResponse, getResponse } from '../common/http-request/responses.mock';

import { HeadlessPaymentMethodResponse } from './headless-payment-method-response';
import { HeadlessPaymentMethodResponse } from './headless-payment';
import { getHeadlessPaymentMethod, initializationData } from './headless-payment-methods.mock';
import PaymentMethod from './payment-method';
import PaymentMethodRequestSender from './payment-method-request-sender';
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/payment/payment-method-request-sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import {
SDK_VERSION_HEADERS,
} from '../common/http-request';

import HeadlessPaymentMethodConfig from './headless-payment-method-config';
import { HeadlessPaymentMethodResponse } from './headless-payment-method-response';
import { HeadlessPaymentMethodType } from './headless-payment-method-type';
import HeadlessPaymentRequestOptions from './headless-payment-request-options';
import {
HeadlessPaymentMethodConfig,
HeadlessPaymentMethodResponse,
HeadlessPaymentMethodType,
HeadlessPaymentRequestOptions,
} from './headless-payment';
import PaymentMethod from './payment-method';

export default class PaymentMethodRequestSender {
Expand Down Expand Up @@ -56,8 +58,6 @@ export default class PaymentMethodRequestSender {
methodId: string,
options: HeadlessPaymentRequestOptions,
): Promise<Response<PaymentMethod>> {
const url = `/graphql`;

const entityId = this.getPaymentEntityId(methodId);

const graphQLQuery = `
Expand All @@ -82,7 +82,7 @@ export default class PaymentMethodRequestSender {
};

return this._requestSender
.post<HeadlessPaymentMethodResponse>(url, requestOptions)
.post<HeadlessPaymentMethodResponse>('/graphql', requestOptions)
.then((response) => this.transformToPaymentMethodResponse(response, methodId));
}

Expand Down

0 comments on commit 7afaa0f

Please sign in to comment.