2021-06-03 06:07:29 +02:00
/ *
This file is part of GNU Taler
2022-06-06 17:05:26 +02:00
( C ) 2022 Taler Systems S . A .
2021-06-03 06:07:29 +02:00
GNU Taler is free software ; you can redistribute it and / or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation ; either version 3 , or ( at your option ) any later version .
GNU Taler is distributed in the hope that it will be useful , but WITHOUT ANY
WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE . See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License along with
GNU Taler ; see the file COPYING . If not , see < http : / / www.gnu.org / licenses / >
* /
/ * *
2021-11-15 15:18:58 +01:00
*
* @author Sebastian Javier Marchano ( sebasjm )
* /
2021-06-03 06:07:29 +02:00
2021-06-08 21:01:41 +02:00
import {
PaymentStatus ,
2022-03-18 15:32:41 +01:00
TalerProtocolTimestamp ,
2021-11-15 15:18:58 +01:00
TransactionCommon ,
TransactionDeposit ,
TransactionPayment ,
TransactionRefresh ,
TransactionRefund ,
TransactionTip ,
TransactionType ,
2021-06-08 21:01:41 +02:00
TransactionWithdrawal ,
2022-05-26 20:55:14 +02:00
WithdrawalDetails ,
2021-11-15 15:18:58 +01:00
WithdrawalType ,
} from "@gnu-taler/taler-util" ;
2022-03-29 04:41:07 +02:00
import { DevContextProviderForTesting } from "../context/devContext.js" ;
2021-12-06 14:31:19 +01:00
import {
createExample ,
createExampleWithCustomContext as createExampleInCustomContext ,
2022-03-29 04:41:07 +02:00
} from "../test-utils.js" ;
import { TransactionView as TestedComponent } from "./Transaction.js" ;
2021-06-03 06:07:29 +02:00
export default {
2021-11-15 15:18:58 +01:00
title : "wallet/history/details" ,
2021-06-16 23:21:03 +02:00
component : TestedComponent ,
2021-06-28 16:38:29 +02:00
argTypes : {
2021-11-15 15:18:58 +01:00
onRetry : { action : "onRetry" } ,
onDelete : { action : "onDelete" } ,
onBack : { action : "onBack" } ,
} ,
2021-06-03 06:07:29 +02:00
} ;
const commonTransaction = {
2021-11-15 15:18:58 +01:00
amountRaw : "KUDOS:11" ,
amountEffective : "KUDOS:9.2" ,
2021-06-03 06:07:29 +02:00
pending : false ,
2022-03-18 15:32:41 +01:00
timestamp : TalerProtocolTimestamp.now ( ) ,
2021-11-15 15:18:58 +01:00
transactionId : "12" ,
} as TransactionCommon ;
2021-06-03 06:07:29 +02:00
2022-05-29 06:42:35 +02:00
import merchantIcon from "../../static-dev/merchant-icon.jpeg" ;
2022-05-26 20:55:14 +02:00
2021-06-03 06:07:29 +02:00
const exampleData = {
withdraw : {
. . . commonTransaction ,
type : TransactionType . Withdrawal ,
2021-11-15 15:18:58 +01:00
exchangeBaseUrl : "http://exchange.taler" ,
2021-06-03 06:07:29 +02:00
withdrawalDetails : {
confirmed : false ,
2021-11-19 18:51:27 +01:00
reservePub : "A05AJGMFNSK4Q62NXR2FKNDB1J4EXTYQTE7VA4M9GZQ4TR06YBNG" ,
2022-05-26 20:55:14 +02:00
exchangePaytoUris : [ "payto://x-taler-bank/bank.demo.taler.net/Exchange" ] ,
2021-06-03 06:07:29 +02:00
type : WithdrawalType . ManualTransfer ,
2021-11-15 15:18:58 +01:00
} ,
2021-06-03 06:07:29 +02:00
} as TransactionWithdrawal ,
payment : {
. . . commonTransaction ,
2022-05-26 20:55:14 +02:00
amountEffective : "KUDOS:12" ,
2021-06-03 06:07:29 +02:00
type : TransactionType . Payment ,
info : {
2021-11-15 15:18:58 +01:00
contractTermsHash : "ASDZXCASD" ,
2021-06-03 06:07:29 +02:00
merchant : {
2021-11-15 15:18:58 +01:00
name : "the merchant" ,
2022-05-26 20:55:14 +02:00
logo : merchantIcon ,
website : "https://www.themerchant.taler" ,
email : "contact@merchant.taler" ,
2021-06-03 06:07:29 +02:00
} ,
2021-11-15 15:18:58 +01:00
orderId : "2021.167-03NPY6MCYMVGT" ,
2021-06-03 06:07:29 +02:00
products : [ ] ,
2021-06-21 15:07:56 +02:00
summary : "Essay: Why the Devil's Advocate Doesn't Help Reach the Truth" ,
2021-11-15 15:18:58 +01:00
fulfillmentMessage : "" ,
2022-05-26 20:55:14 +02:00
// delivery_date: { t_s: 1 },
// delivery_location: {
// address_lines: [""],
// },
2021-06-03 06:07:29 +02:00
} ,
2022-05-29 06:23:15 +02:00
refunds : [ ] ,
2022-05-14 23:09:33 +02:00
refundPending : undefined ,
2022-05-26 20:55:14 +02:00
totalRefundEffective : "KUDOS:0" ,
totalRefundRaw : "KUDOS:0" ,
2021-11-15 15:18:58 +01:00
proposalId : "1EMJJH8EP1NX3XF7733NCYS2DBEJW4Q2KA5KEB37MCQJQ8Q5HMC0" ,
2021-06-03 06:07:29 +02:00
status : PaymentStatus.Accepted ,
} as TransactionPayment ,
deposit : {
. . . commonTransaction ,
type : TransactionType . Deposit ,
2021-11-15 15:18:58 +01:00
depositGroupId : "#groupId" ,
2022-05-26 20:55:14 +02:00
targetPaytoUri : "payto://x-taler-bank/bank.demo.taler.net/Exchange" ,
2021-06-03 06:07:29 +02:00
} as TransactionDeposit ,
refresh : {
. . . commonTransaction ,
type : TransactionType . Refresh ,
2021-11-15 15:18:58 +01:00
exchangeBaseUrl : "http://exchange.taler" ,
2021-06-03 06:07:29 +02:00
} as TransactionRefresh ,
tip : {
. . . commonTransaction ,
type : TransactionType . Tip ,
2022-08-08 19:09:28 +02:00
// merchant: {
// name: "the merchant",
// logo: merchantIcon,
// website: "https://www.themerchant.taler",
// email: "contact@merchant.taler",
// },
2021-11-15 15:18:58 +01:00
merchantBaseUrl : "http://merchant.taler" ,
2021-06-03 06:07:29 +02:00
} as TransactionTip ,
refund : {
. . . commonTransaction ,
type : TransactionType . Refund ,
2021-11-15 15:18:58 +01:00
refundedTransactionId :
"payment:1EMJJH8EP1NX3XF7733NCYS2DBEJW4Q2KA5KEB37MCQJQ8Q5HMC0" ,
2021-06-03 06:07:29 +02:00
info : {
2021-11-15 15:18:58 +01:00
contractTermsHash : "ASDZXCASD" ,
2021-06-03 06:07:29 +02:00
merchant : {
2021-11-15 15:18:58 +01:00
name : "the merchant" ,
2021-06-03 06:07:29 +02:00
} ,
2021-11-15 15:18:58 +01:00
orderId : "2021.167-03NPY6MCYMVGT" ,
2021-06-03 06:07:29 +02:00
products : [ ] ,
2022-05-26 20:55:14 +02:00
summary : "Essay: Why the Devil's Advocate Doesn't Help Reach the Truth" ,
2021-11-15 15:18:58 +01:00
fulfillmentMessage : "" ,
2021-06-03 06:07:29 +02:00
} ,
2022-05-14 23:09:33 +02:00
refundPending : undefined ,
2021-06-03 06:07:29 +02:00
} as TransactionRefund ,
2021-11-15 15:18:58 +01:00
} ;
2021-06-03 06:07:29 +02:00
2021-06-28 16:38:29 +02:00
const transactionError = {
2021-12-06 17:37:01 +01:00
code : 7005 ,
details : {
2022-01-04 21:06:17 +01:00
requestUrl :
"http://merchant-backend.taler:9966/orders/2021.340-02AD5XCC97MQM/pay" ,
2021-12-06 17:37:01 +01:00
httpStatusCode : 410 ,
errorResponse : {
code : 2161 ,
2022-01-04 21:06:17 +01:00
hint : "The payment is too late, the offer has expired." ,
} ,
2021-12-06 17:37:01 +01:00
} ,
hint : "Error: WALLET_UNEXPECTED_REQUEST_ERROR" ,
message : "Unexpected error code in response" ,
2021-11-15 15:18:58 +01:00
} ;
2021-06-28 16:38:29 +02:00
2021-06-21 01:37:35 +02:00
export const Withdraw = createExample ( TestedComponent , {
2021-11-15 15:18:58 +01:00
transaction : exampleData.withdraw ,
2021-06-03 06:07:29 +02:00
} ) ;
2022-05-26 20:55:14 +02:00
export const WithdrawFiveMinutesAgo = createExample ( TestedComponent , ( ) = > ( {
2021-12-06 14:31:19 +01:00
transaction : {
. . . exampleData . withdraw ,
2022-05-26 20:55:14 +02:00
timestamp : TalerProtocolTimestamp.fromSeconds (
new Date ( ) . getTime ( ) / 1000 - 60 * 5 ,
) ,
2021-12-06 14:31:19 +01:00
} ,
2022-05-26 20:55:14 +02:00
} ) ) ;
2021-12-06 14:31:19 +01:00
2022-05-26 20:55:14 +02:00
export const WithdrawFiveMinutesAgoAndPending = createExample (
TestedComponent ,
( ) = > ( {
transaction : {
. . . exampleData . withdraw ,
timestamp : TalerProtocolTimestamp.fromSeconds (
new Date ( ) . getTime ( ) / 1000 - 60 * 5 ,
) ,
pending : true ,
} ,
} ) ,
) ;
2021-12-06 14:31:19 +01:00
2021-06-28 16:38:29 +02:00
export const WithdrawError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . withdraw ,
error : transactionError ,
} ,
} ) ;
2021-12-06 14:31:19 +01:00
export const WithdrawErrorInDevMode = createExampleInCustomContext (
TestedComponent ,
{
transaction : {
. . . exampleData . withdraw ,
error : transactionError ,
} ,
} ,
DevContextProviderForTesting ,
{ value : true } ,
) ;
2022-05-26 20:55:14 +02:00
export const WithdrawPendingManual = createExample ( TestedComponent , ( ) = > ( {
2021-11-19 18:51:27 +01:00
transaction : {
. . . exampleData . withdraw ,
withdrawalDetails : {
type : WithdrawalType . ManualTransfer ,
2022-05-29 06:23:15 +02:00
exchangePaytoUris : [ "payto://iban/ES8877998399652238" ] ,
2021-11-19 18:51:27 +01:00
reservePub : "A05AJGMFNSK4Q62NXR2FKNDB1J4EXTYQTE7VA4M9GZQ4TR06YBNG" ,
2022-05-26 20:55:14 +02:00
} as WithdrawalDetails ,
2021-11-19 18:51:27 +01:00
pending : true ,
} ,
2022-05-26 20:55:14 +02:00
} ) ) ;
2021-06-03 06:07:29 +02:00
2021-11-19 18:51:27 +01:00
export const WithdrawPendingTalerBankUnconfirmed = createExample (
TestedComponent ,
{
transaction : {
. . . exampleData . withdraw ,
withdrawalDetails : {
type : WithdrawalType . TalerBankIntegrationApi ,
confirmed : false ,
reservePub : "A05AJGMFNSK4Q62NXR2FKNDB1J4EXTYQTE7VA4M9GZQ4TR06YBNG" ,
bankConfirmationUrl : "http://bank.demo.taler.net" ,
} ,
pending : true ,
} ,
} ,
) ;
export const WithdrawPendingTalerBankConfirmed = createExample (
TestedComponent ,
{
transaction : {
. . . exampleData . withdraw ,
withdrawalDetails : {
type : WithdrawalType . TalerBankIntegrationApi ,
confirmed : true ,
reservePub : "A05AJGMFNSK4Q62NXR2FKNDB1J4EXTYQTE7VA4M9GZQ4TR06YBNG" ,
} ,
pending : true ,
} ,
} ,
) ;
2021-06-21 01:37:35 +02:00
export const Payment = createExample ( TestedComponent , {
2021-11-15 15:18:58 +01:00
transaction : exampleData.payment ,
2021-06-03 06:07:29 +02:00
} ) ;
2021-06-28 16:38:29 +02:00
export const PaymentError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
2021-11-15 15:18:58 +01:00
error : transactionError ,
2021-06-28 16:38:29 +02:00
} ,
} ) ;
2022-05-26 20:55:14 +02:00
export const PaymentWithRefund = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
amountRaw : "KUDOS:12" ,
totalRefundEffective : "KUDOS:1" ,
totalRefundRaw : "KUDOS:1" ,
2022-05-29 06:23:15 +02:00
refunds : [
{
transactionId : "1123123" ,
amountRaw : "KUDOS:1" ,
amountEffective : "KUDOS:1" ,
timestamp : TalerProtocolTimestamp.fromSeconds ( 1546546544 ) ,
} ,
] ,
2022-05-26 20:55:14 +02:00
} ,
} ) ;
export const PaymentWithDeliveryDate = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
amountRaw : "KUDOS:12" ,
info : {
. . . exampleData . payment . info ,
delivery_date : {
t_s : new Date ( ) . getTime ( ) / 1000 ,
} ,
} ,
} ,
} ) ;
export const PaymentWithDeliveryAddr = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
amountRaw : "KUDOS:12" ,
info : {
. . . exampleData . payment . info ,
delivery_location : {
country : "Argentina" ,
street : "Elm Street" ,
district : "CABA" ,
post_code : "1101" ,
} ,
} ,
} ,
} ) ;
export const PaymentWithDeliveryFull = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
amountRaw : "KUDOS:12" ,
info : {
. . . exampleData . payment . info ,
delivery_date : {
t_s : new Date ( ) . getTime ( ) / 1000 ,
} ,
delivery_location : {
country : "Argentina" ,
street : "Elm Street" ,
district : "CABA" ,
post_code : "1101" ,
} ,
} ,
} ,
} ) ;
export const PaymentWithRefundPending = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
amountRaw : "KUDOS:12" ,
refundPending : "KUDOS:3" ,
totalRefundEffective : "KUDOS:1" ,
totalRefundRaw : "KUDOS:1" ,
} ,
} ) ;
export const PaymentWithFeeAndRefund = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
amountRaw : "KUDOS:11" ,
totalRefundEffective : "KUDOS:1" ,
totalRefundRaw : "KUDOS:1" ,
} ,
} ) ;
export const PaymentWithFeeAndRefundFee = createExample ( TestedComponent , {
2021-06-21 01:37:35 +02:00
transaction : {
. . . exampleData . payment ,
2021-11-15 15:18:58 +01:00
amountRaw : "KUDOS:11" ,
2022-05-26 20:55:14 +02:00
totalRefundEffective : "KUDOS:1" ,
totalRefundRaw : "KUDOS:2" ,
} ,
} ) ;
export const PaymentWithoutFee = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
amountRaw : "KUDOS:12" ,
2021-11-15 15:18:58 +01:00
} ,
2021-06-21 01:37:35 +02:00
} ) ;
export const PaymentPending = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : { . . . exampleData . payment , pending : true } ,
} ) ;
2022-03-29 05:25:33 +02:00
import beer from "../../static-dev/beer.png" ;
2021-06-21 01:37:35 +02:00
export const PaymentWithProducts = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : {
. . . exampleData . payment ,
info : {
. . . exampleData . payment . info ,
2022-05-26 20:55:14 +02:00
summary : "summary of 5 products" ,
2021-11-15 15:18:58 +01:00
products : [
{
description : "t-shirt" ,
unit : "shirts" ,
quantity : 1 ,
} ,
{
description : "t-shirt" ,
unit : "shirts" ,
quantity : 1 ,
} ,
{
description : "e-book" ,
} ,
{
description : "beer" ,
unit : "pint" ,
quantity : 15 ,
2022-03-29 05:25:33 +02:00
image : beer ,
2021-11-15 15:18:58 +01:00
} ,
{
description : "beer" ,
unit : "pint" ,
quantity : 15 ,
2022-03-29 05:25:33 +02:00
image : beer ,
2021-11-15 15:18:58 +01:00
} ,
] ,
} ,
2021-06-21 01:37:35 +02:00
} as TransactionPayment ,
} ) ;
export const PaymentWithLongSummary = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
info : {
. . . exampleData . payment . info ,
2021-11-15 15:18:58 +01:00
summary :
"this is a very long summary that will occupy severals lines, this is a very long summary that will occupy severals lines, this is a very long summary that will occupy severals lines, this is a very long summary that will occupy severals lines, " ,
products : [
{
description :
"an xl sized t-shirt with some drawings on it, color pink" ,
unit : "shirts" ,
quantity : 1 ,
} ,
{
description : "beer" ,
unit : "pint" ,
quantity : 15 ,
} ,
] ,
} ,
2021-06-03 06:07:29 +02:00
} as TransactionPayment ,
} ) ;
2021-06-21 01:37:35 +02:00
export const Deposit = createExample ( TestedComponent , {
2021-11-15 15:18:58 +01:00
transaction : exampleData.deposit ,
2021-06-03 06:07:29 +02:00
} ) ;
2022-05-29 06:23:15 +02:00
export const DepositTalerBank = createExample ( TestedComponent , {
transaction : {
. . . exampleData . deposit ,
targetPaytoUri : "payto://x-taler-bank/bank.demo.taler.net/Exchange" ,
} ,
} ) ;
export const DepositBitcoin = createExample ( TestedComponent , {
transaction : {
. . . exampleData . deposit ,
2022-06-09 18:37:33 +02:00
amountRaw : "BITCOINBTC:0.0000011" ,
2022-08-08 19:09:28 +02:00
amountEffective : "BITCOINBTC:0.00000092" ,
2022-05-29 06:23:15 +02:00
targetPaytoUri :
"payto://bitcoin/bcrt1q6ps8qs6v8tkqrnru4xqqqa6rfwcx5ufpdfqht4?amount=BTC:0.1&subject=0ZSX8SH0M30KHX8K3Y1DAMVGDQV82XEF9DG1HC4QMQ3QWYT4AF00" ,
} ,
} ) ;
export const DepositIBAN = createExample ( TestedComponent , {
transaction : {
. . . exampleData . deposit ,
targetPaytoUri : "payto://iban/ES8877998399652238" ,
} ,
} ) ;
2021-06-03 06:07:29 +02:00
2021-06-28 16:38:29 +02:00
export const DepositError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . deposit ,
2021-11-15 15:18:58 +01:00
error : transactionError ,
2021-06-28 16:38:29 +02:00
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const DepositPending = createExample ( TestedComponent , {
2021-11-15 15:18:58 +01:00
transaction : { . . . exampleData . deposit , pending : true } ,
2021-06-03 06:07:29 +02:00
} ) ;
2021-06-21 01:37:35 +02:00
export const Refresh = createExample ( TestedComponent , {
2021-11-15 15:18:58 +01:00
transaction : exampleData.refresh ,
2021-06-03 06:07:29 +02:00
} ) ;
2021-06-28 16:38:29 +02:00
export const RefreshError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . refresh ,
2021-11-15 15:18:58 +01:00
error : transactionError ,
2021-06-28 16:38:29 +02:00
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const Tip = createExample ( TestedComponent , {
2021-11-15 15:18:58 +01:00
transaction : exampleData.tip ,
2021-06-03 06:07:29 +02:00
} ) ;
2021-06-28 16:38:29 +02:00
export const TipError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . tip ,
2021-11-15 15:18:58 +01:00
error : transactionError ,
2021-06-28 16:38:29 +02:00
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const TipPending = createExample ( TestedComponent , {
2021-11-15 15:18:58 +01:00
transaction : { . . . exampleData . tip , pending : true } ,
2021-06-03 06:07:29 +02:00
} ) ;
2021-06-21 01:37:35 +02:00
export const Refund = createExample ( TestedComponent , {
2021-11-15 15:18:58 +01:00
transaction : exampleData.refund ,
2021-06-03 06:07:29 +02:00
} ) ;
2021-06-28 16:38:29 +02:00
export const RefundError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . refund ,
2021-11-15 15:18:58 +01:00
error : transactionError ,
2021-06-28 16:38:29 +02:00
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const RefundPending = createExample ( TestedComponent , {
2021-11-15 15:18:58 +01:00
transaction : { . . . exampleData . refund , pending : true } ,
2021-06-03 06:07:29 +02:00
} ) ;