Store PayU payment metadata and attempts
All checks were successful
build-and-deploy / build-deploy (push) Successful in 37s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 37s
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.android.trisolarisserver.config
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class PaymentSchemaFix(
|
||||
private val jdbcTemplate: JdbcTemplate
|
||||
) : PostgresSchemaFix(jdbcTemplate) {
|
||||
|
||||
override fun runPostgres(jdbcTemplate: JdbcTemplate) {
|
||||
ensureColumn("payment", "gateway_payment_id", "varchar")
|
||||
ensureColumn("payment", "gateway_txn_id", "varchar")
|
||||
ensureColumn("payment", "bank_ref_num", "varchar")
|
||||
ensureColumn("payment", "mode", "varchar")
|
||||
ensureColumn("payment", "pg_type", "varchar")
|
||||
ensureColumn("payment", "payer_vpa", "varchar")
|
||||
ensureColumn("payment", "payer_name", "varchar")
|
||||
ensureColumn("payment", "payment_source", "varchar")
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.android.trisolarisserver.config
|
||||
|
||||
import org.springframework.jdbc.core.JdbcTemplate
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class PayuPaymentAttemptSchemaFix(
|
||||
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_attempt'
|
||||
""".trimIndent(),
|
||||
Int::class.java
|
||||
) ?: 0
|
||||
if (hasTable == 0) {
|
||||
logger.info("Creating payu_payment_attempt table")
|
||||
jdbcTemplate.execute(
|
||||
"""
|
||||
create table payu_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,
|
||||
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,
|
||||
payload text,
|
||||
received_at timestamptz not null
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user