summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-09-09 12:45:49 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-09-09 12:45:49 +0530
commit71abddec5e3dc9cc407f468feaaa3284ef528aba (patch)
treefbd4c329d8f8b866fdd6549430f0d1bcfcd5ebd5 /packages/taler-wallet-core/src
parent0566406abb74008a5d7796fc047ca98a6dd590b0 (diff)
downloadwallet-core-71abddec5e3dc9cc407f468feaaa3284ef528aba.tar.gz
wallet-core-71abddec5e3dc9cc407f468feaaa3284ef528aba.tar.bz2
wallet-core-71abddec5e3dc9cc407f468feaaa3284ef528aba.zip
make withdrawal, pay and refunds work in the WebExtension
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r--packages/taler-wallet-core/src/operations/refund.ts10
-rw-r--r--packages/taler-wallet-core/src/types/walletTypes.ts4
-rw-r--r--packages/taler-wallet-core/src/util/amounts.ts3
-rw-r--r--packages/taler-wallet-core/src/wallet.ts5
4 files changed, 18 insertions, 4 deletions
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<ApplyRefundResponse> =>
@@ -890,6 +893,7 @@ export const codecForApplyRefundResponse = (): Codec<ApplyRefundResponse> =>
.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<ApplyRefundResponse> {
return applyRefund(this.ws, talerRefundUri);
}