Skip to content

test: Unit & integration tests for PawaPayGateway #49

Description

@teesofttech

Overview

Add a complete unit and integration test suite for PawaPayGateway.

Gateway Details

  • Class: PawaPayGateway
  • Region: Africa mobile money — Ghana, Tanzania, Uganda, Rwanda, Zambia, DRC, Cameroon, Ivory Coast, etc.
  • Networks: MTN MoMo, Airtel Money, M-Pesa, Orange Money, Tigo Pesa, Vodacom
  • Auth: Bearer token (ApiToken)
  • Sandbox URL: https://api.sandbox.pawapay.io
  • Live URL: https://api.pawapay.io
  • Tx Ref prefix: PP_
  • Config: ApiToken, IsSandbox
  • Enum: PaymentGatewayType.PawaPay = 14

Unit Tests (mocked HTTP)

Constructor

  • Throws ArgumentNullException when config is null
  • Uses sandbox URL when IsSandbox=true
  • Uses live URL when IsSandbox=false

CreatePaymentAsync

  • Posts to /deposits with correct payload (depositId, amount, currency, correspondent, payer.type, payer.address.value, statementDescription)
  • Sets Authorization: Bearer header
  • Tx reference starts with PP_
  • Returns PaymentResponse.Success=true on status=ACCEPTED
  • Returns PaymentResponse.Success=false on DUPLICATE_IGNORED or REJECTED

VerifyPaymentAsync

  • Sends GET /deposits/{depositId}
  • Returns IsSuccessful=true when status=COMPLETED
  • Returns IsSuccessful=false for FAILED or TIMED_OUT

RefundPaymentAsync

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

Integration Tests

Requires PAWAPAY_API_TOKEN env var (sandbox token)

  • CreatePaymentAsync returns ACCEPTED status with depositId
  • VerifyPaymentAsync returns correct status for a sandbox deposit

Files to Create

  • PayBridge.SDK.Test/Unit/PawaPayGatewayTests.cs
  • PayBridge.SDK.Test/Integration/PawaPayIntegrationTests.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 PawaPayGateway.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