Skip to content

Commit

Permalink
clean up, add docblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Bak committed Sep 3, 2024
1 parent f7f66e8 commit a264e15
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 60 deletions.
19 changes: 0 additions & 19 deletions src/Commands/QuickpayCommand.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/Facades/Quickpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
namespace Netbums\Quickpay\Facades;

use Illuminate\Support\Facades\Facade;
use Netbums\Quickpay\Resources\CardResource;
use Netbums\Quickpay\Resources\FeeResource;
use Netbums\Quickpay\Resources\PaymentResource;
use Netbums\Quickpay\Resources\PayoutResource;
use Netbums\Quickpay\Resources\SubscriptionResource;

/**
* @method static PaymentResource payments();
* @method static SubscriptionResource subscriptions();
* @method static CardResource cards();
* @method static FeeResource fees();
* @method static PayoutResource payouts();
*/
class Quickpay extends Facade
{
Expand Down
5 changes: 5 additions & 0 deletions src/Resources/Concerns/QuickpayApiConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ trait QuickpayApiConsumer
public function __construct(public QuickPay $client) {}

/**
* Make a request to the Quickpay API
* @param string $method
* @param string $endpoint
* @param array $data
* @return array
* @throws CardNotAccepted
* @throws QuickPayValidationError
*/
Expand Down
65 changes: 30 additions & 35 deletions src/Resources/PaymentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class PaymentResource
use QuickpayApiConsumer;

/**
* Fetch all payments
* @return array
* @throws FetchPaymentsFailed
*/
public function all(): array
Expand All @@ -45,6 +47,9 @@ public function all(): array
}

/**
* Create Payment
* @param Payment $payment
* @return array
* @throws CreatePaymentFailed
*/
public function create(Payment $payment): array
Expand All @@ -67,7 +72,8 @@ public function create(Payment $payment): array

/**
* Create or Update the Payment Link
*
* @param PaymentLink $paymentLink
* @return array
* @throws CreatePaymentLinkFailed
*/
public function createLink(PaymentLink $paymentLink): array
Expand All @@ -92,7 +98,8 @@ public function createLink(PaymentLink $paymentLink): array

/**
* Delete payment link
*
* @param int $id
* @return array
* @throws DeletePaymentLinkFailed
*/
public function deleteLink(int $id): array
Expand All @@ -115,7 +122,8 @@ public function deleteLink(int $id): array

/**
* Get Payment
*
* @param int $id
* @return array
* @throws FetchPaymentFailed
*/
public function find(int $id): array
Expand All @@ -138,7 +146,9 @@ public function find(int $id): array

/**
* Create payment session
*
* @param int $id
* @param int $amount
* @return array
* @throws CreatePaymentSessionFailed
*/
public function createPaymentSession(int $id, int $amount): array
Expand Down Expand Up @@ -166,7 +176,9 @@ public function createPaymentSession(int $id, int $amount): array

/**
* authorize payment
*
* @param int $id
* @param int $amount
* @return array
* @throws AuthorizePaymentFailed
*/
public function authorize(int $id, int $amount): array
Expand Down Expand Up @@ -194,7 +206,9 @@ public function authorize(int $id, int $amount): array

/**
* capture payment
*
* @param int $id
* @param int $amount
* @return array
* @throws CapturePaymentFailed
*/
public function capture(int $id, int $amount): array
Expand Down Expand Up @@ -222,7 +236,9 @@ public function capture(int $id, int $amount): array

/**
* refund payment
*
* @param int $id
* @param int $amount
* @return array
* @throws RefundPaymentFailed
*/
public function refund(int $id, int $amount): array
Expand Down Expand Up @@ -251,7 +267,8 @@ public function refund(int $id, int $amount): array

/**
* cancel payment
*
* @param int $id
* @return array
* @throws CancelPaymentFailed
*/
public function cancel(int $id): array
Expand All @@ -274,7 +291,8 @@ public function cancel(int $id): array

/**
* renew authorization
*
* @param int $id
* @return array
* @throws RenewPaymentFailed
*/
public function renew(int $id): array
Expand All @@ -297,7 +315,9 @@ public function renew(int $id): array

/**
* create fraud confirmation report
*
* @param int $id
* @param string|null $description
* @return array
* @throws CreateFraudConfirmationReportFailed
*/
public function createFraudConfirmationReport(int $id, ?string $description = null): array
Expand All @@ -321,29 +341,4 @@ public function createFraudConfirmationReport(int $id, ?string $description = nu

return $response;
}

// /** Helpers for the createLink() */
// public function allowedPaymentMethods(string $paymentMethods): static
// {
// $this->data['payment_methods'] = $paymentMethods;
// return $this;
// }
//
// public function autoFee(): static
// {
// $this->data['auto_fee'] = true;
// return $this;
// }
//
// public function acquirer(string $aquirer): static
// {
// $this->data['acquirer'] = $aquirer;
// return $this;
// }
//
// public function autoCapture(): static
// {
// $this->data['auto_capture'] = true;
// return $this;
// }
}
5 changes: 5 additions & 0 deletions src/Resources/SubscriptionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Netbums\Quickpay\Resources;

use Netbums\Quickpay\Exceptions\QuickPayValidationError;
use Netbums\Quickpay\Exceptions\Subscriptions\FetchSubscriptionFailed;
use Netbums\Quickpay\Exceptions\Subscriptions\FetchSubscriptionsFailed;
use Netbums\Quickpay\Resources\Concerns\QuickpayApiConsumer;
use Throwable;
Expand Down Expand Up @@ -68,6 +70,9 @@ public function deletePaymentLink(string $subscriptionId): array

// @see https://learn.quickpay.net/tech-talk/api/services/#POST-subscriptions---format-
// TODO: convert the provided array to a DTO
/**
* @throws QuickPayValidationError
*/
public function create(array $data): array
{
$this->method = 'post';
Expand Down

0 comments on commit a264e15

Please sign in to comment.