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; 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; timestamp_proposed: TalerProtocolTimestamp;
/** /**

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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