1.0.12 • Published 3 years ago

jetiffy-payment-services-shared-functions v1.0.12

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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": "customer@email.com", "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

1.0.12

3 years ago

1.0.11

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.10

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago