hngprojects / hng_boilerplate_expressjs

75 stars 85 forks source link

[FEAT] Plan subscription - PAYSTACK #523

Open Uzo-Felix opened 2 months ago

Uzo-Felix commented 2 months ago

Payment Functionality Implementation using Paystack

Description

Implement payment functionality using Paystack to allow both individual users and organizations to make payments through our platform. This feature will handle the entire payment process, including initiating and processing payments.

Acceptance Criteria

Request Examples

POST /api/v1/payments/paystack [PROTECTED]

Request Body:

{
   "organization_id": "string",
   "plan_id": "string",
   "full_name": "string",
   "billing_option": "monthly | yearly",
   "redirect_url": "http://boilerplate.com/setting"
}

Response Examples

Success Response

Status Code: 200 OK

{
   "status": 200,
   "message": "Payment initiated successfully",
   "data": {
      "payment_url": "https://example.com/checkout?paymentId=pay_abc123"
   }
}

Failure Responses

  1. Validation Error

    • Status Code: 400 Bad Request
      {
      "status": 400,
      "message": "Validation error: amount must be a positive number"
      }
  2. Authentication Error

    • Status Code: 401 Unauthorized
      {
      "status": 401,
      "message": "Authentication required"
      }
  3. Authorization Error

    • Status Code: 403 Forbidden
      {
      "status": 403,
      "message": "You do not have permission to initiate this payment"
      }
  4. Server Error

    • Status Code: 500 Internal Server Error
      {
      "status": 500,
      "message": "An unexpected error occurred. Please try again later."
      }

Data Validation

Input Validation

Authentication and Authorization

Authentication

Authorization

Error Handling

Error Responses

Documentation

API Documentation

Testing Requirements

Unit Tests

Integration Tests