-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2dd54b
commit 5bded72
Showing
18 changed files
with
216 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface InvoiceRefundAddresses { | ||
type: string; | ||
date: string; | ||
tag?: number; | ||
email?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {z} from "zod"; | ||
|
||
export const invoiceRefundAddressesSchema = z.object({ | ||
type: z.string(), | ||
date: z.string(), | ||
tag: z.number().optional().nullable(), | ||
email: z.string().optional().nullable(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { z } from 'zod'; | ||
|
||
export const invoiceWebhookBuyerFieldsInterfaceSchema = z.object({ | ||
buyerName: z.string().optional(), | ||
buyerAddress1: z.string().optional(), | ||
buyerAddress2: z.string().optional(), | ||
buyerCity: z.string().optional(), | ||
buyerState: z.string().optional(), | ||
buyerZip: z.string().optional(), | ||
buyerCountry: z.string().optional(), | ||
buyerPhone: z.string().optional(), | ||
buyerNotify: z.boolean().optional(), | ||
buyerEmail: z.string().optional() | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {BuyerFields} from "../Ledger/BuyerFields"; | ||
import {InvoiceWebhookBuyerFields} from "./InvoiceWebhookBuyerFields"; | ||
|
||
export interface InvoiceWebhook { | ||
id?: string; | ||
url?: string; | ||
posData?: string; | ||
status?: string; | ||
price?: string; | ||
currency?: string; | ||
invoiceTime?: string; | ||
currencyTime?: string; | ||
exceptionStatus?: string; | ||
buyerFields?: InvoiceWebhookBuyerFields; | ||
paymentSubtotals?: Record<string, number>; | ||
paymentTotals?: Record<string, number>; | ||
exchangeRates?: Record<string, Record<string, number>>; | ||
amountPaid?: number; | ||
orderId?: string; | ||
transactionCurrency?: string; | ||
inInvoiceId?: string; | ||
inPaymentRequest?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { z } from 'zod'; | ||
import {invoiceWebhookBuyerFieldsInterfaceSchema} from "./InvoiceBuyerFields.zod"; | ||
|
||
export const invoiceWebhookSchema = z.object({ | ||
id: z.string().optional(), | ||
url: z.string().optional(), | ||
posData: z.string().optional(), | ||
status: z.string().optional(), | ||
price: z.string().optional(), | ||
currency: z.string().optional(), | ||
invoiceTime: z.string().optional(), | ||
currencyTime: z.string().optional(), | ||
exceptionStatus: z.string().optional(), | ||
buyerFields: invoiceWebhookBuyerFieldsInterfaceSchema.optional(), | ||
paymentSubtotals: z.record(z.number()).nullable(), | ||
paymentTotals: z.record(z.number()).nullable(), | ||
exchangeRates: z.record(z.record(z.number())).nullable(), | ||
amountPaid: z.number().optional(), | ||
orderId: z.string().optional(), | ||
transactionCurrency: z.string().optional(), | ||
inInvoiceId: z.string().optional(), | ||
inPaymentRequest: z.string().optional(), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export interface InvoiceWebhookBuyerFieldsInterface { | ||
buyerName?: string; | ||
buyerAddress1?: string; | ||
buyerAddress2?: string; | ||
buyerCity?: string; | ||
buyerState?: string; | ||
buyerZip?: string; | ||
buyerCountry?: string; | ||
buyerPhone?: string; | ||
buyerNotify?: boolean; | ||
buyerEmail?: string; | ||
} | ||
|
||
export class InvoiceWebhookBuyerFields implements InvoiceWebhookBuyerFieldsInterface { | ||
buyerName?: string; | ||
buyerAddress1?: string; | ||
buyerAddress2?: string; | ||
buyerCity?: string; | ||
buyerState?: string; | ||
buyerZip?: string; | ||
buyerCountry?: string; | ||
buyerPhone?: string; | ||
buyerNotify?: boolean; | ||
buyerEmail?: string; | ||
|
||
public constructor() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {PayoutTransaction} from "../Payout/PayoutTransaction"; | ||
|
||
export interface PayoutWebhookInterface { | ||
id?: string; | ||
recipientId?: string; | ||
shopperId?: string; | ||
price?: number; | ||
currency?: string; | ||
ledgerCurrency?: string; | ||
exchangeRates?: Record<string, Record<string, number>>; | ||
email?: string; | ||
reference?: string; | ||
label?: string; | ||
notificationUrl?: string; | ||
notificationEmail?: string; | ||
effectiveDate?: string; | ||
requestDate?: string; | ||
status?: string; | ||
transactions?: PayoutTransaction[]; | ||
accountId?: string; | ||
date?: string; | ||
groupId?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { z } from 'zod'; | ||
import {payoutTransactionInterfaceSchema} from "../Payout/PayoutTransaction.zod"; | ||
|
||
export const payoutWebhookSchema = z.object({ | ||
id: z.string().optional(), | ||
recipientId: z.string().optional(), | ||
shopperId: z.string().optional(), | ||
price: z.number().optional(), | ||
currency: z.string().optional(), | ||
ledgerCurrency: z.string().optional(), | ||
exchangeRates: z.record(z.record(z.number())).optional(), | ||
email: z.string().optional(), | ||
reference: z.string().optional(), | ||
label: z.string().optional(), | ||
notificationUrl: z.string().optional(), | ||
notificationEmail: z.string().optional(), | ||
effectiveDate: z.string().optional(), | ||
requestDate: z.string().optional(), | ||
status: z.string().optional(), | ||
transactions: z.array(payoutTransactionInterfaceSchema).optional(), | ||
accountId: z.string().optional(), | ||
date: z.string().optional(), | ||
groupId: z.string().optional(), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface RefundWebhook { | ||
amount?: number; | ||
buyerPaysRefundFee?: boolean; | ||
currency?: string; | ||
id?: string; | ||
immediate?: boolean; | ||
invoice?: string; | ||
lastRefundNotification?: string; | ||
refundFee?: number; | ||
requestDate?: string; | ||
status?: string; | ||
supportRequest?: string; | ||
reference?: string; | ||
guid?: string; | ||
refundAddress?: string; | ||
type?: string; | ||
txid?: string; | ||
transactionCurrency?: string; | ||
transactionAmount?: number; | ||
transactionRefundFee?: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { z } from 'zod'; | ||
|
||
export const refundWebhookSchema = z.object({ | ||
amount: z.number().nullable(), | ||
buyerPaysRefundFee: z.boolean().nullable(), | ||
currency: z.string().nullable(), | ||
id: z.string().nullable(), | ||
immediate: z.boolean().nullable(), | ||
invoice: z.string().nullable(), | ||
lastRefundNotification: z.string().nullable(), | ||
refundFee: z.number().nullable(), | ||
requestDate: z.string().nullable(), | ||
status: z.string().nullable(), | ||
supportRequest: z.string().nullable(), | ||
reference: z.string().nullable(), | ||
guid: z.string().nullable(), | ||
refundAddress: z.string().nullable(), | ||
type: z.string().nullable(), | ||
txid: z.string().nullable(), | ||
transactionCurrency: z.string().nullable(), | ||
transactionAmount: z.number().nullable(), | ||
transactionRefundFee: z.number().nullable(), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -525,6 +525,7 @@ describe('BitPaySDK.Client', () => { | |
expect(result.url).toBe('https://bitpay.com/invoice?id=G3viJEJgE8Jk2oekSdgT2A'); | ||
expect(result.buyerProvidedInfo.emailAddress).toBe('[email protected]'); | ||
expect(result.universalCodes.paymentString).toBe('https://link.bitpay.com/i/G3viJEJgE8Jk2oekSdgT2A'); | ||
expect(result.refundAddresses[0].n2MDYgEhxCAnuoVd1JpPmvxZShE6rQA6zv.type).toBe("buyerSupplied") | ||
}); | ||
|
||
it('should get invoice', async () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,15 @@ | |
"redirectURL": "https://merchantwebsite.com/shop/return", | ||
"autoRedirect": false, | ||
"closeURL": "https://merchantwebsite.com/shop/cancel", | ||
"refundAddresses": [], | ||
"refundAddresses": [ | ||
{ | ||
"n2MDYgEhxCAnuoVd1JpPmvxZShE6rQA6zv": { | ||
"type": "buyerSupplied", | ||
"date": "2024-01-08T23:50:56.556Z", | ||
"email": "[email protected]" | ||
} | ||
} | ||
], | ||
"refundAddressRequestPending": false, | ||
"buyerProvidedEmail": "[email protected]", | ||
"buyerProvidedInfo": { | ||
|