Initial commit
This commit is contained in:
commit
2b9e58beee
822 files changed
+62544
No files matched your search
Vendored
+151
@@ -0,0 +1,151 @@
|
||||
# Create a Connect Balance Transfer
|
||||
|
||||
How to create a balance transfer between two connected Mollie balances using the API.
|
||||
|
||||
## The Code
|
||||
|
||||
```php
|
||||
use Mollie\Api\Http\Data\Money;
|
||||
use Mollie\Api\Http\Data\TransferParty;
|
||||
use Mollie\Api\Http\Requests\CreateConnectBalanceTransferRequest;
|
||||
use Mollie\Api\Types\ConnectBalanceTransferCategory;
|
||||
|
||||
try {
|
||||
// Initialize the Mollie client with your OAuth access token
|
||||
$mollie = new \Mollie\Api\MollieApiClient();
|
||||
$mollie->setAccessToken('access_xxx');
|
||||
|
||||
// Create a balance transfer
|
||||
$balanceTransfer = $mollie->send(
|
||||
new CreateConnectBalanceTransferRequest(
|
||||
amount: new Money(
|
||||
currency: 'EUR',
|
||||
value: '100.00'
|
||||
),
|
||||
description: 'Transfer from balance A to balance B',
|
||||
source: new TransferParty(
|
||||
id: 'org_12345678',
|
||||
description: 'Payment from Organization A'
|
||||
),
|
||||
destination: new TransferParty(
|
||||
id: 'org_87654321',
|
||||
description: 'Payment to Organization B'
|
||||
),
|
||||
category: ConnectBalanceTransferCategory::ManualCorrection
|
||||
)
|
||||
);
|
||||
|
||||
echo "Balance transfer created: {$balanceTransfer->id}\n";
|
||||
echo "Amount: {$balanceTransfer->amount->currency} {$balanceTransfer->amount->value}\n";
|
||||
echo "Status: Transfer initiated\n";
|
||||
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
||||
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
||||
}
|
||||
```
|
||||
|
||||
## Using Endpoint Collections (Legacy Style)
|
||||
|
||||
```php
|
||||
try {
|
||||
// Create a balance transfer using endpoint collections
|
||||
$balanceTransfer = $mollie->connectBalanceTransfers->create([
|
||||
'amount' => [
|
||||
'currency' => 'EUR',
|
||||
'value' => '100.00'
|
||||
],
|
||||
'description' => 'Transfer from balance A to balance B',
|
||||
'source' => [
|
||||
'type' => 'organization',
|
||||
'id' => 'org_12345678',
|
||||
'description' => 'Payment from Organization A'
|
||||
],
|
||||
'destination' => [
|
||||
'type' => 'organization',
|
||||
'id' => 'org_87654321',
|
||||
'description' => 'Payment to Organization B'
|
||||
],
|
||||
'category' => 'manual_correction'
|
||||
]);
|
||||
|
||||
echo "Balance transfer created: {$balanceTransfer->id}\n";
|
||||
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
||||
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
||||
}
|
||||
```
|
||||
|
||||
## The Response
|
||||
|
||||
```php
|
||||
$balanceTransfer->id; // "cbt_4KgGJJSZpH"
|
||||
$balanceTransfer->resource; // "connect-balance-transfer"
|
||||
$balanceTransfer->amount->currency; // "EUR"
|
||||
$balanceTransfer->amount->value; // "100.00"
|
||||
$balanceTransfer->description; // "Transfer from balance A to balance B"
|
||||
$balanceTransfer->status; // "created", "failed", "succeeded"
|
||||
$balanceTransfer->statusReason; // Object with status reason (if applicable)
|
||||
$balanceTransfer->category; // "manual_correction", "purchase", "refund", etc.
|
||||
$balanceTransfer->source->type; // "organization"
|
||||
$balanceTransfer->source->id; // "org_12345678"
|
||||
$balanceTransfer->source->description; // "Payment from Organization A"
|
||||
$balanceTransfer->destination->type; // "organization"
|
||||
$balanceTransfer->destination->id; // "org_87654321"
|
||||
$balanceTransfer->destination->description; // "Payment to Organization B"
|
||||
$balanceTransfer->executedAt; // "2023-12-25T10:31:00+00:00" (null if not executed)
|
||||
$balanceTransfer->mode; // "live" or "test"
|
||||
$balanceTransfer->createdAt; // "2023-12-25T10:30:54+00:00"
|
||||
```
|
||||
|
||||
## Transfer Status
|
||||
|
||||
The transfer status indicates the current state of the transfer:
|
||||
|
||||
```php
|
||||
// Check transfer status
|
||||
if ($balanceTransfer->status === 'succeeded') {
|
||||
echo "Transfer completed successfully\n";
|
||||
echo "Executed at: {$balanceTransfer->executedAt}\n";
|
||||
} elseif ($balanceTransfer->status === 'failed') {
|
||||
echo "Transfer failed\n";
|
||||
if ($balanceTransfer->statusReason) {
|
||||
echo "Reason: " . json_encode($balanceTransfer->statusReason) . "\n";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Transfer Categories
|
||||
|
||||
Different transfer categories may have different fees:
|
||||
|
||||
- `invoice_collection` - Collecting invoice payments
|
||||
- `purchase` - Purchase-related transfers
|
||||
- `chargeback` - Chargeback transfers
|
||||
- `refund` - Refund transfers
|
||||
- `service_penalty` - Service penalty fees
|
||||
- `discount_compensation` - Discount compensations
|
||||
- `manual_correction` - Manual corrections
|
||||
- `other_fee` - Other fees
|
||||
|
||||
## Additional Notes
|
||||
|
||||
- **OAuth Required**: You need an OAuth access token to create balance transfers. API keys are not supported for this endpoint.
|
||||
- **Sub-merchant consent**: You must have a documented consent from your sub-merchants authorizing balance movements.
|
||||
- **Balance Ownership**: You can only transfer funds between balances that belong to organizations connected through your OAuth app.
|
||||
- **Transfer Speed**: Balance transfers are processed immediately. The funds are moved instantly between the balances.
|
||||
- **Status Tracking**: Monitor the `status` field to track transfer completion. Check `executedAt` for the exact completion time.
|
||||
- **Currency Requirements**:
|
||||
- Both balances must use the same currency
|
||||
- The transfer amount must match the balance currency
|
||||
- **Balance Validation**:
|
||||
- The source balance must have sufficient available funds
|
||||
- Both balances must be active and operational
|
||||
- **Use Cases**:
|
||||
- Moving funds between merchant balances in a marketplace
|
||||
- Redistributing funds across different connected accounts
|
||||
- Managing liquidity between multiple balances
|
||||
- **Permissions**: Your OAuth app must have the appropriate scopes to access and transfer between the balances
|
||||
- **Idempotency**: Consider using idempotency keys when creating transfers to prevent duplicate transfers in case of network issues
|
||||
|
||||
## Related Resources
|
||||
|
||||
- [List Connect Balance Transfers](list-balance-transfers.md)
|
||||
- [Get Connect Balance Transfer](get-balance-transfer.md)
|
||||
Vendored
+105
@@ -0,0 +1,105 @@
|
||||
# Get a Connect Balance Transfer
|
||||
|
||||
How to retrieve details of a specific connect balance transfer using the Mollie API.
|
||||
|
||||
## The Code
|
||||
|
||||
```php
|
||||
use Mollie\Api\Http\Requests\GetConnectBalanceTransferRequest;
|
||||
|
||||
try {
|
||||
// Initialize the Mollie client with your OAuth access token
|
||||
$mollie = new \Mollie\Api\MollieApiClient();
|
||||
$mollie->setAccessToken('access_xxx');
|
||||
|
||||
// Get a specific balance transfer
|
||||
$balanceTransfer = $mollie->send(
|
||||
new GetConnectBalanceTransferRequest(
|
||||
id: 'cbt_4KgGJJSZpH'
|
||||
)
|
||||
);
|
||||
|
||||
echo "Balance Transfer {$balanceTransfer->id}:\n";
|
||||
echo "- Amount: {$balanceTransfer->amount->currency} {$balanceTransfer->amount->value}\n";
|
||||
echo "- Description: {$balanceTransfer->description}\n";
|
||||
echo "- From: {$balanceTransfer->source->balanceId}\n";
|
||||
echo "- To: {$balanceTransfer->destination->balanceId}\n";
|
||||
echo "- Created: {$balanceTransfer->createdAt}\n";
|
||||
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
||||
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
||||
}
|
||||
```
|
||||
|
||||
## Using Endpoint Collections (Legacy Style)
|
||||
|
||||
```php
|
||||
try {
|
||||
// Get a balance transfer using endpoint collections
|
||||
$balanceTransfer = $mollie->connectBalanceTransfers->get('cbt_4KgGJJSZpH');
|
||||
|
||||
echo "Transfer amount: {$balanceTransfer->amount->value}\n";
|
||||
echo "Transfer description: {$balanceTransfer->description}\n";
|
||||
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
||||
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
||||
}
|
||||
```
|
||||
|
||||
## The Response
|
||||
|
||||
```php
|
||||
$balanceTransfer->id; // "cbt_4KgGJJSZpH"
|
||||
$balanceTransfer->resource; // "connect-balance-transfer"
|
||||
$balanceTransfer->amount->currency; // "EUR"
|
||||
$balanceTransfer->amount->value; // "100.00"
|
||||
$balanceTransfer->description; // "Transfer from balance A to balance B"
|
||||
$balanceTransfer->status; // "created", "failed", "succeeded"
|
||||
$balanceTransfer->statusReason; // Object with status reason (if applicable)
|
||||
$balanceTransfer->category; // "manual_correction", "purchase", "refund", etc.
|
||||
$balanceTransfer->source->type; // "organization"
|
||||
$balanceTransfer->source->id; // "org_12345678"
|
||||
$balanceTransfer->source->description; // "Payment from Organization A"
|
||||
$balanceTransfer->destination->type; // "organization"
|
||||
$balanceTransfer->destination->id; // "org_87654321"
|
||||
$balanceTransfer->destination->description; // "Payment to Organization B"
|
||||
$balanceTransfer->executedAt; // "2023-12-25T10:31:00+00:00" (null if not executed)
|
||||
$balanceTransfer->mode; // "live" or "test"
|
||||
$balanceTransfer->createdAt; // "2023-12-25T10:30:54+00:00"
|
||||
$balanceTransfer->_links; // Object containing relevant URLs
|
||||
```
|
||||
|
||||
## Transfer Party Details
|
||||
|
||||
Access the transfer party information:
|
||||
|
||||
```php
|
||||
// Source party details
|
||||
echo "Source Organization:\n";
|
||||
echo "- Type: {$balanceTransfer->source->type}\n"; // "organization"
|
||||
echo "- ID: {$balanceTransfer->source->id}\n"; // Organization token
|
||||
echo "- Description: {$balanceTransfer->source->description}\n";
|
||||
|
||||
// Destination party details
|
||||
echo "Destination Organization:\n";
|
||||
echo "- Type: {$balanceTransfer->destination->type}\n";
|
||||
echo "- ID: {$balanceTransfer->destination->id}\n";
|
||||
echo "- Description: {$balanceTransfer->destination->description}\n";
|
||||
```
|
||||
|
||||
## Additional Notes
|
||||
|
||||
- **OAuth Required**: You need an OAuth access token to retrieve balance transfer details
|
||||
- **Access Control**: You can only retrieve transfers involving balances accessible through your OAuth app
|
||||
- **Transfer Tracking**: Use the transfer ID to track and audit balance movements
|
||||
- **Embedded Data**: The response may include embedded balance details for both source and destination balances
|
||||
- **Links**: The `_links` object contains URLs to related resources:
|
||||
- `self`: Link to this balance transfer
|
||||
- `documentation`: Link to API documentation
|
||||
- **Audit Trail**: Store transfer IDs in your system for reconciliation and reporting purposes
|
||||
- **Error Handling**:
|
||||
- Returns 404 if the transfer ID doesn't exist
|
||||
- Returns 403 if you don't have permission to access this transfer
|
||||
|
||||
## Related Resources
|
||||
|
||||
- [Create Connect Balance Transfer](create-balance-transfer.md)
|
||||
- [List Connect Balance Transfers](list-balance-transfers.md)
|
||||
Vendored
+177
@@ -0,0 +1,177 @@
|
||||
# List Connect Balance Transfers
|
||||
|
||||
How to retrieve a list of all connect balance transfers using the Mollie API.
|
||||
|
||||
## The Code
|
||||
|
||||
```php
|
||||
use Mollie\Api\Http\Requests\ListConnectBalanceTransfersRequest;
|
||||
|
||||
try {
|
||||
// Initialize the Mollie client with your OAuth access token
|
||||
$mollie = new \Mollie\Api\MollieApiClient();
|
||||
$mollie->setAccessToken('access_xxx');
|
||||
|
||||
// List all balance transfers
|
||||
$balanceTransfers = $mollie->send(
|
||||
new ListConnectBalanceTransfersRequest()
|
||||
);
|
||||
|
||||
foreach ($balanceTransfers as $transfer) {
|
||||
echo "Transfer {$transfer->id}:\n";
|
||||
echo "- Amount: {$transfer->amount->currency} {$transfer->amount->value}\n";
|
||||
echo "- Description: {$transfer->description}\n";
|
||||
echo "- From: {$transfer->source->balanceId}\n";
|
||||
echo "- To: {$transfer->destination->balanceId}\n";
|
||||
echo "- Created: {$transfer->createdAt}\n\n";
|
||||
}
|
||||
|
||||
// Get the next page if available
|
||||
if ($balanceTransfers->hasNext()) {
|
||||
$nextPage = $balanceTransfers->next();
|
||||
// Process next page...
|
||||
}
|
||||
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
||||
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
||||
}
|
||||
```
|
||||
|
||||
## With Pagination Parameters
|
||||
|
||||
```php
|
||||
use Mollie\Api\Http\Requests\ListConnectBalanceTransfersRequest;
|
||||
|
||||
try {
|
||||
// List balance transfers with pagination
|
||||
$balanceTransfers = $mollie->send(
|
||||
new ListConnectBalanceTransfersRequest(
|
||||
from: 'cbt_8KhHNOSdpL', // Start from this ID
|
||||
limit: 50, // Limit to 50 results
|
||||
sort: 'createdAt' // Sort by creation date
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($balanceTransfers as $transfer) {
|
||||
// Process each transfer...
|
||||
}
|
||||
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
||||
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
||||
}
|
||||
```
|
||||
|
||||
## Using Iterator for All Transfers
|
||||
|
||||
```php
|
||||
use Mollie\Api\Http\Requests\ListConnectBalanceTransfersRequest;
|
||||
|
||||
try {
|
||||
// Use iterator to automatically handle pagination
|
||||
$request = new ListConnectBalanceTransfersRequest();
|
||||
|
||||
$allTransfers = $mollie->send($request->useIterator());
|
||||
|
||||
foreach ($allTransfers as $transfer) {
|
||||
echo "Transfer {$transfer->id}: ";
|
||||
echo "{$transfer->amount->currency} {$transfer->amount->value}\n";
|
||||
}
|
||||
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
||||
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
||||
}
|
||||
```
|
||||
|
||||
## Using Endpoint Collections (Legacy Style)
|
||||
|
||||
```php
|
||||
try {
|
||||
// List balance transfers using endpoint collections
|
||||
$balanceTransfers = $mollie->connectBalanceTransfers->page();
|
||||
|
||||
foreach ($balanceTransfers as $transfer) {
|
||||
echo "Transfer: {$transfer->description}\n";
|
||||
echo "Amount: {$transfer->amount->value}\n\n";
|
||||
}
|
||||
|
||||
// Use iterator for automatic pagination
|
||||
foreach ($mollie->connectBalanceTransfers->iterator() as $transfer) {
|
||||
// Process each transfer across all pages...
|
||||
}
|
||||
} catch (\Mollie\Api\Exceptions\ApiException $e) {
|
||||
echo "API call failed: " . htmlspecialchars($e->getMessage());
|
||||
}
|
||||
```
|
||||
|
||||
## The Response
|
||||
|
||||
```php
|
||||
// Collection properties
|
||||
$balanceTransfers->count; // Number of transfers in current page
|
||||
$balanceTransfers->_links; // Pagination links
|
||||
|
||||
// Individual transfer properties
|
||||
$transfer->id; // "cbt_4KgGJJSZpH"
|
||||
$transfer->resource; // "connect-balance-transfer"
|
||||
$transfer->amount->currency; // "EUR"
|
||||
$transfer->amount->value; // "100.00"
|
||||
$transfer->description; // "Transfer from balance A to balance B"
|
||||
$transfer->status; // "created", "failed", "succeeded"
|
||||
$transfer->category; // "manual_correction", "purchase", "refund", etc.
|
||||
$transfer->source->type; // "organization"
|
||||
$transfer->source->id; // "org_12345678"
|
||||
$transfer->source->description; // "Payment from Organization A"
|
||||
$transfer->destination->type; // "organization"
|
||||
$transfer->destination->id; // "org_87654321"
|
||||
$transfer->destination->description; // "Payment to Organization B"
|
||||
$transfer->executedAt; // "2023-12-25T10:31:00+00:00" (null if not executed)
|
||||
$transfer->mode; // "live" or "test"
|
||||
$transfer->createdAt; // "2023-12-25T10:30:54+00:00"
|
||||
```
|
||||
|
||||
## Pagination Methods
|
||||
|
||||
```php
|
||||
// Check if there's a next page
|
||||
if ($balanceTransfers->hasNext()) {
|
||||
$nextPage = $balanceTransfers->next();
|
||||
}
|
||||
|
||||
// Check if there's a previous page
|
||||
if ($balanceTransfers->hasPrevious()) {
|
||||
$previousPage = $balanceTransfers->previous();
|
||||
}
|
||||
|
||||
// Get auto-iterator for all transfers
|
||||
$iterator = $balanceTransfers->getAutoIterator();
|
||||
foreach ($iterator as $transfer) {
|
||||
// Processes all transfers across all pages automatically
|
||||
}
|
||||
```
|
||||
|
||||
## Additional Notes
|
||||
|
||||
- **OAuth Required**: You need an OAuth access token to list balance transfers
|
||||
- **Access Scope**: The list includes only transfers involving balances accessible through your OAuth app
|
||||
- **Pagination**:
|
||||
- Results are paginated with a default limit
|
||||
- Use `from` parameter to start from a specific transfer ID
|
||||
- Use `limit` to control the number of results per page (max 250)
|
||||
- **Sorting**:
|
||||
- Transfers are returned in descending order by creation date (newest first)
|
||||
- Use the `sort` parameter to customize ordering
|
||||
- **Filtering**: Currently, there are no filter parameters available. All accessible transfers are returned.
|
||||
- **Performance**:
|
||||
- Use the iterator for processing large numbers of transfers
|
||||
- The iterator automatically handles pagination
|
||||
- Set appropriate limits to balance between API calls and memory usage
|
||||
- **Iteration Direction**:
|
||||
- By default, iteration goes forward (newest to oldest)
|
||||
- Set `iterateBackwards: true` to reverse the direction
|
||||
- **Use Cases**:
|
||||
- Financial reporting and reconciliation
|
||||
- Audit trails for balance movements
|
||||
- Analyzing transfer patterns
|
||||
- Monitoring platform activity
|
||||
|
||||
## Related Resources
|
||||
|
||||
- [Create Connect Balance Transfer](create-balance-transfer.md)
|
||||
- [Get Connect Balance Transfer](get-balance-transfer.md)
|
||||
Reference in new issue
Block a user