An open API service indexing awesome lists of open source software.

https://github.com/alexnguetcha/intouch-api-wrapper

The Intouch Payment Library is a PHP library that provides a simple interface for making payments with mobile money service providers that are supported by the Intouch platform. This library handles the complexities of interacting with the Intouch API, allowing you to focus on building your application.
https://github.com/alexnguetcha/intouch-api-wrapper

mobile-payments payment-integration php php-library

Last synced: about 2 months ago
JSON representation

The Intouch Payment Library is a PHP library that provides a simple interface for making payments with mobile money service providers that are supported by the Intouch platform. This library handles the complexities of interacting with the Intouch API, allowing you to focus on building your application.

Awesome Lists containing this project

README

        

# Intouch Payment Library

The Intouch Payment Library is a PHP library that provides a simple interface for making payments with mobile money service providers that are supported by the Intouch platform. This library handles the complexities of interacting with the Intouch API, allowing you to focus on building your application.

## Installation

To install the Intouch Payment Library, you can use [Composer](https://getcomposer.org/), a package manager for PHP. Run the following command in your project directory:

```
composer require alex-nguetcha/intouch
```

## Complete example

Here is an complete example of a use case

```php
$intouch = Intouch::credentials(
username: 'username',
password: 'password',
loginAgent: 'loginAgent',
passwordAgent: 'passwordAgent',
intouchId: 'passwordAgent'
)->callback('https://app.test/confirm-payment')
->amount(100)
->phone(6xxxxxx)
->operator('ORANGE')
->makeMerchantPayment(
[
"recipientEmail" => "[email protected]",
"recipientFirstName" => "John",
"recipientLastName" => "Doe",
]
);

if ($intouch->isInitiated()) {
// Your transaction has been initiated by intouch API
// echo (string)($intouch->getResult()->getBody());
} else {
// something went wrong
// echo $intouch->getError()['request'];
// echo $intouch->getError()['response'];
}
```

## Usage

To use the Intouch Payment Library, you must first obtain credentials from the [Intouch platform](https://intouchgroup.net/). These credentials include a username, password, login agent, password agent, and Intouch ID. You can then create an instance of the `Intouch` class, passing in your credentials:

```php
use AlexNguetcha\Intouch\Intouch;

$intouch = Intouch::credentials(
username: 'your-username',
password: 'your-password',
loginAgent: 'your-login-agent',
passwordAgent: 'your-password-agent',
intouchId: 'your-intouch-id'
);
```

## Initiating a Payment

Once you have created an instance of the `Intouch` class, you can initiate a payment using the `makeMerchantPayment` method. This method takes an array of payment information, including the amount to be paid, the mobile money account to be debited, and the recipient information:

Before initiating a payment, you need to set the payment details using the following methods:

```php
$intouch->amount(100); // Set the amount to be paid
$intouch->phone('1234567890'); // Set the mobile money account to be debited
$intouch->operator('MTN'); // Set the mobile money operator for the transaction
$intouch->callback('https://example.com/payment/callback');
```

### Callbacks

Intouch sends a notification to your application when a payment is completed. You can set a callback URL using the `callback` method. This URL will be called by Intouch with a payload containing information about the completed payment:

```php
$intouch->makeMerchantPayment([
"recipientEmail" => "[email protected]",
"recipientFirstName" => "John",
"recipientLastName" => "Doe",
"phone" => "1234567890",
"amount" => 100,
"operator" => "MTN",
"reason" => "Payment for goods and services",
]);

```

```php
$intouch->callback('https://your-app.com/intouch-callback');
```

## Handling the Response

You can check if a payment was successfully initiated using the isInitiated method. If the payment was initiated, you can access the response using the getResult method. If something went wrong, you can access error information using the getError method:

```php
if ($intouch->isInitiated()) {
// Your transaction has been initiated by intouch API
echo (string)($intouch->getResult()->getBody());
} else {
// something went wrong
// echo $intouch->getError()['request'];
echo $intouch->getError()['response'];
}
```

## Conclusion

The Intouch Payment Library provides a simple and convenient way to interact with the Intouch API and make mobile money payments. By following the steps outlined in this documentation, you can easily integrate mobile money payments into your PHP application.