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
3 changes: 2 additions & 1 deletion docs/ApplePay.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ try {
// Handle specific errors, e.g., domain not found, invalid operation.
}

?>
?>
```
2 changes: 1 addition & 1 deletion docs/BulkCharge.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ if ($batchCode) {
echo "\nSkipping batch-specific operations as no valid batch code was obtained from initiation.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Charge.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ try {
// 2. You extract the reference from the initial response.
// 3. You call the respective submit method with the user-provided data and the reference.

?>
?>```
2 changes: 1 addition & 1 deletion docs/Customer.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ try {
echo "Error deactivating authorization '{$sampleAuthorizationCode}': " . $e->getMessage() . "\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Dispute.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ try {
echo "Error exporting disputes: " . $e->getMessage() . "\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ try {
echo "Error verifying updated payment session timeout: " . $e->getMessage() . "\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Miscellaneous.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ try {
echo "Error fetching Nigerian states: " . $e->getMessage() . "\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/PaymentPage.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ if ($fixedPageId && $dummyProductId) {
echo "\nSkipping addProduct operation as either page ID or dummy product ID is missing.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/PaymentRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ try {
echo "Error fetching total payment requests: " . $e->getMessage() . "\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ if ($planId || $planCode) {
echo "\nSkipping plan-specific operations as no valid plan ID/code was obtained from creation.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Product.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ if ($productId) {
echo "\nSkipping product-specific operations as no valid product ID was obtained from creation.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Refund.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ if ($refundId) {
echo "\nSkipping fetch refund operation as no valid refund ID was obtained from creation.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Settlement.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ if ($sampleSettlementId) {
echo "\nSkipping fetching settlement transactions as no valid settlement ID was available.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/SubAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ if ($subaccountId || $subaccountCode) {
echo "\nSkipping subaccount-specific operations as no valid subaccount ID/code was obtained from creation.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ if ($subscriptionCode && $emailToken) {
echo "\nSkipping subscription-specific operations as no valid subscription code/token was obtained.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Terminal.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ if ($commissionedTerminalId && $newTerminalSerialNumber) { // Only decommission
echo "\nSkipping decommission operation as no new terminal was commissioned in this run.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,4 @@ if ($authorizationCode && $sampleCustomerEmail) {
echo "\nSkipping partial debit as no valid authorization code or customer email is available.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/TransactionSplit.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ if ($splitId || $splitCode) {
echo "\nSkipping split-specific operations as no valid split ID/code was obtained from creation.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@ if ($transferCode) {
echo "\nSkipping transfer-specific operations as no valid transfer code is available.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/TransferControl.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ try {
echo "Error enabling OTP: " . $e->getMessage() . "\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/TransferRecipient.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ if ($recipientId || $recipientCode) {
echo "\nSkipping recipient-specific operations as no valid recipient ID/code was obtained.\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/Verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ try {
echo "Error resolving card BIN: " . $e->getMessage() . "\n";
}

?>
?>```
2 changes: 1 addition & 1 deletion docs/VirtualAccount.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ if ($virtualAccountId && $virtualAccountNumber && $virtualAccountBankSlug) {
echo "\nSkipping virtual account-specific operations as no valid virtual account ID/number/bank slug was obtained.\n";
}

?>
?>```
37 changes: 37 additions & 0 deletions tests/Factory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use MusheAbdulHakim\Paystack\Client;
use MusheAbdulHakim\Paystack\Factory;
use Psr\Http\Client\ClientInterface;

it('can create a client with a secret key', function () {
$client = (new Factory())->withSecretKey('sk_test_123')->make();

expect($client)->toBeInstanceOf(Client::class);
});

it('can create a client with a public key', function () {
$client = (new Factory())->withPublicKey('pk_test_123')->make();

expect($client)->toBeInstanceOf(Client::class);
});

it('can create a client with a base URI', function () {
$client = (new Factory())->withBaseUri('https://example.com')->make();

expect($client)->toBeInstanceOf(Client::class);
});

it('can create a client with a custom HTTP client', function () {
$httpClient = Mockery::mock(ClientInterface::class);

$client = (new Factory())->withHttpClient($httpClient)->make();

expect($client)->toBeInstanceOf(Client::class);
});

it('can create a client with a custom HTTP header', function () {
$client = (new Factory())->withHttpHeader('X-Custom', 'value')->make();

expect($client)->toBeInstanceOf(Client::class);
});
25 changes: 25 additions & 0 deletions tests/Paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@
use MusheAbdulHakim\Paystack\Factory;
use MusheAbdulHakim\Paystack\Paystack;

it('can initialize the client factory', function () {
$factory = Paystack::init('secret');
expect($factory)->toBeInstanceOf(Factory::class);
});

it('can create a client with secret key', function () {
$client = Paystack::client('secret');
expect($client)->toBeInstanceOf(Client::class);
});

it('can create a client with secret key and base uri', function () {
$client = Paystack::client('secret', 'https://example.com');
expect($client)->toBeInstanceOf(Client::class);
});

it('can create a new factory instance', function () {
$factory = Paystack::factory();
expect($factory)->toBeInstanceOf(Factory::class);
});

it('should return a Factory instance when calling init', function () {
$factory = Paystack::init('test_secret');
expect($factory)->toBeInstanceOf(Factory::class);
});

it('may create client', function () {
$paystack = Paystack::client('key');
expect($paystack)->toBeInstanceOf(Client::class);
Expand Down