Skip to content

Commit

Permalink
Add test Payout
Browse files Browse the repository at this point in the history
  • Loading branch information
rooneyi committed Oct 16, 2024
1 parent 06a90d8 commit d97fba7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
16 changes: 6 additions & 10 deletions src/Request/PayoutRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace Devscast\Flexpay\Request;

use Devscast\Flexpay\Credential;
use Devscast\Flexpay\Data\Currency;
use Devscast\Flexpay\Data\TransactionType;
use Webmozart\Assert\Assert;

final class PayoutRequest extends Request
Expand All @@ -16,24 +14,22 @@ public function __construct(
string $reference,
Currency $currency,
string $callbackUrl,
public Credential $credentials,
public string $telephone,
public TransactionType $type,
public string $phone,
public int $type = 1,
) {

Assert::length($this->telephone, 12, 'The phone number should be 12 characters long, eg: 243123456789');
Assert::length($this->phone, 12, 'The phone number should be 12 characters long, eg: 243123456789');

parent::__construct($amount, $reference, $currency, $callbackUrl);
}

public function getPayload(): array
{
return [
'authorization' => sprintf('Bearer %s', $this->credentials->token),
'merchant' => $this->merchant,
'type' => $this->type->value,
'authorization' => $this->authorization,
'type' => $this->type,
'reference' => $this->reference,
'phone' => $this->telephone,
'phone' => $this->phone,
'amount' => $this->amount,
'currency' => $this->currency->value,
'callbackUrl' => $this->callbackUrl,
Expand Down
5 changes: 2 additions & 3 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ public function testPayout(): void
reference: 'ref',
currency: Currency::USD,
callbackUrl: 'http://localhost:8000/callback',
credentials: '',
telephone: '243123456789',
type: TransactionType::CARD
phone: '243123456789',
type: 1
);

$response = $flexpay->payout($request);
Expand Down

0 comments on commit d97fba7

Please sign in to comment.