Download the PHP package salymdev/moshipay-php without Composer
On this page you can find all versions of the php package salymdev/moshipay-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package moshipay-php
MoshiPay PHP SDK
Production-ready PHP SDK for accepting payments through the MoshiPay payment gateway.
The SDK provides:
- Mobile money payment creation
- Card payment creation with redirect and cancel URLs
- Payment status lookup
- Idempotency support for payment creation
- Webhook signature verification and JSON parsing
- Typed exceptions for validation and API errors
Requirements
- PHP 8.1 or newer
- PHP
curlextension - PHP
jsonextension - Composer
Installation
Configuration
Store credentials in environment variables. Do not hard-code API keys, API secrets, or webhook secrets in source code.
Create a client for sandbox or live payments:
If you need to override the API base URL, instantiate the client directly:
Mobile Money Payments
Card Payments
Generic Payment Payloads
Use createPayment() when you need direct control over the request payload.
Supported payment_type values are mobile_money and card.
Fetch Payment Status
Pass the MoshiPay payment identifier returned by a create payment response.
Webhooks
MoshiPay signs callbacks with these headers:
X-MoshiPay-EventX-MoshiPay-ReferenceX-MoshiPay-TimestampX-MoshiPay-Signature
The signature is generated as:
For merchant callback URLs that use your account credentials, the default verification secret is the API secret configured on the client. If your MoshiPay dashboard provides a separate webhook endpoint secret, pass it as the fourth argument to verifyWebhookSignature().
Webhook verification includes a default timestamp tolerance of 300 seconds to reduce replay risk.
Error Handling
Idempotency
Pass a stable idempotencyKey when creating payments. A good key is your internal order ID or payment attempt ID.
Use a new idempotency key for a genuinely new payment attempt.
Production Checklist
- Use
Client::sandbox()while testing andClient::live()only after credentials are approved for production. - Keep API keys, API secrets, and webhook secrets in environment variables or a secret manager.
- Always pass an idempotency key when creating payments from an order or invoice.
- Validate and persist your own order state before redirecting customers or returning webhook success responses.
- Treat webhooks as the source of truth for final payment state.
- Make webhook handlers idempotent because callbacks may be retried.
- Verify webhook signatures using the raw request body before parsing JSON.
- Log API status codes and response bodies for failed requests, but never log secrets.
- Use HTTPS URLs for callback, return, redirect, and cancel URLs.
Testing
Install development dependencies:
Run the test suite:
Validate package metadata:
API Coverage
Implemented:
- Create mobile money payments
- Create card payments
- Fetch payment status
- Idempotency key header
- Webhook signature verification
- Webhook JSON parsing
License
MIT. See LICENSE.
All versions of moshipay-php with dependencies
ext-curl Version *
ext-json Version *