Paytrail
npm package for Paytrail payment API
Installation
npm i paytrail
Usage
Payment creation
const data = await paytrail// Save paymentres // Redirect user to the payment page
paymentInfo
should be valid data (see. mockPaymentInfo.js
and Paytrail docs for more info)
Error handling
Use try...catch
statement to handle errors
try const data = await paytrail res catch err console res
You can also use validateData
function to check if your data is valid before calling createPayment
. Beware, there still might be errors since validateData
isn't exhaustive and there might be other errors.
Payment confirmation
After successful payment user is redirected to url defined in paymentInfo (urlSet.success)
app
Examples
See tests/tests.js
and tests/exampleServer.js