feat: Refactor AlchemyController's callback function for usability and clarity.
- Add constant and callback URL to AlchemyController for Alchemy Pay - Improve parameter validations and error handling in `alchemyCallback` function - Remove unused variable `redirectUrl` in AlchemyController - Update `.env.development` with Alchemy Pay callback URL
This commit is contained in:
parent
6ede0fd01a
commit
c3f81a825f
@ -15,3 +15,4 @@ ALCHEMY_APPID="f83Is2y7L425rxl8"
|
|||||||
ALCHEMY_APP_SECRET="4Yn8RkxDXN71Q3p0"
|
ALCHEMY_APP_SECRET="4Yn8RkxDXN71Q3p0"
|
||||||
ALCHEMY_API_BASE="https://openapi-test.alchemypay.org"
|
ALCHEMY_API_BASE="https://openapi-test.alchemypay.org"
|
||||||
ALCHEMY_PAGE_BASE="https://ramptest.alchemypay.org"
|
ALCHEMY_PAGE_BASE="https://ramptest.alchemypay.org"
|
||||||
|
ALCHEMY_PAY_CB_URL="https://wallet.cebg.games"
|
||||||
|
@ -6,6 +6,7 @@ import { checkPayResultSign, createPageSign, refreshToken } from 'service/alchem
|
|||||||
import { generateKVStr } from 'utils/net.util'
|
import { generateKVStr } from 'utils/net.util'
|
||||||
import { PayRecord, PayStatus } from 'modules/PayRecord'
|
import { PayRecord, PayStatus } from 'modules/PayRecord'
|
||||||
|
|
||||||
|
const CALL_BACK_URL = `${process.env.ALCHEMY_PAY_CB_URL}/pay/alchemy/cb`
|
||||||
class AlchemyController extends BaseController {
|
class AlchemyController extends BaseController {
|
||||||
@router('post /pay/alchemy/buy')
|
@router('post /pay/alchemy/buy')
|
||||||
async beginPay(req, res) {
|
async beginPay(req, res) {
|
||||||
@ -19,7 +20,6 @@ class AlchemyController extends BaseController {
|
|||||||
}
|
}
|
||||||
const { id, email, accessToken } = tokenResult.data
|
const { id, email, accessToken } = tokenResult.data
|
||||||
const redirectUrl = ''
|
const redirectUrl = ''
|
||||||
const callbackUrl = ''
|
|
||||||
let record = new PayRecord({ account: user.id, address, chain, currency })
|
let record = new PayRecord({ account: user.id, address, chain, currency })
|
||||||
await record.save()
|
await record.save()
|
||||||
const merchantOrderNo = record.id
|
const merchantOrderNo = record.id
|
||||||
@ -29,6 +29,7 @@ class AlchemyController extends BaseController {
|
|||||||
id,
|
id,
|
||||||
showTable: 'buy',
|
showTable: 'buy',
|
||||||
merchantOrderNo,
|
merchantOrderNo,
|
||||||
|
callbackUrl: CALL_BACK_URL,
|
||||||
}
|
}
|
||||||
if (chain) dataOrign.network = chain
|
if (chain) dataOrign.network = chain
|
||||||
if (currency) dataOrign.crypto = currency
|
if (currency) dataOrign.crypto = currency
|
||||||
|
Loading…
x
Reference in New Issue
Block a user