-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from XYOracleNetwork/feature/payment-receipts
Payment Receipts
- Loading branch information
Showing
5 changed files
with
102 additions
and
8 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 |
---|---|---|
@@ -1,22 +1,42 @@ | ||
import { Hash } from '@xylabs/hex' | ||
import { PayloadWithSources } from '@xyo-network/payload-model' | ||
import { | ||
isPayloadOfSchemaType, | ||
isPayloadOfSchemaTypeWithMeta, | ||
isPayloadOfSchemaTypeWithSources, | ||
PayloadWithSources, | ||
} from '@xyo-network/payload-model' | ||
|
||
export type PurchaseSchema = 'network.xyo.payments.purchase' | ||
export const PurchaseSchema: PurchaseSchema = 'network.xyo.payments.purchase' | ||
|
||
export interface PurchaseFields { | ||
/** | ||
* The hashes that were purchased | ||
* The things that were purchased | ||
*/ | ||
hashes: Hash[] | ||
assets: Hash[] | ||
/** | ||
* The payments for this purchase. Array to allow for multiple payments | ||
* The receipts for payments for this purchase. Array to allow for multiple payments | ||
* for a single quote. | ||
*/ | ||
payments: Hash[] | ||
receipts: Hash[] | ||
} | ||
|
||
/** | ||
* A purchase ties a payment made to a quote | ||
*/ | ||
export type Purchase = PayloadWithSources<PurchaseFields, PurchaseSchema> | ||
|
||
/** | ||
* Identity function for determine if an object is a Purchase | ||
*/ | ||
export const isPurchase = isPayloadOfSchemaType<Purchase>(PurchaseSchema) | ||
|
||
/** | ||
* Identity function for determine if an object is a Purchase with sources | ||
*/ | ||
export const isPurchaseWithSources = isPayloadOfSchemaTypeWithSources<Purchase>(PurchaseSchema) | ||
|
||
/** | ||
* Identity function for determine if an object is a Purchase with meta | ||
*/ | ||
export const isPurchaseWithMeta = isPayloadOfSchemaTypeWithMeta<Purchase>(PurchaseSchema) |
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,42 @@ | ||
import { | ||
isPayloadOfSchemaType, | ||
isPayloadOfSchemaTypeWithMeta, | ||
isPayloadOfSchemaTypeWithSources, | ||
PayloadWithSources, | ||
} from '@xyo-network/payload-model' | ||
|
||
import { SupportedCurrency } from './Currency' | ||
|
||
export type ReceiptSchema = 'network.xyo.payments.receipt' | ||
export const ReceiptSchema: ReceiptSchema = 'network.xyo.payments.receipt' | ||
|
||
export interface ReceiptFields { | ||
/** | ||
* The amount paid | ||
*/ | ||
amount: number | ||
/** | ||
* The currency of the amount paid | ||
*/ | ||
currency: SupportedCurrency | ||
} | ||
|
||
/** | ||
* A receipt is a record of a payment made | ||
*/ | ||
export type Receipt = PayloadWithSources<ReceiptFields, ReceiptSchema> | ||
|
||
/** | ||
* Identity function for determine if an object is a Receipt | ||
*/ | ||
export const isReceipt = isPayloadOfSchemaType<Receipt>(ReceiptSchema) | ||
|
||
/** | ||
* Identity function for determine if an object is a Receipt with sources | ||
*/ | ||
export const isReceiptWithSources = isPayloadOfSchemaTypeWithSources<Receipt>(ReceiptSchema) | ||
|
||
/** | ||
* Identity function for determine if an object is a Receipt with meta | ||
*/ | ||
export const isReceiptWithMeta = isPayloadOfSchemaTypeWithMeta<Receipt>(ReceiptSchema) |
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