Last active
May 7, 2024 06:09
-
-
Save mbmohib/5f08b90dd6349e0695ad63d4bfacbc19 to your computer and use it in GitHub Desktop.
SSL Commerz API Issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Init Order | |
async initOrder( | |
user: User, | |
transactionId: string, | |
price: number, | |
name: string, | |
) { | |
const data = { | |
total_amount: price, | |
currency: 'BDT', | |
tran_id: transactionId, // use unique tran_id for each api call | |
success_url: `http://localhost:8000/transactions/payment/success/${transactionId}`, | |
fail_url: `http://localhost:8000/transactions/payment/fail/${transactionId}`, | |
cancel_url: `http://localhost:8000/transactions/payment/cancel/${transactionId}`, | |
ipn_url: `http://localhost:8000/transactions/payment/ipn`, | |
shipping_method: 'Courier', | |
product_name: name, | |
product_category: 'Electronic', | |
product_profile: 'general', | |
cus_name: user.name, | |
cus_email: user.email, | |
cus_add1: 'Dhaka', | |
cus_add2: 'Dhaka', | |
cus_city: 'Dhaka', | |
cus_state: 'Dhaka', | |
cus_postcode: '1000', | |
cus_country: 'Bangladesh', | |
cus_phone: user.phone, | |
cus_fax: '01711111111', | |
ship_name: user.name, | |
ship_add1: 'Dhaka', | |
ship_add2: 'Dhaka', | |
ship_city: 'Dhaka', | |
ship_state: 'Dhaka', | |
ship_postcode: 1000, | |
ship_country: 'Bangladesh', | |
}; | |
const sslcz = new SSLCommerzPayment(store_id, store_passwd, is_live); | |
const apiResponse = await sslcz.init(data); | |
return apiResponse; | |
} | |
// IPN api endpoint (nest js) | |
// https://docs.nestjs.com/controllers | |
@Post('payment/ipn') | |
async paymentIpn(@Res() res, @Query() query) { | |
console.log('query :>> ', query); | |
return res.redirect('http://localhost:4002/payment/processing'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment