diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 167b319..3e606cf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,11 +21,9 @@ jobs: matrix: os: [ubuntu-latest] php: [8.1, 8.2, 8.3] - laravel: ['9.*', '10.*', '11.*'] + laravel: ['10.*', '11.*'] stability: [prefer-lowest, prefer-stable] include: - - laravel: 9.* - testbench: 7.* - laravel: 10.* testbench: 8.* - laravel: 11.* @@ -33,10 +31,6 @@ jobs: exclude: - laravel: 11.* php: 8.1 - - laravel: 9.* - php: 8.3 - - laravel: 9.* - php: 8.2 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -57,5 +51,9 @@ jobs: composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction + - name: Install parallel dependencies + if: matrix.laravel == '9.*' + run: composer require --dev --no-interaction --no-update "pestphp/pest-plugin-parallel" + - name: Execute tests run: vendor/bin/pest --coverage --parallel diff --git a/.gitignore b/.gitignore index 05d5053..e1a489e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock vendor coverage .env* +.idea diff --git a/.phpunit.result.cache b/.phpunit.result.cache index 3054883..c06df3c 100644 --- a/.phpunit.result.cache +++ b/.phpunit.result.cache @@ -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}} \ No newline at end of file +{"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}} \ No newline at end of file diff --git a/composer.json b/composer.json index d5d82b9..69a375b 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ }, "require-dev": { "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0", - "pestphp/pest": "^2.34" + "pestphp/pest": "^1.0|^2.34" }, "autoload": { "psr-4": { diff --git a/src/Traits/HasToggleWebhook.php b/src/Traits/HasToggleWebhook.php index a2e2175..f3c9d4b 100644 --- a/src/Traits/HasToggleWebhook.php +++ b/src/Traits/HasToggleWebhook.php @@ -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', ], @@ -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', ], diff --git a/src/Traits/Request.php b/src/Traits/Request.php index 03beecc..72cac28 100644 --- a/src/Traits/Request.php +++ b/src/Traits/Request.php @@ -22,7 +22,7 @@ trait Request { protected array $data; protected array $payload; - protected array $options; + protected array $guzzleOptions; /** * Request a create to API. @@ -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', @@ -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', @@ -71,7 +71,7 @@ public function all(): Collection { $this->method = 'GET'; - $this->setOptions([ + $this->setGuzzleOptions([ 'headers' => [ 'Accept' => 'application/json', 'Content-type' => 'application/json', @@ -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', ], @@ -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', ], @@ -135,7 +135,7 @@ public function attach(PaymentIntent $intent, string $paymentMethodId, string|nu } $this->formRequestData(); - $this->setOptions([ + $this->setGuzzleOptions([ 'headers' => [ 'Accept' => 'application/json', ], @@ -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', ], @@ -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', ], @@ -192,7 +192,7 @@ public function updateCustomer(Customer $customer, array $payload) $this->payload = $payload; $this->formRequestData(); - $this->setOptions([ + $this->setGuzzleOptions([ 'headers' => [ 'Accept' => 'application/json', ], @@ -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', ], @@ -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', ], @@ -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', ], @@ -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()); @@ -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; }