jetiffy-payment-services-shared-functions
v1.0.12
Published
**HOW TO TEST**
Downloads
14
Readme
PAYSTACK
HOW TO TEST
- make a POST request to https://api.paystack.co/transaction/initialize
- pass the Authorization header as :
Authorization : Bearer sk_test_f37d04c1c6eac6ad4239a04abc149ee126cd38e4
- body Object:
{ "email": "[email protected]", "amount": "20000" }
- a custom checkout link will be generated from the response that you can use to execute the transaction on paystack's checkout page. Sample response:
{
"status": true,
"message": "Authorization URL created",
"data": {
"authorization_url": "https://checkout.paystack.com/h05joqiw6vgze2v",
"access_code": "h05joqiw6vgze2v",
"reference": "v7o6mscp25"
}
}
- click on the authorization_url and perform a payment, you can then verify later.
VERIFY TRANSACTION SHARED FUNCTION
- ensure the following environment variables are set in the serverless.env.json file for the service
- PAYSTACK_BASE_URL : https://api.paystack.co
- PAYSTACK_SECRET_KEY :
use the test secret key for dev
- call the paystack.verify(referenceId). the reference id will be sent from the frontend to verify a transaction Success Response Object
{
success: true
message : "a message describing the success flag. this can be sent to the client as a response"
data : {
amount: 20000,
fee: 300,
currency: "NGN",
reference: "qdats89k8y",
}
}
Error Response Object 1
{
success: false
message : "a message describing the failure flag. this can be sent to the client as a response"
data : {
amount: 20000,
fee: null,
currency: "NGN",
reference: "qdats89k8y",
}
}
Success Response Object 2
{
success: false
message : "a message describing the failure flag. this can be sent to the client as a response"
}
NOTES
- depending on the error code, the error response might return a data or not. the key property is the success flag. once false simply return a custom error message or the message property to the client
- the amount property can be used to verify the transaction amount against what was supplied from the frontend, after which the users wallet will be credited with the amount.
- always save the referenceId on the wallet history and also the fundingType. e.g paystack, flutterwave, providusVirtualAccount. this should be enums that will be allowed on the wallet history.
FLUTTERWAVE
VERIFY TRANSACTION SHARED FUNCTION
- ensure the following environment variables are set in the serverless.env.json file for the service
- FLUTTERWAVE_BASE_URL : https://api.flutterwave.com
- FLUTTERWAVE_SECRET_KEY :
use the test secret key for dev
- call the flutterwave.verify(referenceId). the reference id will be sent from the frontend to verify a transaction
THE SAME PROCESS APPLIES FOR SUCCESS AND ERROR RESPONSES