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: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.1, '8.2']
laravel: ['9.*', '11.*']
php: [8.1, 8.2, 8.3]
laravel: ['10.*', '11.*']
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
exclude:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
vendor
coverage
.env*
.idea
2 changes: 1 addition & 1 deletion .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":1,"defects":{"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_create_payment":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once":3,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_not_valid":3,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_retrieve_a_payment":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id":3,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_allow_valid_signature":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/BaseModelTest.php::it":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/SourceTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookListCommandTest.php::it":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/AmounToIntegerTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/RefundTest.php::it":3},"times":{"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_without_decimal":0.042,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_tenth_decimal":0.002,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_hundredth_decimal":0.001,"Luigel\\Paymongo\\Tests\\BaseModelTest::it_can_set_data":0.003,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_create_payment_intent":1.034,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_create_payment_intent_when_data_is_invalid":0.809,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_cancel_payment_intent":1.694,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_payment_method_to_payment_intent":2.908,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_attach_payment_intent_with_invalid_data":0.9,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_retrieve_payment_intent":1.774,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_create_payment_method":0.966,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_cannot_create_payment_method_with_invalid_data":0.834,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_retrieve_payment_method":1.755,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_create_payment":2.189,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once":2.784,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_not_valid":2.779,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_retrieve_a_payment":2.82,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id":1.72,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_get_all_payments":1.811,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_not_allow_invalid_signature":0.009,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_allow_valid_signature":0.055,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_gcash_source":0.875,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_grab_pay_source":0.857,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_create_token":0.912,"Luigel\\Paymongo\\Tests\\TokenTest::it_cannot_create_token_with_invalid_data":0.855,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_retrieve_token":1.782,"Luigel\\Paymongo\\Tests\\UnauthorizedTest::it_expects_unauthorized_exception_with_invalid_api_keys":0.825,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_list_all_webhooks":0.849,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_retrieve_webhook":1.646,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":2.616,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/AmounToIntegerTest.php::it":0.047,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/BaseModelTest.php::it":0.061,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":1.063,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentTest.php::it":1.19,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymongoValidateSignatureTest.php::it":0.061,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/SourceTest.php::it":0.883,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/TokenTest.php::it":0.815,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/UnauthorizedTest.php::it":1.045,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookTest.php::it":1.714,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookListCommandTest.php::it":1.957,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/RefundTest.php::it":1.658}}
{"version":1,"defects":{"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_create_payment":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once":3,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_not_valid":3,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_retrieve_a_payment":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id":3,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_allow_valid_signature":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/BaseModelTest.php::it":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/SourceTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookListCommandTest.php::it":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/AmounToIntegerTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/RefundTest.php::it":3},"times":{"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_without_decimal":0.042,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_tenth_decimal":0.002,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_hundredth_decimal":0.001,"Luigel\\Paymongo\\Tests\\BaseModelTest::it_can_set_data":0.003,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_create_payment_intent":1.034,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_create_payment_intent_when_data_is_invalid":0.809,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_cancel_payment_intent":1.694,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_payment_method_to_payment_intent":2.908,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_attach_payment_intent_with_invalid_data":0.9,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_retrieve_payment_intent":1.774,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_create_payment_method":0.966,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_cannot_create_payment_method_with_invalid_data":0.834,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_retrieve_payment_method":1.755,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_create_payment":2.189,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once":2.784,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_not_valid":2.779,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_retrieve_a_payment":2.82,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id":1.72,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_get_all_payments":1.811,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_not_allow_invalid_signature":0.009,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_allow_valid_signature":0.055,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_gcash_source":0.875,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_grab_pay_source":0.857,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_create_token":0.912,"Luigel\\Paymongo\\Tests\\TokenTest::it_cannot_create_token_with_invalid_data":0.855,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_retrieve_token":1.782,"Luigel\\Paymongo\\Tests\\UnauthorizedTest::it_expects_unauthorized_exception_with_invalid_api_keys":0.825,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_list_all_webhooks":0.849,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_retrieve_webhook":1.646,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":2.616,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/AmounToIntegerTest.php::it":0.047,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/BaseModelTest.php::it":0.061,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":1.063,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentTest.php::it":1.19,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymongoValidateSignatureTest.php::it":0.061,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/SourceTest.php::it":0.883,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/TokenTest.php::it":0.815,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/UnauthorizedTest.php::it":1.045,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookTest.php::it":1.714,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookListCommandTest.php::it":1.957,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/RefundTest.php::it":1.658,"\/Users\/luigel\/Projects\/php\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":2.194}}
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
},
"require-dev": {
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
"pestphp/pest": "^1.20|^2.34",
"pestphp/pest-plugin-parallel": "^1.0"
"pestphp/pest": "^2.34"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>

<php>
<env name="APP_ENV" value="testing" />
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/HasToggleWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function enable(Webhook $webhook)
$this->method = 'POST';
$this->apiUrl = $this->apiUrl.$webhook->getId().'/enable';

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -39,7 +39,7 @@ public function disable(Webhook $webhook)
$this->method = 'POST';
$this->apiUrl = $this->apiUrl.$webhook->getId().'/disable';

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand Down
34 changes: 17 additions & 17 deletions src/Traits/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait Request
{
protected array $data;
protected array $payload;
protected array $options;
protected array $guzzleOptions;

/**
* Request a create to API.
Expand All @@ -33,7 +33,7 @@ public function create(array $payload): BaseModel
$this->payload = $this->convertPayloadAmountsToInteger($payload);
$this->formRequestData();

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
'Content-type' => 'application/json',
Expand All @@ -53,7 +53,7 @@ public function find(string $payload): BaseModel
$this->method = 'GET';
$this->apiUrl = $this->apiUrl.$payload;

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
'Content-type' => 'application/json',
Expand All @@ -71,7 +71,7 @@ public function all(): Collection
{
$this->method = 'GET';

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
'Content-type' => 'application/json',
Expand All @@ -92,7 +92,7 @@ public function update(Webhook $webhook, array $payload): BaseModel
$this->apiUrl = $this->apiUrl.$webhook->id;

$this->formRequestData();
$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -111,7 +111,7 @@ public function cancel(PaymentIntent $intent): BaseModel
$this->method = 'POST';
$this->apiUrl = $this->apiUrl.$intent->id.'/cancel';

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -135,7 +135,7 @@ public function attach(PaymentIntent $intent, string $paymentMethodId, string|nu
}

$this->formRequestData();
$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -154,7 +154,7 @@ public function archive(Link $link)
$this->method = 'POST';
$this->apiUrl = $this->apiUrl.$link->id.'/archive';

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -172,7 +172,7 @@ public function unarchive(Link $link)
$this->method = 'POST';
$this->apiUrl = $this->apiUrl.$link->id.'/unarchive';

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -192,7 +192,7 @@ public function updateCustomer(Customer $customer, array $payload)
$this->payload = $payload;

$this->formRequestData();
$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -211,7 +211,7 @@ public function deleteCustomer(Customer $customer)
$this->method = 'DELETE';
$this->apiUrl = $this->apiUrl.$customer->id;

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -229,7 +229,7 @@ public function getPaymentMethods(Customer $customer)
$this->method = 'GET';
$this->apiUrl = $this->apiUrl.$customer->id.'/payment_methods';

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -244,7 +244,7 @@ public function expireCheckout(Checkout $checkout)
$this->method = 'POST';
$this->apiUrl = $this->apiUrl.$checkout->id.'/expire';

$this->setOptions([
$this->setGuzzleOptions([
'headers' => [
'Accept' => 'application/json',
],
Expand All @@ -268,7 +268,7 @@ protected function request(): BaseModel|Collection
$client = new Client();

try {
$response = $client->request($this->method, $this->apiUrl, $this->options);
$response = $client->request($this->method, $this->apiUrl, $this->guzzleOptions);

$array = $this->parseToArray((string) $response->getBody());

Expand Down Expand Up @@ -328,12 +328,12 @@ protected function setReturnModel($array)
/**
* Set the options.
*
* @param array $options
* @param array $guzzleOptions
* @return $this
*/
protected function setOptions($options)
protected function setGuzzleOptions($guzzleOptions)
{
$this->options = $options;
$this->guzzleOptions = $guzzleOptions;

return $this;
}
Expand Down