save posConfirmation after payment

This commit is contained in:
Sebastian 2023-04-03 12:13:13 -03:00
parent defdfd7697
commit 543795f7fc
No known key found for this signature in database
GPG Key ID: 173909D1A5F66069
9 changed files with 27 additions and 7 deletions

View File

@ -947,6 +947,11 @@ export interface BackupPurchase {
*/
merchant_pay_sig: string | undefined;
/**
* Text to be shown to the point-of-sale staff as a proof of payment.
*/
pos_confirmation: string | undefined;
timestamp_proposed: TalerProtocolTimestamp;
/**

View File

@ -961,6 +961,7 @@ export class ExchangeWithdrawBatchResponse {
export interface MerchantPayResponse {
sig: string;
pos_confirmation?: string;
}
export interface ExchangeMeltRequest {
@ -1490,6 +1491,7 @@ export const codecForWithdrawBatchResponse =
export const codecForMerchantPayResponse = (): Codec<MerchantPayResponse> =>
buildCodecForObject<MerchantPayResponse>()
.property("sig", codecForString())
.property("pos_confirmation", codecOptional(codecForString()))
.build("MerchantPayResponse");
export const codecForExchangeMeltResponse = (): Codec<ExchangeMeltResponse> =>

View File

@ -406,6 +406,11 @@ export interface TransactionPayment extends TransactionCommon {
* Is the wallet currently checking for a refund?
*/
refundQueryActive: boolean;
/**
* Does this purchase has an pos validation
*/
posConfirmation: string | undefined;
}
export interface OrderShortInfo {

View File

@ -51,15 +51,15 @@ import {
AmountString,
AuditorDenomSig,
codecForMerchantContractTerms,
codecForPeerContractTerms,
CoinEnvelope,
MerchantContractTerms,
PeerContractTerms,
DenominationPubKey,
DenomKeyType,
ExchangeAuditor,
UnblindedSignature,
codecForPeerContractTerms,
MerchantContractTerms,
PeerContractTerms,
TrackTransaction,
UnblindedSignature,
} from "./taler-types.js";
import {
AbsoluteTime,

View File

@ -1239,6 +1239,8 @@ export interface PurchaseRecord {
merchantPaySig: string | undefined;
posConfirmation: string | undefined;
/**
* When was the purchase record created?
*/

View File

@ -468,6 +468,7 @@ export async function exportBackup(
contract_terms_raw: contractTermsRaw,
auto_refund_deadline: purch.autoRefundDeadline,
merchant_pay_sig: purch.merchantPaySig,
pos_confirmation: purch.posConfirmation,
pay_info: backupPayInfo,
proposal_id: purch.proposalId,
refunds,

View File

@ -691,6 +691,7 @@ export async function importBackup(
backupPurchase.timestamp_first_successful_pay,
timestampLastRefundStatus: undefined,
merchantPaySig: backupPurchase.merchant_pay_sig,
posConfirmation: backupPurchase.pos_confirmation,
lastSessionId: undefined,
download,
refunds,

View File

@ -57,6 +57,7 @@ import {
MerchantCoinRefundStatus,
MerchantCoinRefundSuccessStatus,
MerchantContractTerms,
MerchantPayResponse,
NotificationType,
parsePayUri,
parseRefundUri,
@ -605,6 +606,7 @@ async function startDownloadProposal(
timestampFirstSuccessfulPay: undefined,
timestampLastRefundStatus: undefined,
pendingRemovedCoinPubs: undefined,
posConfirmation: undefined,
};
await ws.db
@ -629,7 +631,7 @@ async function storeFirstPaySuccess(
ws: InternalWalletState,
proposalId: string,
sessionId: string | undefined,
paySig: string,
payResponse: MerchantPayResponse,
): Promise<void> {
const now = AbsoluteTime.toTimestamp(AbsoluteTime.now());
await ws.db
@ -651,7 +653,8 @@ async function storeFirstPaySuccess(
}
purchase.timestampFirstSuccessfulPay = now;
purchase.lastSessionId = sessionId;
purchase.merchantPaySig = paySig;
purchase.merchantPaySig = payResponse.sig;
purchase.posConfirmation = payResponse.pos_confirmation;
const dl = purchase.download;
checkDbInvariant(!!dl);
const contractTermsRecord = await tx.contractTerms.get(
@ -1529,7 +1532,7 @@ export async function processPurchasePay(
throw Error("merchant payment signature invalid");
}
await storeFirstPaySuccess(ws, proposalId, sessionId, merchantResp.sig);
await storeFirstPaySuccess(ws, proposalId, sessionId, merchantResp);
await unblockBackup(ws, proposalId);
} else {
const payAgainUrl = new URL(

View File

@ -1014,6 +1014,7 @@ async function buildTransactionForPurchase(
extendedStatus: status,
pending: purchaseRecord.purchaseStatus === PurchaseStatus.Paying,
refunds,
posConfirmation: purchaseRecord.posConfirmation,
timestamp,
transactionId: makeTransactionId(
TransactionType.Payment,