Skip to content

test: Unit & integration tests for KorapayGateway #44

Description

@teesofttech

Overview

Add a complete unit and integration test suite for KorapayGateway.

Gateway Details

  • Class: KorapayGateway
  • Region: Nigeria / Africa
  • Auth: Bearer token (SecretKey)
  • Base URL: https://api.korapay.com/merchant/api/v1/
  • Tx Ref prefix: KR_ (from GatewayReferencePrefixes.Korapay)
  • Enum: PaymentGatewayType.Korapay = 9

Unit Tests (mocked HTTP)

Constructor

CreatePaymentAsync

  • Posts to /charges/initialize with correct payload (reference, amount, currency, customer.email, redirect_url)
  • Reference starts with KR_
  • Returns PaymentResponse.Success=true with CheckoutUrl (data.checkout_url) on success
  • Returns PaymentResponse.Success=false when data.status=false

VerifyPaymentAsync

  • Sends GET /charges/{reference}
  • Returns IsSuccessful=true when data.status=success
  • Returns IsSuccessful=false for failed/processing

RefundPaymentAsync

  • Posts to /refunds with correct payload
  • Returns RefundResponse.IsSuccessful=true on success

GatewayExtractor Tests

  • DetectGatewayFromWebhook returns PaymentGatewayType.Korapay when reference starts with KR_

Integration Tests

Requires KORAPAY_SECRET_KEY env var

  • CreatePaymentAsync returns a real Korapay checkout URL

Files to Create

  • PayBridge.SDK.Test/Unit/KorapayGatewayTests.cs
  • PayBridge.SDK.Test/Integration/KorapayIntegrationTests.cs

Acceptance Criteria

  • All unit tests pass with zero live HTTP calls
  • Integration tests use [Trait("Category", "Integration")] and skip when env var is absent
  • Code coverage >= 80% for KorapayGateway.cs

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: gatewaysPayment gateway integrations and provider behaviorarea: testingAutomated test architecture and coveragepriority: P1High priority; should be addressed nexttestingTest coverage and test suite work

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions