Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 53 additions & 12 deletions config/payment.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Bow\Payment\Payment;
use Bow\Payment\Processor;

return [
/**
Expand All @@ -12,8 +12,8 @@
* The default gateway
*/
'default' => [
'gateway' => Payment::ORANGE,
'country' => 'ci',
'gateway' => Processor::ORANGE,
'country' => 'ivory_coast',
],

/**
Expand All @@ -23,32 +23,60 @@
'orange' => [
'client_key' => '',
'client_secret' => '',
'webhook_secret' => ''
'webhook_secret' => '',
'options' => [
'notif_url' => '', // Notification URL
'return_url' => '', // Return URL after payment
'cancel_url' => '', // Cancel URL if payment failed
],
],

'mtn' => [
'subscription_key' => '',
'api_user' => '',
'api_key' => '',
'environment' => 'sandbox', // or 'production'
'webhook_secret' => ''
'webhook_secret' => '',
'subscription_key' => '',
'options' => [
'notif_url' => '', // Notification URL
'return_url' => '', // Return URL after payment
'cancel_url' => '', // Cancel URL if payment failed
],
],

'moov' => [
'client_key' => '',
'client_secret' => '',
'webhook_secret' => ''
'webhook_secret' => '',
'options' => [
'merchant_id' => '',
'notif_url' => '', // Notification URL
'return_url' => '', // Return URL after payment
'cancel_url' => '', // Cancel URL if payment failed
],
],

'wave' => [
'api_key' => '', // Your Wave API key (starts with wave_sn_prod_ or wave_sn_sandbox_)
'webhook_secret' => ''
'webhook_secret' => '',
'aggregated_merchant_id' => '',
'options' => [
'restrict_payer_mobile' => false,
'aggregated_merchant_id' => '', // Aggregated Merchant ID for Senegal to override default
'notif_url' => '', // Notification URL
'success_url' => '', // Success URL after payment
'error_url' => '', // Error URL if payment failed
],
],

'djamo' => [
'client_key' => '',
'client_secret' => '',
'webhook_secret' => ''
'webhook_secret' => '',
'options' => [
'notif_url' => '', // Notification URL
'return_url' => '', // Return URL after payment
'cancel_url' => '', // Cancel URL if payment failed
],
]
],

Expand All @@ -59,12 +87,25 @@
'orange' => [
'client_key' => '',
'client_secret' => '',
'webhook_secret' => ''
'webhook_secret' => '',
'options' => [
'notif_url' => '', // Notification URL
'return_url' => '', // Return URL after payment
'cancel_url' => '', // Cancel URL if payment failed
],
],

'wave' => [
'api_key' => '', // Your Wave API key (starts with wave_sn_prod_ or wave_sn_sandbox_)
'webhook_secret' => ''
'webhook_secret' => '',
'aggregated_merchant_id' => '',
'options' => [
'restrict_payer_mobile' => false,
'aggregated_merchant_id' => '', // Aggregated Merchant ID for Senegal to override default
'notif_url' => '', // Notification URL
'success_url' => '', // Success URL after payment
'error_url' => '', // Error URL if payment failed
],
],
],
];
8 changes: 4 additions & 4 deletions docs/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,20 @@ For advanced use cases, you can use providers directly:
### Orange Money Direct Usage

```php
use Bow\Payment\Gateway\IvoryCost\OrangeMoney\OrangeMoneyGateway;
use Bow\Payment\Gateway\IvoryCost\OrangeMoney\OrangeMoneyTokenGenerator;
use Bow\Payment\Gateway\IvoryCost\Orange\OrangeGateway;
use Bow\Payment\Gateway\IvoryCost\Orange\OrangeTokenGenerator;

$config = [
'client_key' => 'YOUR_CLIENT_KEY',
'client_secret' => 'YOUR_CLIENT_SECRET',
];

$tokenGenerator = new OrangeMoneyTokenGenerator(
$tokenGenerator = new OrangeTokenGenerator(
$config['client_key'],
$config['client_secret']
);

$gateway = new OrangeMoneyGateway($tokenGenerator, $config);
$gateway = new OrangeGateway($tokenGenerator, $config);

$result = $gateway->payment([
'amount' => 1000,
Expand Down
8 changes: 4 additions & 4 deletions docs/fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,20 @@ Pour des cas d'utilisation avancés, vous pouvez utiliser les fournisseurs direc
### Utilisation Directe d'Orange Money

```php
use Bow\Payment\Gateway\IvoryCost\OrangeMoney\OrangeMoneyGateway;
use Bow\Payment\Gateway\IvoryCost\OrangeMoney\OrangeMoneyTokenGenerator;
use Bow\Payment\Gateway\IvoryCost\Orange\OrangeGateway;
use Bow\Payment\Gateway\IvoryCost\Orange\OrangeTokenGenerator;

$config = [
'client_key' => 'VOTRE_CLIENT_KEY',
'client_secret' => 'VOTRE_CLIENT_SECRET',
];

$tokenGenerator = new OrangeMoneyTokenGenerator(
$tokenGenerator = new OrangeTokenGenerator(
$config['client_key'],
$config['client_secret']
);

$gateway = new OrangeMoneyGateway($tokenGenerator, $config);
$gateway = new OrangeGateway($tokenGenerator, $config);

$result = $gateway->payment([
'amount' => 1000,
Expand Down
36 changes: 21 additions & 15 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use Bow\Payment\Payment;
return [
'default' => [
'gateway' => Payment::ORANGE,
'country' => 'ci',
'country' => 'ivory_coast',
],

'ivory_coast' => [
Expand All @@ -66,22 +66,26 @@ return [
use Bow\Payment\Payment;

// Configure the payment gateway
Payment::configure($config);
$gateway = Payment::configure($config);

// Make a payment
Payment::payment([
$gateway->payment([
'amount' => 1000,
'phone_number' => '+225070000001',
'reference' => 'ORDER-123',
'notif_url' => 'https://your-app.com/webhook',
'return_url' => 'https://your-app.com/success',
'cancel_url' => 'https://your-app.com/cancel',
'options' => [
'notif_url' => 'https://your-app.com/webhook',
'return_url' => 'https://your-app.com/success',
'cancel_url' => 'https://your-app.com/cancel',
]
]);

// Verify a transaction
$status = Payment::verify([
'amount' => 1000,
'order_id' => 'ORDER-123',
'pay_token' => 'TOKEN',
$status = $gateway->verify([
'reference' => 'ORDER-123',
'options' => [
//
]
]);

if ($status->isSuccess()) {
Expand Down Expand Up @@ -224,9 +228,11 @@ Payment::configure([
$result = Payment::payment([
'amount' => 1000,
'reference' => 'ORDER-123',
'notif_url' => 'https://your-app.com/webhook',
'return_url' => 'https://your-app.com/success',
'cancel_url' => 'https://your-app.com/cancel',
'options' => [
'notif_url' => 'https://your-app.com/webhook',
'return_url' => 'https://your-app.com/success',
'cancel_url' => 'https://your-app.com/cancel',
],
]);
```

Expand All @@ -250,12 +256,12 @@ Payment::configure([

$result = Payment::payment([
'amount' => 1000,
'phone' => '0707070707',
'reference' => 'ORDER-123',
'phone_number' => '0707070707',
]);

// Verify transaction
$status = Payment::verify(['reference_id' => $result['reference_id']]);
$status = Payment::verify(['reference' => $result['reference']]);

// Check balance
$balance = Payment::balance();
Expand Down
23 changes: 19 additions & 4 deletions src/Common/ProcessorGatewayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,48 @@

namespace Bow\Payment\Common;

use Bow\Payment\Exceptions\InputValidationException;

interface ProcessorGatewayInterface
{
/**
* Make payment
*
* @param array $params
* @return mixed
*/
public function payment(...$args);
public function payment(array $params);

/**
* Make transfer
*
* @param array $params
* @return mixed
*/
public function transfer(...$args);
public function transfer(array $params);

/**
* Get balance
*
* @param array $params
* @return mixed
*/
public function balance(...$args);
public function balance(array $params = []);

/**
* Verify payment
*
* @param array $params
* @return void
*/
public function verify(array $params);

/**
* Validate payment data
*
* @param array $params
* @throws InputValidationException
* @return void
*/
public function verify();
public function validatePaymentData(array $params): void;
}
18 changes: 18 additions & 0 deletions src/Exceptions/InputValidationException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Bow\Payment\Exceptions;

use Bow\Payment\Exceptions\PaymentException;

class InputValidationException extends PaymentException
{
/**
* Create a new input validation exception
*
* @param string $message
*/
public function __construct(string $message)
{
parent::__construct("Input validation error: {$message}", 422);
}
}
27 changes: 19 additions & 8 deletions src/Gateway/IvoryCost/Djamo/DjamoGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public function __construct(array $config)
/**
* Make payment
*
* @param mixed ...$args
* @param array $params
* @return mixed
* @throws PaymentRequestException
*/
public function payment(...$args)
public function payment(array $params)
{
throw new PaymentRequestException(
'Djamo payment gateway is not yet implemented. Implementation pending official API documentation.'
Expand All @@ -45,11 +45,11 @@ public function payment(...$args)
/**
* Make transfer
*
* @param mixed ...$args
* @param array $params
* @return mixed
* @throws PaymentRequestException
*/
public function transfer(...$args)
public function transfer(array $params)
{
throw new PaymentRequestException(
'Djamo transfer is not yet implemented.'
Expand All @@ -59,11 +59,11 @@ public function transfer(...$args)
/**
* Get balance
*
* @param mixed ...$args
* @param array $params
* @return mixed
* @throws PaymentRequestException
*/
public function balance(...$args)
public function balance(array $params = [])
{
throw new PaymentRequestException(
'Djamo balance inquiry is not yet implemented.'
Expand All @@ -73,14 +73,25 @@ public function balance(...$args)
/**
* Verify payment
*
* @param mixed ...$args
* @param array $params
* @return mixed
* @throws PaymentRequestException
*/
public function verify(...$args)
public function verify(array $params)
{
throw new PaymentRequestException(
'Djamo payment verification is not yet implemented.'
);
}

/**
* Validate payment data
*
* @param array $params
* @return void
*/
public function validatePaymentData(array $params): void
{
// Implement validation logic as per Djamo's requirements when available
}
}
Loading