Skip to content

Commit

Permalink
pending_payment: convert js to ts
Browse files Browse the repository at this point in the history
Create a pending_payment.ts model from the pending_payment.js model.
  • Loading branch information
Mersho committed Sep 6, 2023
1 parent bddcb7e commit 4b8910b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 26 deletions.
26 changes: 0 additions & 26 deletions models/pending_payment.js

This file was deleted.

43 changes: 43 additions & 0 deletions models/pending_payment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import mongoose, { Document, Schema } from 'mongoose';

export interface IPendingPayment extends Document {
description: string;
amount: number;
attempts: number;
paid: boolean;
is_invoice_expired: boolean;
payment_request: string;
hash: string;
created_at: Date;
paid_at: Date;
user_id: string;
order_id: string;
community_id: string;
}


const PendingPaymentSchema = new Schema<IPendingPayment>({
description: { type: String },
amount: {
// amount in satoshis
type: Number,
min: [1, 'Minimum amount is 1 sat'],
validate: {
validator: Number.isInteger,
message: '{VALUE} is not an integer value',
},
},
attempts: { type: Number, min: 0, default: 0 },
paid: { type: Boolean, default: false },
is_invoice_expired: { type: Boolean, default: false },
payment_request: { type: String },
hash: { type: String },
created_at: { type: Date, default: Date.now },
paid_at: { type: Date },
user_id: { type: String },
order_id: { type: String },
community_id: { type: String },
});


module.exports = mongoose.model<IPendingPayment>('PendingPayment', PendingPaymentSchema);

0 comments on commit 4b8910b

Please sign in to comment.