diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-merchant.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-merchant.ts | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts index f6bbe5b9f..c71dd7d90 100644 --- a/packages/taler-wallet-core/src/operations/pay-merchant.ts +++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts @@ -146,6 +146,7 @@ import { import { constructTransactionIdentifier, notifyTransition, + parseTransactionIdentifier, stopLongpolling, } from "./transactions.js"; @@ -319,6 +320,7 @@ export class PayMerchantTransactionContext implements TransactionContext { currency, refreshCoins, RefreshReason.AbortPay, + this.transactionId, ); } break; @@ -1669,10 +1671,15 @@ async function runPayForConfirmPay( */ export async function confirmPay( ws: InternalWalletState, - proposalId: string, + transactionId: string, sessionIdOverride?: string, forcedCoinSel?: ForcedCoinSel, ): Promise<ConfirmPayResult> { + const parsedTx = parseTransactionIdentifier(transactionId); + if (parsedTx?.tag !== TransactionType.Payment) { + throw Error("expected payment transaction ID"); + } + const proposalId = parsedTx.proposalId; logger.trace( `executing confirmPay with proposalId ${proposalId} and sessionIdOverride ${sessionIdOverride}`, ); @@ -1686,11 +1693,6 @@ export async function confirmPay( throw Error(`proposal with id ${proposalId} not found`); } - const transactionId = constructTransactionIdentifier({ - tag: TransactionType.Payment, - proposalId, - }); - const d = await expectProposalDownload(ws, proposal); if (!d) { throw Error("proposal is in invalid state"); @@ -1815,6 +1817,8 @@ export async function confirmPay( hintTransactionId: transactionId, }); + // We directly make a first attempt to pay. + // FIXME: In the future we should just wait for the right event return runPayForConfirmPay(ws, proposalId); } @@ -3082,6 +3086,12 @@ async function storeRefunds( Amounts.currencyOf(download.contractData.amount), refreshCoins, RefreshReason.Refund, + // Since refunds are really just pseudo-transactions, + // the originating transaction for the refresh is the payment transaction. + constructTransactionIdentifier({ + tag: TransactionType.Payment, + proposalId: myPurchase.proposalId, + }), ); } } |