Skip to content

Commit 721552c

Browse files
committed
Add Razorpay payment integration - complete implementation
1 parent 0b1997c commit 721552c

File tree

14 files changed

+1230
-0
lines changed

14 files changed

+1230
-0
lines changed

.DS_Store

8 KB
Binary file not shown.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""Add payment models
2+
3+
Revision ID: 7c4cf1d2308a
4+
Revises: 1a31ce608336
5+
Create Date: 2024-11-02 12:10:28.000000
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import postgresql
11+
import sqlmodel.sql.sqltypes
12+
13+
# revision identifiers, used by Alembic.
14+
revision = '7c4cf1d2308a'
15+
down_revision = '1a31ce608336'
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.create_table('order',
23+
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
24+
sa.Column('amount', sa.Numeric(precision=19, scale=2), nullable=False),
25+
sa.Column('currency', sa.String(length=3), nullable=False),
26+
sa.Column('receipt', sa.String(length=255), nullable=True),
27+
sa.Column('notes', postgresql.JSON(astext_type=sa.Text()), nullable=True),
28+
sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
29+
sa.Column('razorpay_order_id', sa.String(length=255), nullable=False),
30+
sa.Column('status', sa.String(length=50), nullable=False),
31+
sa.Column('created_at', sa.DateTime(), nullable=False),
32+
sa.Column('updated_at', sa.DateTime(), nullable=False),
33+
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
34+
sa.PrimaryKeyConstraint('id')
35+
)
36+
op.create_index(op.f('ix_order_razorpay_order_id'), 'order', ['razorpay_order_id'], unique=True)
37+
op.create_table('payment',
38+
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
39+
sa.Column('order_id', postgresql.UUID(as_uuid=True), nullable=False),
40+
sa.Column('razorpay_payment_id', sa.String(length=255), nullable=False),
41+
sa.Column('razorpay_signature', sa.String(length=500), nullable=True),
42+
sa.Column('status', sa.String(length=50), nullable=False),
43+
sa.Column('amount', sa.Numeric(precision=19, scale=2), nullable=False),
44+
sa.Column('currency', sa.String(length=3), nullable=False),
45+
sa.Column('method', sa.String(length=50), nullable=True),
46+
sa.Column('created_at', sa.DateTime(), nullable=False),
47+
sa.ForeignKeyConstraint(['order_id'], ['order.id'], ondelete='CASCADE'),
48+
sa.PrimaryKeyConstraint('id')
49+
)
50+
op.create_index(op.f('ix_payment_razorpay_payment_id'), 'payment', ['razorpay_payment_id'], unique=True)
51+
# ### end Alembic commands ###
52+
53+
54+
def downgrade():
55+
# ### commands auto generated by Alembic - please adjust! ###
56+
op.drop_index(op.f('ix_payment_razorpay_payment_id'), table_name='payment')
57+
op.drop_table('payment')
58+
op.drop_index(op.f('ix_order_razorpay_order_id'), table_name='order')
59+
op.drop_table('order')
60+
# ### end Alembic commands ###
61+

0 commit comments

Comments
 (0)