From 71abddec5e3dc9cc407f468feaaa3284ef528aba Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 9 Sep 2020 12:45:49 +0530 Subject: make withdrawal, pay and refunds work in the WebExtension --- packages/taler-wallet-core/src/operations/refund.ts | 10 ++++++++++ packages/taler-wallet-core/src/types/walletTypes.ts | 4 ++++ packages/taler-wallet-core/src/util/amounts.ts | 3 ++- packages/taler-wallet-core/src/wallet.ts | 5 ++--- 4 files changed, 18 insertions(+), 4 deletions(-) (limited to 'packages/taler-wallet-core/src') diff --git a/packages/taler-wallet-core/src/operations/refund.ts b/packages/taler-wallet-core/src/operations/refund.ts index 10a57f909..ff08fc93d 100644 --- a/packages/taler-wallet-core/src/operations/refund.ts +++ b/packages/taler-wallet-core/src/operations/refund.ts @@ -527,6 +527,16 @@ export async function applyRefund( amountRefundGone: Amounts.stringify(amountRefundGone), amountRefundGranted: Amounts.stringify(amountRefundGranted), pendingAtExchange, + info: { + contractTermsHash: purchase.contractData.contractTermsHash, + merchant: purchase.contractData.merchant, + orderId: purchase.contractData.orderId, + products: purchase.contractData.products, + summary: purchase.contractData.summary, + fulfillmentMessage: purchase.contractData.fulfillmentMessage, + summary_i18n: purchase.contractData.summaryI18n, + fulfillmentMessage_i18n: purchase.contractData.fulfillmentMessageI18n, + } }; } diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts index b8d8be668..1b20d7b47 100644 --- a/packages/taler-wallet-core/src/types/walletTypes.ts +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -55,6 +55,7 @@ import { codecForContractTerms, ContractTerms, } from "./talerTypes"; +import { OrderShortInfo, codecForOrderShortInfo } from "./transactions"; /** * Response for the create reserve request to the wallet. @@ -880,6 +881,8 @@ export interface ApplyRefundResponse { amountRefundGone: AmountString; pendingAtExchange: boolean; + + info: OrderShortInfo; } export const codecForApplyRefundResponse = (): Codec => @@ -890,6 +893,7 @@ export const codecForApplyRefundResponse = (): Codec => .property("contractTermsHash", codecForString()) .property("pendingAtExchange", codecForBoolean()) .property("proposalId", codecForString()) + .property("info", codecForOrderShortInfo()) .build("ApplyRefundResponse"); export interface SetCoinSuspendedRequest { diff --git a/packages/taler-wallet-core/src/util/amounts.ts b/packages/taler-wallet-core/src/util/amounts.ts index 533005b18..e6bee2d1d 100644 --- a/packages/taler-wallet-core/src/util/amounts.ts +++ b/packages/taler-wallet-core/src/util/amounts.ts @@ -257,7 +257,8 @@ export function isNonZero(a: AmountJson): boolean { return a.value > 0 || a.fraction > 0; } -export function isZero(a: AmountJson): boolean { +export function isZero(a: AmountLike): boolean { + a = jsonifyAmount(a); return a.value === 0 && a.fraction === 0; } diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 768d5eb0f..1140a13c3 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -70,7 +70,6 @@ import { AcceptManualWithdrawalResult, BalancesResponse, TestPayArgs, - PreparePayResultType, IntegrationTestArgs, codecForAddExchangeRequest, codecForGetWithdrawalDetailsForUri, @@ -80,7 +79,6 @@ import { codecForApplyRefundRequest, codecForAcceptBankIntegratedWithdrawalRequest, codecForGetExchangeTosRequest, - codecForAbortProposalRequest, codecForConfirmPayRequest, CoreApiResponse, codecForPreparePayRequest, @@ -95,6 +93,7 @@ import { codecForPrepareTipRequest, codecForAcceptTipRequest, codecForAbortPayWithRefundRequest, + ApplyRefundResponse, } from "./types/walletTypes"; import { Logger } from "./util/logging"; @@ -723,7 +722,7 @@ export class Wallet { */ async applyRefund( talerRefundUri: string, - ): Promise<{ contractTermsHash: string; proposalId: string }> { + ): Promise { return applyRefund(this.ws, talerRefundUri); } -- cgit v1.2.3