respond with contract terms as JSON (instead of string) in the wallet API
This commit is contained in:
parent
b51932cc85
commit
119c1c708f
@ -924,7 +924,7 @@ export async function preparePayForUri(
|
||||
logger.info("not confirming payment, insufficient coins");
|
||||
return {
|
||||
status: PreparePayResultType.InsufficientBalance,
|
||||
contractTerms: d.contractTermsRaw,
|
||||
contractTerms: JSON.parse(d.contractTermsRaw),
|
||||
proposalId: proposal.proposalId,
|
||||
};
|
||||
}
|
||||
@ -935,7 +935,7 @@ export async function preparePayForUri(
|
||||
|
||||
return {
|
||||
status: PreparePayResultType.PaymentPossible,
|
||||
contractTerms: d.contractTermsRaw,
|
||||
contractTerms: JSON.parse(d.contractTermsRaw),
|
||||
proposalId: proposal.proposalId,
|
||||
amountEffective: Amounts.stringify(costInfo.totalCost),
|
||||
amountRaw: Amounts.stringify(res.paymentAmount),
|
||||
@ -957,20 +957,20 @@ export async function preparePayForUri(
|
||||
const r = await submitPay(ws, proposalId);
|
||||
return {
|
||||
status: PreparePayResultType.AlreadyConfirmed,
|
||||
contractTerms: purchase.contractTermsRaw,
|
||||
contractTerms: JSON.parse(purchase.contractTermsRaw),
|
||||
paid: true,
|
||||
nextUrl: r.nextUrl,
|
||||
};
|
||||
} else if (!purchase.timestampFirstSuccessfulPay) {
|
||||
return {
|
||||
status: PreparePayResultType.AlreadyConfirmed,
|
||||
contractTerms: purchase.contractTermsRaw,
|
||||
contractTerms: JSON.parse(purchase.contractTermsRaw),
|
||||
paid: false,
|
||||
};
|
||||
} else if (purchase.paymentSubmitPending) {
|
||||
return {
|
||||
status: PreparePayResultType.AlreadyConfirmed,
|
||||
contractTerms: purchase.contractTermsRaw,
|
||||
contractTerms: JSON.parse(purchase.contractTermsRaw),
|
||||
paid: false,
|
||||
};
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ export type PreparePayResult =
|
||||
export interface PreparePayResultPaymentPossible {
|
||||
status: PreparePayResultType.PaymentPossible;
|
||||
proposalId: string;
|
||||
contractTerms: string;
|
||||
contractTerms: Record<string, unknown>;
|
||||
amountRaw: string;
|
||||
amountEffective: string;
|
||||
}
|
||||
@ -337,12 +337,12 @@ export interface PreparePayResultPaymentPossible {
|
||||
export interface PreparePayResultInsufficientBalance {
|
||||
status: PreparePayResultType.InsufficientBalance;
|
||||
proposalId: string;
|
||||
contractTerms: any;
|
||||
contractTerms: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface PreparePayResultAlreadyConfirmed {
|
||||
status: PreparePayResultType.AlreadyConfirmed;
|
||||
contractTerms: any;
|
||||
contractTerms: Record<string, unknown>;
|
||||
paid: boolean;
|
||||
// Only specified if paid.
|
||||
nextUrl?: string;
|
||||
@ -368,7 +368,7 @@ export interface AcceptWithdrawalResponse {
|
||||
* Details about a purchase, including refund status.
|
||||
*/
|
||||
export interface PurchaseDetails {
|
||||
contractTerms: any;
|
||||
contractTerms: Record<string, undefined>;
|
||||
hasRefund: boolean;
|
||||
totalRefundAmount: AmountJson;
|
||||
totalRefundAndRefreshFees: AmountJson;
|
||||
|
@ -791,7 +791,7 @@ export class Wallet {
|
||||
]).amount;
|
||||
const totalFees = totalRefundFees;
|
||||
return {
|
||||
contractTerms: purchase.contractTermsRaw,
|
||||
contractTerms: JSON.parse(purchase.contractTermsRaw),
|
||||
hasRefund: purchase.timestampLastRefundStatus !== undefined,
|
||||
totalRefundAmount: totalRefundAmount,
|
||||
totalRefundAndRefreshFees: totalFees,
|
||||
|
@ -74,9 +74,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }): JSX.Element {
|
||||
let contractTerms: ContractTerms;
|
||||
|
||||
try {
|
||||
contractTerms = codecForContractTerms().decode(
|
||||
JSON.parse(payStatus.contractTerms),
|
||||
);
|
||||
contractTerms = codecForContractTerms().decode(payStatus.contractTerms);
|
||||
} catch (e) {
|
||||
// This should never happen, as the wallet is supposed to check the contract terms
|
||||
// before storing them.
|
||||
|
Loading…
Reference in New Issue
Block a user