Skip to content

Commit

Permalink
Clarify requried properties in ExistingCardTransactionRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
sirbrillig committed Dec 16, 2020
1 parent 83b30ca commit 5b45c33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { PaymentProcessorResponse } from '@automattic/composite-checkout';
import { createTransactionEndpointRequestPayloadFromLineItems } from './translate-cart';
import { wpcomTransaction } from '../payment-method-helpers';
import type { PaymentProcessorOptions } from '../types/payment-processors';
import type { TransactionRequestWithLineItems } from '../types/transaction-endpoint';
import type { ExistingCardTransactionRequestWithLineItems } from '../types/transaction-endpoint';

const debug = debugFactory( 'calypso:composite-checkout:payment-method-helpers' );

Expand Down Expand Up @@ -61,7 +61,10 @@ async function submitExistingCardPayment(
return wpcomTransaction( formattedTransactionData, transactionOptions );
}

type ExistingCardTransactionRequest = Omit< TransactionRequestWithLineItems, 'paymentMethodType' >;
type ExistingCardTransactionRequest = Omit<
ExistingCardTransactionRequestWithLineItems,
'paymentMethodType'
>;

function isValidTransactionData(
submitData: unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ export interface TransactionRequestWithLineItems {
nik?: string | undefined;
}

export type ExistingCardTransactionRequestWithLineItems = Partial< TransactionRequestWithLineItems > &
Required<
Pick<
TransactionRequestWithLineItems,
| 'country'
| 'postalCode'
| 'items'
| 'name'
| 'storedDetailsId'
| 'siteId'
| 'paymentMethodToken'
| 'paymentPartnerProcessorId'
>
>;

export type WPCOMTransactionEndpoint = (
_: WPCOMTransactionEndpointRequestPayload
) => Promise< WPCOMTransactionEndpointResponse >;
Expand Down

0 comments on commit 5b45c33

Please sign in to comment.