Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/payment-detection/src/payment-network-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ export class PaymentNetworkFactory {
*
* @param paymentNetworkId the ID of the payment network to instantiate
* @param currencyType the currency type of the request
* @param currencyNetwork the network of the currency of the payment to detect
* @param paymentChain Different from request.currency.network for on-chain conversion payment networks (any-to-something)
* @returns the module to handle the payment network
*/
public createPaymentNetwork(
paymentNetworkId: PaymentTypes.PAYMENT_NETWORK_ID,
currencyType: RequestLogicTypes.CURRENCY,
currencyNetwork?: string,
paymentChain?: string,
paymentNetworkVersion?: string,
): PaymentTypes.IPaymentNetwork {
const network = currencyNetwork || 'mainnet';
const network = paymentChain ?? 'mainnet';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I think we could challenge this default choice. For another PR.

const currencyPaymentMap =
supportedPaymentNetwork[currencyType]?.[network] ||
supportedPaymentNetwork[currencyType]?.['*'] ||
Expand Down
7 changes: 6 additions & 1 deletion packages/request-client.js/src/api/request-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,16 @@ export default class RequestNetwork {
const copiedRequestParameters = Utils.deepCopy(requestParameters);
copiedRequestParameters.extensionsData = [];

const detectionChain =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I have prepared some refactoring of the payment network creation parameters, upcoming PR.

parameters?.paymentNetwork?.parameters && 'network' in parameters.paymentNetwork.parameters
? parameters.paymentNetwork.parameters.network ?? requestParameters.currency.network
: requestParameters.currency.network;

const paymentNetwork = parameters.paymentNetwork
? this.paymentNetworkFactory.createPaymentNetwork(
parameters.paymentNetwork.id,
requestParameters.currency.type,
requestParameters.currency.network,
detectionChain,
)
: null;

Expand Down
11 changes: 11 additions & 0 deletions packages/request-client.js/test/data-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ export const parametersWithoutExtensionsData: RequestLogicTypes.ICreateParameter
payer: payer.identity,
timestamp: arbitraryTimestamp,
};
export const parametersUSDWithoutExtensionsData: RequestLogicTypes.ICreateParameters = {
currency: {
type: RequestLogicTypes.CURRENCY.ISO4217,
value: 'USD',
},
// 345.67 USD
expectedAmount: '34567',
payee: payee.identity,
payer: payer.identity,
timestamp: arbitraryTimestamp,
};
export const parametersWithoutExtensionsDataForSigning: RequestLogicTypes.ICreateParameters = {
currency: {
network: 'testnet',
Expand Down
Loading