Skip to content

Commit

Permalink
chore: Remove redundant getPayNode() function
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Dec 18, 2024
1 parent a6ff471 commit 18fdbb6
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/requests/payment-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function createPaymentRequest(
console.error(`Unable to generate fee breakdown for session ${sessionId}`);
}

const paymentAmountPounds = await getPaymentAmount(payNode, session);
const paymentAmountPounds = await getPaymentAmount(session);
if (!paymentAmountPounds)
throw new Error("Payment amount not found in passport");

Expand Down Expand Up @@ -225,19 +225,11 @@ async function getPayNode(
/**
* Find the payment amount from the the passport
*/
async function getPaymentAmount(
payNode: PayNode,
session: Session,
): Promise<number | undefined> {
const amountKey = getPaymentAmountKey(payNode);
async function getPaymentAmount(session: Session): Promise<number | undefined> {
const amountKey = "application.fee.payable";
return new Passport(session.data.passport).number([amountKey]);
}

function getPaymentAmountKey(payNode: PayNode) {
const defaultPaymentKey = "application.fee.payable";
return payNode.data.fn || defaultPaymentKey;
}

export async function _markPaymentRequestAsPaid(
client: GraphQLClient,
paymentRequestId: string,
Expand Down

0 comments on commit 18fdbb6

Please sign in to comment.