Skip to content

Instantly share code, notes, and snippets.

@midoalone
Created September 20, 2022 06:48
Show Gist options
  • Save midoalone/4c2341267a3e76518d9a27fcca949475 to your computer and use it in GitHub Desktop.
Save midoalone/4c2341267a3e76518d9a27fcca949475 to your computer and use it in GitHub Desktop.
export async function createPaymentUrl (total_price, test = false) {
const api = apisauce.create({
baseURL: 'https://api.upayments.com',
headers: {
'Cache-Control': 'no-cache',
'content-type': 'application/json',
},
timeout: 10000,
})
Loader.show()
let request
if(test) {
// Test Mode
request = await api.post('test-payment', {
merchant_id: '1201',
username: 'test',
password: 'test',
api_key: 'jtest123',
order_id: Math.floor(Math.random() * 1000),
total_price,
success_url: `${baseUrl}/payment/confirm`,
error_url: `${baseUrl}/payment/error`,
test_mode: 1,
})
}else{
// Live Mode
request = await api.post('payment-request', {
merchant_id: '7016',
username: 'parknwash',
password: 'aXEmrLDFW}83Pfp',
api_key: '$2y$10$euwN9dESurMN9ynXZvKGS.XoeQr2Wwk6.sGjDYh2TYgjhkn9l/dm2',
order_id: Math.floor(Math.random() * 1000),
total_price,
// total_price: 0.1,
success_url: `${baseUrl}/payment/confirm`,
error_url: `${baseUrl}/payment/error`,
test_mode: 0,
})
}
return request.data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment