Skip to content

Commit

Permalink
Merge pull request #4 from luigel/analysis-2QbKDg
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
luigel committed May 16, 2020
2 parents 7f25089 + 90fff4d commit a85d6e0
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 151 deletions.
4 changes: 2 additions & 2 deletions config/config.php
Expand Up @@ -3,7 +3,7 @@
return [

/**
* Public and Secret keys from Paymongo. You can get the keys here https://dashboard.paymongo.com/developers
* Public and Secret keys from Paymongo. You can get the keys here https://dashboard.paymongo.com/developers.
*/

/**
Expand All @@ -25,5 +25,5 @@
* Paymongo's team continuously adding more features and integrations to the API.
* Currently, the API supports doing payments via debit and credit cards issued by Visa and Mastercard.
*/
'version' => env('PAYMONGO_VERSION', '2019-08-05')
'version' => env('PAYMONGO_VERSION', '2019-08-05'),
];
3 changes: 1 addition & 2 deletions src/Exceptions/BadRequestException.php
Expand Up @@ -11,8 +11,7 @@ public function __construct(
$message = 'The request was not understood, often caused by missing parameters.',
$code = 400,
Throwable $previous = null
)
{
) {
parent::__construct($message, $code, $previous);
}
}
3 changes: 1 addition & 2 deletions src/Exceptions/NotFoundException.php
Expand Up @@ -11,8 +11,7 @@ public function __construct(
$message = 'Not found record',
$code = 404,
Throwable $previous = null
)
{
) {
parent::__construct($message, $code, $previous);
}
}
3 changes: 1 addition & 2 deletions src/Exceptions/PaymentErrorException.php
Expand Up @@ -11,8 +11,7 @@ public function __construct(
$message = 'There is an error during payment',
$code = 402,
Throwable $previous = null
)
{
) {
parent::__construct($message, $code, $previous);
}
}
7 changes: 4 additions & 3 deletions src/Models/Payment.php
Expand Up @@ -36,23 +36,24 @@ public function setData($data)
foreach ($data as $item) {
$payments->push($this->setSingleData($item));
}

return $payments;
}

protected function setSingleData($data)
{
$this->id = $data['id'];
$this->type = $data['type'];
$this->amount = doubleval($data['attributes']['amount'] / 100);
$this->amount = floatval($data['attributes']['amount'] / 100);
$this->billing_address = $data['attributes']['billing']['address'];
$this->billing_email = $data['attributes']['billing']['email'];
$this->billing_name = $data['attributes']['billing']['name'];
$this->billing_phone_number = $data['attributes']['billing']['phone'];
$this->currency = $data['attributes']['currency'] ?? 'PHP';
$this->description = $data['attributes']['description'];
$this->fee = doubleval($data['attributes']['fee'] / 100);
$this->fee = floatval($data['attributes']['fee'] / 100);
$this->livemode = $data['attributes']['livemode'];
$this->net_amount = doubleval($data['attributes']['net_amount']);
$this->net_amount = floatval($data['attributes']['net_amount']);
$this->payout = $data['attributes']['payout'];
$this->source = $data['attributes']['source'];
$this->statement_descriptor = $data['attributes']['statement_descriptor'];
Expand Down
11 changes: 5 additions & 6 deletions src/Models/PaymentIntent.php
Expand Up @@ -23,7 +23,6 @@ class PaymentIntent
protected $metadata;
protected $status;


public function setData($data)
{
$this->id = $data['id'];
Expand Down Expand Up @@ -97,27 +96,27 @@ public function getStatementDescriptor()
{
return $this->statement_descriptor;
}

public function getClientKey()
{
return $this->client_key;
}

public function getLastPaymentError()
{
return $this->last_payment_error;
}

public function getPayments()
{
return $this->payments;
}

public function getNextAction()
{
return $this->next_action;
}

public function getPaymentMethodOptions()
{
return $this->payment_method_options;
Expand Down
3 changes: 2 additions & 1 deletion src/Models/PaymentSource.php
Expand Up @@ -2,7 +2,8 @@

namespace Luigel\Paymongo\Models;

class PaymentSource {
class PaymentSource
{
public $id;
public $type;

Expand Down
2 changes: 1 addition & 1 deletion src/Models/Source.php
Expand Up @@ -33,7 +33,7 @@ public function setData($data)
'amount' => $this->amount,
'redirect' => $this->redirect,
'source_type' => $this->source_type,
'created_at' => $this->created_at
'created_at' => $this->created_at,
];

return $this;
Expand Down
5 changes: 2 additions & 3 deletions src/Models/Token.php
Expand Up @@ -23,7 +23,7 @@ public function setData($data)
$this->id = $data['id'];
$this->type = $data['type'];
$this->card = $data['attributes']['card'];
$this->kind =$data['attributes']['kind'];
$this->kind = $data['attributes']['kind'];
$this->livemode = $data['attributes']['livemode'];
$this->used = $data['attributes']['used'];
$this->created_at = $data['attributes']['created_at'];
Expand All @@ -49,7 +49,6 @@ public function setData($data)
];

return $this;

}

public function getId()
Expand Down Expand Up @@ -116,4 +115,4 @@ public function getData()
{
return $this->data;
}
}
}
17 changes: 7 additions & 10 deletions src/Models/Webhook.php
Expand Up @@ -20,16 +20,15 @@ class Webhook

public function setData($data)
{
if (is_array($data) && isset($data['id']))
{
if (is_array($data) && isset($data['id'])) {
return $this->setSingleData($data);
}
$webhooks = collect();

foreach ($data as $item)
{
foreach ($data as $item) {
$webhooks->push($this->setSingleData($item));
}

return $webhooks;
}

Expand All @@ -44,8 +43,7 @@ protected function setSingleData($data)
$this->created_at = $data['attributes']['created_at'];

$events = collect();
foreach ($data['attributes']['events'] as $event)
{
foreach ($data['attributes']['events'] as $event) {
$events->push($event);
}

Expand All @@ -59,7 +57,7 @@ protected function setSingleData($data)
'url' => $this->url,
'events' => $this->events,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at
'updated_at' => $this->updated_at,
];

return $this;
Expand Down Expand Up @@ -92,11 +90,10 @@ public function getUrl()

public function getEvents($i = null)
{
if (is_int($i) && $i !== null)
{
if (is_int($i) && $i !== null) {
return $this->events[$i];
}

return $this->events;
}

Expand Down
30 changes: 18 additions & 12 deletions src/Paymongo.php
Expand Up @@ -30,74 +30,80 @@ class Paymongo
protected const SOURCE_GRAB_PAY = 'grab_pay';

/**
* Source Module used to create Source
* Source Module used to create Source.
*
* @return $this
*/
public function source()
{
$this->apiUrl = self::BASE_API . self::ENPDPOINT_SOURCES;
$this->apiUrl = self::BASE_API.self::ENPDPOINT_SOURCES;
$this->returnModel = Source::class;

return $this;
}

/**
* Webhook Module used to create, retrieve, enable, and disable Webhooks
* Webhook Module used to create, retrieve, enable, and disable Webhooks.
*
* @return $this
*/
public function webhook()
{
$this->apiUrl = self::BASE_API . self::ENDPOINT_WEBHOOKS;
$this->apiUrl = self::BASE_API.self::ENDPOINT_WEBHOOKS;
$this->returnModel = Webhook::class;

return $this;
}

/**
* Payment Method Module used to create, retrieve Payment method informations
* Payment Method Module used to create, retrieve Payment method informations.
*
* @return $this
*/
public function paymentMethod()
{
$this->apiUrl = self::BASE_API . self::ENDPOINT_PAYMENT_METHOD;
$this->apiUrl = self::BASE_API.self::ENDPOINT_PAYMENT_METHOD;
$this->returnModel = PaymentMethod::class;

return $this;
}

/**
* Payment Intent Module used to create, retrieve, and attach payment method in payment intent
* Payment Intent Module used to create, retrieve, and attach payment method in payment intent.
*
* @return $this
*/
public function paymentIntent()
{
$this->apiUrl = self::BASE_API . self::ENDPOINT_PAYMENT_INTENT;
$this->apiUrl = self::BASE_API.self::ENDPOINT_PAYMENT_INTENT;
$this->returnModel = PaymentIntent::class;

return $this;
}

/**
* Payment Module used to create, retrieve Payment informations
* Payment Module used to create, retrieve Payment informations.
*
* @return $this
*/
public function payment()
{
$this->apiUrl = self::BASE_API . self::ENDPOINT_PAYMENT;
$this->apiUrl = self::BASE_API.self::ENDPOINT_PAYMENT;
$this->returnModel = Payment::class;

return $this;
}

/**
* Token Module used to create and retrieve token
* Token Module used to create and retrieve token.
* @deprecated 1.2.0
* @return $this
*/
public function token()
{
$this->apiUrl = self::BASE_API . self::ENDPOINT_TOKEN;
$this->apiUrl = self::BASE_API.self::ENDPOINT_TOKEN;
$this->returnModel = Token::class;

return $this;
}
}

0 comments on commit a85d6e0

Please sign in to comment.