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
4 changes: 2 additions & 2 deletions docs/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ $balance = Payment::balance();
Payment::configure($config);

// Switch to MTN for a specific transaction
Payment::withProvider('ci', Payment::MTN);
Payment::useProvider('ci', Payment::MTN);
Payment::payment($data);

// Switch back to default provider
Payment::withProvider('ci', Payment::ORANGE);
Payment::useProvider('ci', Payment::ORANGE);
```

## Advanced Features
Expand Down
4 changes: 2 additions & 2 deletions docs/fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ $balance = Payment::balance();
Payment::configure($config);

// Basculer vers MTN pour une transaction spécifique
Payment::withProvider('ci', Payment::MTN);
Payment::useProvider('ci', Payment::MTN);
Payment::payment($data);

// Revenir au fournisseur par défaut
Payment::withProvider('ci', Payment::ORANGE);
Payment::useProvider('ci', Payment::ORANGE);
```

## Fonctionnalités Avancées
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ $balance = Payment::balance();
Payment::configure($config);

// Switch to MTN for a specific transaction
Payment::withProvider('ci', Payment::MTN);
Payment::useProvider('ci', Payment::MTN);
Payment::payment($data);
```

Expand Down
13 changes: 13 additions & 0 deletions src/Common/PaymentStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Bow\Payment\Common;

class PaymentStatus
{
const INITIATED = 'initiated';
const PENDING = 'pending';
const COMPLETED = 'completed';
const FAILED = 'failed';
const EXPIRED = 'expired';
const UNKNOWN = 'unknown';
}
9 changes: 8 additions & 1 deletion src/Common/ProcessorStatusInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ProcessorStatusInterface
*
* @return bool
*/
public function isFail();
public function isFailed();

/**
* Define if transaction initiated
Expand Down Expand Up @@ -38,4 +38,11 @@ public function isSuccess();
* @return bool
*/
public function isPending();

/**
* Get payment status string
*
* @return string
*/
public function getStatus(): string;
}
25 changes: 14 additions & 11 deletions src/Gateway/IvoryCost/Mono/Collection/MomoPaymentStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Bow\Payment\Gateway\IvoryCost\Mono\Collection;

use Bow\Payment\Common\PaymentStatus;
use Bow\Payment\Common\ProcessorStatusInterface;

class MomoPaymentStatus implements ProcessorStatusInterface
Expand Down Expand Up @@ -37,7 +38,7 @@ public function __construct(string $status, array $data = [])
*
* @return bool
*/
public function isFail(): bool
public function isFailed(): bool
{
return in_array($this->status, ['FAILED', 'REJECTED']);
}
Expand Down Expand Up @@ -89,17 +90,19 @@ public function isPending(): bool
*/
public function getStatus(): string
{
return $this->status;
}
if ($this->isSuccess()) {
return PaymentStatus::COMPLETED;
}

/**
* Get transaction data
*
* @return array
*/
public function getData(): array
{
return $this->data;
if ($this->isPending()) {
return PaymentStatus::PENDING;
}

if ($this->isFailed()) {
return PaymentStatus::FAILED;
}

return PaymentStatus::UNKNOWN;
}
}

2 changes: 1 addition & 1 deletion src/Gateway/IvoryCost/Orange/OrangeTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function checkIfHasFail($amount, string $order_id, string $pay_token)
{
$status = $this->check($amount, $order_id, $pay_token);

return $status->isFail();
return $status->isFailed();
}

/**
Expand Down
25 changes: 24 additions & 1 deletion src/Gateway/IvoryCost/Orange/OrangeTransactionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Bow\Payment\Gateway\IvoryCost\Orange;

use Bow\Payment\Common\PaymentStatus;
use Bow\Payment\Common\ProcessorStatusInterface;

class OrangeTransactionStatus implements ProcessorStatusInterface
Expand Down Expand Up @@ -29,7 +30,7 @@ public function __construct(string $status)
*
* @return bool
*/
public function isFail()
public function isFailed()
{
return $this->status == 'FAIL';
}
Expand Down Expand Up @@ -73,4 +74,26 @@ public function isPending()
{
return $this->status == 'PENDING';
}

/**
* Get payment status string
*
* @return string
*/
public function getStatus(): string
{
if ($this->isSuccess()) {
return PaymentStatus::COMPLETED;
}

if ($this->isPending()) {
return PaymentStatus::PENDING;
}

if ($this->isFailed()) {
return PaymentStatus::FAILED;
}

return PaymentStatus::UNKNOWN;
}
}
Loading