Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Nov 26, 2024
1 parent 73404f0 commit e249f3e
Show file tree
Hide file tree
Showing 471 changed files with 7,812 additions and 11,083 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/fix-codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Fix Code Style

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [8.3]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, dom, curl, libxml, mbstring
coverage: none

- name: Install Pint
run: composer global require laravel/pint

- name: Run Pint
run: pint

- name: Commit linted files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Fixes coding style"
23 changes: 0 additions & 23 deletions .github/workflows/php-cs-fixer.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center">
****<p align="center">
<img src="https://github.com/mollie/mollie-api-php/assets/7265703/140510a5-ede5-41bf-9d77-0d09b906e8f4" width="128" height="128"/>
</p>

Expand Down
115 changes: 109 additions & 6 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,94 @@ This change should not have any impact on your code, but if you have a type hint
- `Mollie\Api\Resources\OrganizationCollection`
- `Mollie\Api\Resources\RouteCollection`


### Removed deprecations
The following was removed due to a deprecation
- `Mollie\Api\Types\OrderStatus::REFUNDED`
- `Mollie\Api\Types\OrderLineStatus::REFUNDED`
- all Orders related endpoints
- properties starting with `orders` prefix or related to any `Order*Endpoint`
- `orderPayments`
- `orderRefunds`
- `orderLines`
- `orderPayments`
- Shipments endpoint (all properties prefixed with `shipments` / `Shipment*Endpoint`)

### Removed non-valid method params
**Mollie\Api\EndpointCollection\CustomerPaymentsEndpointCollection**
- `createFor()` and `createForId()` removed third argument `$filters`

**Mollie\Api\EndpointCollection\InvoiceEndpointCollection**
- `get()` removed second argument `$parameters`

**Mollie\Api\EndpointCollection\MandateEndpointCollection**
- `createFor()` and `createForId()` removed third argument `$filters`

### Standardisation of function names
Accross the codebase we have had inconsistent namings like `listFor()` as well as `pageFor()` and `page()`. Those have been standardized. The following method names were changed.
**Mollie\Api\EndpointCollection\PaymentCaptureEndpointCollection**
- `createFor()` and `createForId()` removed third argument `$filters`

**Mollie\Api\Endpoints\BalanceTransactionEndpointCollection**
- `balanceTransactions->listFor()` into `balanceTransactions->page()`
### Removed methods
**Mollie\Api\EndpointCollection\InvoiceEndpointCollection**
- `all()` was removed -> use `page()` instead

### change of function names
Accross the codebase we have had inconsistent namings like `listFor()` as well as `pageFor()` and `page()`. Those have been standardized. Endpoints that return a paginated response use the `page*()` naming while non-paginated endpoints use `list*()`. The following method names were changed.

**Mollie\Api\EndpointCollection\BalanceTransactionEndpointCollection**
- `balanceTransactions->listFor()` into `balanceTransactions->pageFor()`
- `balanceTransactions->listForId()` into `balanceTransactions->pageForId()`

**Mollie\Api\Endpoints\PaymentRefundEndpointCollection**
**Mollie\Api\EndpointCollection\CustomerPaymentsEndpointCollection**
- `customerPayments->listFor()` into `customerPayments->pageFor()`
- `customerPayments->listForId()` into `customerPayments->pageForId()`

**Mollie\Api\EndpointCollection\MandateEndpointCollection**
- `mandates->listFor()` into `mandates->pageFor()`
- `mandates->listForId()` into `mandates->pageForId()`

**Mollie\Api\EndpointCollection\PaymentRefundEndpointCollection**
- `paymentRefunds->listFor()` into `paymentRefunds->pageFor()`
- `paymentRefunds->listForId()` into `paymentRefunds->pageForId()`

**Mollie\Api\EndpointCollection\MethodEndpointCollection**
- `methods->allAvailable()` has been renamed into `methods->all()` now returns all available methods (both enabled and disabled) - previously returned only all enabled methods
- former `methods->all()` has been renamed to `methods->allEnabled()`
- `methods->allActive()` is deprecated

The reasoning behind this change is to make the method names more intuitive:
- `all()` returns ALL methods (both enabled and disabled)
- `allEnabled()` returns only the enabled methods (previously called `allActive()`)
- The `allActive()` method is deprecated and will be removed in v4

**Mollie\Api\EndpointCollection\OnboardingEndpointCollection**
- `get()` was changed into `status()`
- depricated `submit()` and `create()` were removed -> use `ClientLinkEndpointCollection@create()` instead

**Mollie\Api\EndpointCollection\PaymentCaptureEndpointCollection**
- `paymentCaptures->listFor()` into `paymentCaptures->pageFor()`
- `paymentCaptures->listForId()` into `paymentCaptures->pageForId()`

**Mollie\Api\EndpointCollection\PaymentChargebackEndpointCollection**
- `listFor()` into `pageFor()`
- `listForId()` into `pageForId()`

**Mollie\Api\EndpointCollection\PaymentRefundEndpointCollection**
- `pageFor(Payment $payment, array $parameters = [])` changed to `pageFor(Payment $payment, ?string $from = null, ?int $limit = null, array $filters = [])`
- `pageForId(string $paymentId, array $parameters = [])` changed to `pageForId(string $paymentId, ?string $from = null, ?int $limit = null, array $filters = [])`

**Mollie\Api\EndpointCollection\SubscriptionEndpointCollection**
- `listFor` changed to `pageFor`
- `listForId` changed to `pageForId`
- `page` which previously returned all subscriptions, was renamed into `allFor`
- `allForId` and `iteratorForAll` were added to return all subscriptions

### Renamed methods
**Mollie\Api\EndpointCollection\PermissionEndpointCollection**
- `all()` was renamed to `list()` to maintain consistency with other non-paginated endpoints

### Removed non-valid method params
**Mollie\Api\EndpointCollection\PermissionEndpointCollection**
- `get()` second argument changed from `array $parameters` to `array|bool $testmode` to match API documentation

# Changelog
### Type cast embeded Resources
In previous versions resources requested via `embed` param on requests like [get-payment](https://docs.mollie.com/reference/get-payment) were not casted into their respective collection or resource classes. Starting with this version all embeded resources are typecasted.
Expand Down Expand Up @@ -167,3 +238,35 @@ With this you get a `Response` and can also inspect its status, body or any othe
## Some Context...
..on how the new request cycle works
<img width="1190" alt="Screenshot 2024-09-09 at 11 03 17" src="https://github.com/user-attachments/assets/89c8ba43-bde5-4619-82e9-7f1ef752d7de">

### Added contractId parameter for Method Issuers
The `enable()` method on the `MethodIssuerEndpointCollection` now supports an optional `contractId` parameter when enabling voucher issuers. This parameter can be used when an intermediary party (contractor) is involved([1](https://docs.mollie.com/reference/enable-method-issuer)).

```php
// Enable a method issuer with a contract ID
$issuer = $mollie->methodIssuers->enable(
profileId: 'pfl_...',
methodId: 'voucher',
issuerId: 'issuer_id',
contractId: 'contract_123' // Optional parameter
);
```

The contract ID can be updated as long as it hasn't been approved yet by repeating the API call with a different contract ID.

### Added optional testmode parameter
The following methods now accept an optional `testmode` parameter:

**Mollie\Api\EndpointCollection\PaymentLinkEndpointCollection**
- `get(string $paymentLinkId, ?bool $testmode = null)`
- `update(string $paymentLinkId, $payload = [], ?bool $testmode = null)`
- `delete(string $paymentLinkId, ?bool $testmode = null)`

This parameter can be used when working with organization-level credentials such as OAuth access tokens to specify whether the operation should be performed in test mode. For API key credentials, this parameter can be omitted as the mode is determined by the key type.

```php
// Example with testmode parameter
$paymentLink = $mollie->paymentLinks->get('pl_...', testmode: true);
$paymentLink = $mollie->paymentLinks->update('pl_...', ['description' => 'Updated'], testmode: true);
$mollie->paymentLinks->delete('pl_...', testmode: true);
```
14 changes: 7 additions & 7 deletions examples/captures/create-capture.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* See: https://www.mollie.com/dashboard/developers/api-keys
*/
require "../initialize.php";
require '../initialize.php';

/*
* Capture parameters:
Expand All @@ -19,14 +19,14 @@
*/
$capture = $mollie
->paymentCaptures->createForId('tr_WDqYK6vllg', [
"amount" => [
"currency" => "EUR",
"value" => "5.00",
'amount' => [
'currency' => 'EUR',
'value' => '5.00',
],
"description" => "Order #12345",
'description' => 'Order #12345',
]);

echo "<p>New capture created " . htmlspecialchars($capture->id) . " (" . htmlspecialchars($capture->description) . ").</p>";
echo '<p>New capture created '.htmlspecialchars($capture->id).' ('.htmlspecialchars($capture->description).').</p>';
} catch (\Mollie\Api\Exceptions\ApiException $e) {
echo "API call failed: " . htmlspecialchars($e->getMessage());
echo 'API call failed: '.htmlspecialchars($e->getMessage());
}
8 changes: 4 additions & 4 deletions examples/captures/get-capture.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/*
* Initialize the Mollie API library with your API key or OAuth access token.
*/
require "../initialize.php";
require '../initialize.php';

/*
* Retrieve a capture with ID 'cpt_4qqhO89gsT' for payment with
Expand All @@ -19,9 +19,9 @@
$payment = $mollie->payments->get('tr_WDqYK6vllg');
$capture = $payment->getCapture('cpt_4qqhO89gsT');

$amount = $capture->amount->currency . ' ' . $capture->amount->value;
$amount = $capture->amount->currency.' '.$capture->amount->value;

echo 'Captured ' . $amount;
echo 'Captured '.$amount;
} catch (\Mollie\Api\Exceptions\ApiException $e) {
echo "API call failed: " . htmlspecialchars($e->getMessage());
echo 'API call failed: '.htmlspecialchars($e->getMessage());
}
8 changes: 4 additions & 4 deletions examples/captures/list-captures.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/*
* Initialize the Mollie API library with your API key or OAuth access token.
*/
require "../initialize.php";
require '../initialize.php';

/*
* List captures for payment with ID 'tr_WDqYK6vllg'.
Expand All @@ -19,9 +19,9 @@
$captures = $payment->captures();

foreach ($captures as $capture) {
$amount = $capture->amount->currency . ' ' . $capture->amount->value;
echo 'Captured ' . $amount . ' for payment ' . $payment->id;
$amount = $capture->amount->currency.' '.$capture->amount->value;
echo 'Captured '.$amount.' for payment '.$payment->id;
}
} catch (\Mollie\Api\Exceptions\ApiException $e) {
echo "API call failed: " . htmlspecialchars($e->getMessage());
echo 'API call failed: '.htmlspecialchars($e->getMessage());
}
36 changes: 18 additions & 18 deletions examples/client-links/create-client-link.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
/*
* Initialize the Mollie API library with your API key or OAuth access token.
*/
require "../initialize.php";
require '../initialize.php';

/*
* Determine the url parts to these example files.
*/
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? 'https' : 'http';
$hostname = $_SERVER['HTTP_HOST'];
$path = dirname($_SERVER['REQUEST_URI'] ?? $_SERVER['PHP_SELF']);

Expand All @@ -22,21 +22,21 @@
* See: https://docs.mollie.com/reference/v2/client-links-api/create-client-link
*/
$clientLink = $mollie->clientLinks->create([
"owner" => [
"email" => "[email protected]",
"givenName" => "foo",
"familyName" => "bar",
"locale" => "nl_NL",
'owner' => [
'email' => '[email protected]',
'givenName' => 'foo',
'familyName' => 'bar',
'locale' => 'nl_NL',
],
"name" => "Foo Company",
"address" => [
"streetAndNumber" => "Keizersgracht 313",
"postalCode" => "1016 EE",
"city" => "Amsterdam",
"country" => "nl",
'name' => 'Foo Company',
'address' => [
'streetAndNumber' => 'Keizersgracht 313',
'postalCode' => '1016 EE',
'city' => 'Amsterdam',
'country' => 'nl',
],
"registrationNumber" => "30204462",
"vatNumber" => "NL123456789B01",
'registrationNumber' => '30204462',
'vatNumber' => 'NL123456789B01',
]);

/**
Expand All @@ -46,7 +46,7 @@
*
* For more info see: https://docs.mollie.com/reference/oauth2/authorize#parameters
*/
$redirectUrl = $clientLink->getRedirectUrl("app_j9Pakf56Ajta6Y65AkdTtAv", "decafbad", "force", [
$redirectUrl = $clientLink->getRedirectUrl('app_j9Pakf56Ajta6Y65AkdTtAv', 'decafbad', 'force', [
'onboarding.read',
'onboarding.write',
]);
Expand All @@ -55,7 +55,7 @@
* Send the customer off to finalize the organization creation.
* This request should always be a GET, thus we enforce 303 http response code
*/
header("Location: " . $redirectUrl, true, 303);
header('Location: '.$redirectUrl, true, 303);
} catch (\Mollie\Api\Exceptions\ApiException $e) {
echo "API call failed: " . htmlspecialchars($e->getMessage());
echo 'API call failed: '.htmlspecialchars($e->getMessage());
}
Loading

0 comments on commit e249f3e

Please sign in to comment.