fix preparePay API response
This commit is contained in:
parent
2a4d2944aa
commit
c2dcad8efe
@ -927,6 +927,7 @@ export async function preparePayForUri(
|
||||
status: PreparePayResultType.InsufficientBalance,
|
||||
contractTerms: JSON.parse(d.contractTermsRaw),
|
||||
proposalId: proposal.proposalId,
|
||||
amountRaw: Amounts.stringify(d.contractData.amount),
|
||||
};
|
||||
}
|
||||
|
||||
@ -961,18 +962,24 @@ export async function preparePayForUri(
|
||||
contractTerms: JSON.parse(purchase.contractTermsRaw),
|
||||
paid: true,
|
||||
nextUrl: r.nextUrl,
|
||||
amountRaw: Amounts.stringify(purchase.contractData.amount),
|
||||
amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost),
|
||||
};
|
||||
} else if (!purchase.timestampFirstSuccessfulPay) {
|
||||
return {
|
||||
status: PreparePayResultType.AlreadyConfirmed,
|
||||
contractTerms: JSON.parse(purchase.contractTermsRaw),
|
||||
paid: false,
|
||||
amountRaw: Amounts.stringify(purchase.contractData.amount),
|
||||
amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost),
|
||||
};
|
||||
} else if (purchase.paymentSubmitPending) {
|
||||
return {
|
||||
status: PreparePayResultType.AlreadyConfirmed,
|
||||
contractTerms: JSON.parse(purchase.contractTermsRaw),
|
||||
paid: false,
|
||||
amountRaw: Amounts.stringify(purchase.contractData.amount),
|
||||
amountEffective: Amounts.stringify(purchase.payCostInfo.totalCost),
|
||||
};
|
||||
}
|
||||
// FIXME: we don't handle aborted payments correctly here.
|
||||
|
@ -353,12 +353,15 @@ export interface PreparePayResultInsufficientBalance {
|
||||
status: PreparePayResultType.InsufficientBalance;
|
||||
proposalId: string;
|
||||
contractTerms: Record<string, unknown>;
|
||||
amountRaw: string;
|
||||
}
|
||||
|
||||
export interface PreparePayResultAlreadyConfirmed {
|
||||
status: PreparePayResultType.AlreadyConfirmed;
|
||||
contractTerms: Record<string, unknown>;
|
||||
paid: boolean;
|
||||
amountRaw: string;
|
||||
amountEffective: string;
|
||||
// Only specified if paid.
|
||||
nextUrl?: string;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user