Replace PayU integration with Razorpay
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s

This commit is contained in:
androidlover5842
2026-02-01 09:44:57 +05:30
parent 93ac0dbc9e
commit ebaef53f98
38 changed files with 935 additions and 1421 deletions

View File

@@ -1,61 +0,0 @@
package com.android.trisolarisserver.config
import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Component
@Component
class PayuPaymentLinkSettingsSchemaFix(
private val jdbcTemplate: JdbcTemplate
) : PostgresSchemaFix(jdbcTemplate) {
override fun runPostgres(jdbcTemplate: JdbcTemplate) {
val hasTable = jdbcTemplate.queryForObject(
"""
select count(*)
from information_schema.tables
where table_name = 'payu_payment_link_settings'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasTable == 0) {
logger.info("Creating payu_payment_link_settings table")
jdbcTemplate.execute(
"""
create table payu_payment_link_settings (
id uuid primary key,
property_id uuid not null unique references property(id) on delete cascade,
merchant_id text not null,
client_id text,
client_secret text,
access_token text,
token_expires_at timestamptz,
is_test boolean not null default false,
updated_at timestamptz not null
)
""".trimIndent()
)
}
ensureColumn("payu_payment_link_settings", "client_id", "text")
ensureColumn("payu_payment_link_settings", "client_secret", "text")
ensureColumn("payu_payment_link_settings", "access_token", "text")
ensureColumn("payu_payment_link_settings", "token_expires_at", "timestamptz")
jdbcTemplate.execute("alter table payu_payment_link_settings alter column access_token drop not null")
}
private fun ensureColumn(table: String, column: String, type: String) {
val exists = jdbcTemplate.queryForObject(
"""
select count(*)
from information_schema.columns
where table_name = '$table'
and column_name = '$column'
""".trimIndent(),
Int::class.java
) ?: 0
if (exists == 0) {
logger.info("Adding $table.$column column")
jdbcTemplate.execute("alter table $table add column $column $type")
}
}
}

View File

@@ -1,58 +0,0 @@
package com.android.trisolarisserver.config
import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Component
@Component
class PayuSettingsSchemaFix(
private val jdbcTemplate: JdbcTemplate
) : PostgresSchemaFix(jdbcTemplate) {
override fun runPostgres(jdbcTemplate: JdbcTemplate) {
val hasTable = jdbcTemplate.queryForObject(
"""
select count(*)
from information_schema.tables
where table_name = 'payu_settings'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasTable == 0) {
logger.info("Creating payu_settings table")
jdbcTemplate.execute(
"""
create table payu_settings (
id uuid primary key,
property_id uuid not null unique references property(id) on delete cascade,
merchant_key varchar not null,
salt_32 varchar,
salt_256 varchar,
base_url varchar not null,
is_test boolean not null default false,
use_salt_256 boolean not null default true,
updated_at timestamptz not null
)
""".trimIndent()
)
}
val hasIsTest = jdbcTemplate.queryForObject(
"""
select count(*)
from information_schema.columns
where table_name = 'payu_settings'
and column_name = 'is_test'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasIsTest == 0) {
logger.info("Adding payu_settings.is_test column")
jdbcTemplate.execute("alter table payu_settings add column is_test boolean not null default false")
}
logger.info("Ensuring payu_settings text column sizes")
jdbcTemplate.execute("alter table payu_settings alter column merchant_key type text")
jdbcTemplate.execute("alter table payu_settings alter column salt_32 type text")
jdbcTemplate.execute("alter table payu_settings alter column salt_256 type text")
jdbcTemplate.execute("alter table payu_settings alter column base_url type text")
}
}

View File

@@ -4,7 +4,7 @@ import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Component
@Component
class PayuPaymentAttemptSchemaFix(
class RazorpayPaymentAttemptSchemaFix(
private val jdbcTemplate: JdbcTemplate
) : PostgresSchemaFix(jdbcTemplate) {
@@ -13,32 +13,24 @@ class PayuPaymentAttemptSchemaFix(
"""
select count(*)
from information_schema.tables
where table_name = 'payu_payment_attempt'
where table_name = 'razorpay_payment_attempt'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasTable == 0) {
logger.info("Creating payu_payment_attempt table")
logger.info("Creating razorpay_payment_attempt table")
jdbcTemplate.execute(
"""
create table payu_payment_attempt (
create table razorpay_payment_attempt (
id uuid primary key,
property_id uuid not null references property(id) on delete cascade,
booking_id uuid references booking(id) on delete set null,
event varchar,
status varchar,
unmapped_status varchar,
amount bigint,
currency varchar,
gateway_payment_id varchar,
gateway_txn_id varchar,
bank_ref_num varchar,
mode varchar,
pg_type varchar,
payer_vpa varchar,
payer_name varchar,
payment_source varchar,
error_code varchar,
error_message varchar,
payment_id varchar,
order_id varchar,
payload text,
received_at timestamptz not null
)

View File

@@ -0,0 +1,41 @@
package com.android.trisolarisserver.config
import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Component
@Component
class RazorpayPaymentLinkRequestSchemaFix(
private val jdbcTemplate: JdbcTemplate
) : PostgresSchemaFix(jdbcTemplate) {
override fun runPostgres(jdbcTemplate: JdbcTemplate) {
val hasTable = jdbcTemplate.queryForObject(
"""
select count(*)
from information_schema.tables
where table_name = 'razorpay_payment_link_request'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasTable == 0) {
logger.info("Creating razorpay_payment_link_request table")
jdbcTemplate.execute(
"""
create table razorpay_payment_link_request (
id uuid primary key,
property_id uuid not null references property(id) on delete cascade,
booking_id uuid not null references booking(id) on delete cascade,
payment_link_id varchar,
amount bigint not null,
currency varchar not null,
status varchar not null,
short_url text,
request_payload text,
response_payload text,
created_at timestamptz not null
)
""".trimIndent()
)
}
}
}

View File

@@ -4,7 +4,7 @@ import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Component
@Component
class PayuQrRequestSchemaFix(
class RazorpayQrRequestSchemaFix(
private val jdbcTemplate: JdbcTemplate
) : PostgresSchemaFix(jdbcTemplate) {
@@ -13,22 +13,23 @@ class PayuQrRequestSchemaFix(
"""
select count(*)
from information_schema.tables
where table_name = 'payu_qr_request'
where table_name = 'razorpay_qr_request'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasTable == 0) {
logger.info("Creating payu_qr_request table")
logger.info("Creating razorpay_qr_request table")
jdbcTemplate.execute(
"""
create table payu_qr_request (
create table razorpay_qr_request (
id uuid primary key,
property_id uuid not null references property(id) on delete cascade,
booking_id uuid not null references booking(id) on delete cascade,
txnid varchar not null,
qr_id varchar,
amount bigint not null,
currency varchar not null,
status varchar not null,
image_url text,
request_payload text,
response_payload text,
expiry_at timestamptz,
@@ -36,25 +37,6 @@ class PayuQrRequestSchemaFix(
)
""".trimIndent()
)
} else {
val hasExpiryAt = jdbcTemplate.queryForObject(
"""
select count(*)
from information_schema.columns
where table_name = 'payu_qr_request'
and column_name = 'expiry_at'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasExpiryAt == 0) {
logger.info("Adding expiry_at to payu_qr_request table")
jdbcTemplate.execute(
"""
alter table payu_qr_request
add column expiry_at timestamptz
""".trimIndent()
)
}
}
}
}

View File

@@ -0,0 +1,41 @@
package com.android.trisolarisserver.config
import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Component
@Component
class RazorpaySettingsSchemaFix(
private val jdbcTemplate: JdbcTemplate
) : PostgresSchemaFix(jdbcTemplate) {
override fun runPostgres(jdbcTemplate: JdbcTemplate) {
val hasTable = jdbcTemplate.queryForObject(
"""
select count(*)
from information_schema.tables
where table_name = 'razorpay_settings'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasTable == 0) {
logger.info("Creating razorpay_settings table")
jdbcTemplate.execute(
"""
create table razorpay_settings (
id uuid primary key,
property_id uuid not null unique references property(id) on delete cascade,
key_id varchar not null,
key_secret varchar not null,
webhook_secret varchar,
is_test boolean not null default false,
updated_at timestamptz not null
)
""".trimIndent()
)
}
logger.info("Ensuring razorpay_settings text column sizes")
jdbcTemplate.execute("alter table razorpay_settings alter column key_id type text")
jdbcTemplate.execute("alter table razorpay_settings alter column key_secret type text")
jdbcTemplate.execute("alter table razorpay_settings alter column webhook_secret type text")
}
}

View File

@@ -4,7 +4,7 @@ import org.springframework.jdbc.core.JdbcTemplate
import org.springframework.stereotype.Component
@Component
class PayuWebhookLogSchemaFix(
class RazorpayWebhookLogSchemaFix(
private val jdbcTemplate: JdbcTemplate
) : PostgresSchemaFix(jdbcTemplate) {
@@ -13,15 +13,15 @@ class PayuWebhookLogSchemaFix(
"""
select count(*)
from information_schema.tables
where table_name = 'payu_webhook_log'
where table_name = 'razorpay_webhook_log'
""".trimIndent(),
Int::class.java
) ?: 0
if (hasTable == 0) {
logger.info("Creating payu_webhook_log table")
logger.info("Creating razorpay_webhook_log table")
jdbcTemplate.execute(
"""
create table payu_webhook_log (
create table razorpay_webhook_log (
id uuid primary key,
property_id uuid not null references property(id) on delete cascade,
headers text,