# jetiffy-payment-services-shared-functions

> **HOW TO TEST**

Latest version **1.0.12** (published 2021-05-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install jetiffy-payment-services-shared-functions
pnpm add jetiffy-payment-services-shared-functions
yarn add jetiffy-payment-services-shared-functions
bun add jetiffy-payment-services-shared-functions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2021-05-08 |
| First published | 2021-03-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 (+27 in 3 direct dependencies) |
| Install scripts | no |
| Maintainers | jetiffydev, cjay91 |

## Links

- npm: https://www.npmjs.com/package/jetiffy-payment-services-shared-functions
- Repository: https://github.com/peterugah/jetiffy-payment-services-shared-functions
- Homepage: https://github.com/peterugah/jetiffy-payment-services-shared-functions#readme
- Issues: https://github.com/peterugah/jetiffy-payment-services-shared-functions/issues
- npm.io page: https://npm.io/package/jetiffy-payment-services-shared-functions

## Dependencies (4)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [axios](https://npm.io/package/axios.md) ^0.21.1
- [mongoose](https://npm.io/package/mongoose.md) ^5.12.2
- [dotenv-json](https://npm.io/package/dotenv-json.md) ^1.0.0

## Recent versions

- 1.0.12 (latest) — 2021-05-08
- 1.0.11 — 2021-04-13
- 1.0.10 — 2021-04-13
- 1.0.9 — 2021-04-12
- 1.0.8 — 2021-04-12
- 1.0.7 — 2021-04-06
- 1.0.6 — 2021-03-29
- 1.0.5 — 2021-03-29
- 1.0.4 — 2021-03-28
- 1.0.3 — 2021-03-25
- 1.0.2 — 2021-03-24
- 1.0.1 — 2021-03-24
- 1.0.0 — 2021-03-24

## 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": "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**

---
_Source: https://npm.io/package/jetiffy-payment-services-shared-functions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
