# Manage Customer Mandates How to create, list, and revoke mandates for recurring payments using the Mollie API. ## Create a Mandate ```php use Mollie\Api\Http\Requests\CreateMandateRequest; use Mollie\Api\Types\MandateMethod; try { // Create a SEPA Direct Debit mandate $mandate = $mollie->send( new CreateMandateRequest( customerId: 'cst_8wmqcHMN4U', method: MandateMethod::Directdebit->value, consumerName: 'B. A. Example', consumerAccount: 'NL34ABNA0243341423' ) ); echo "New mandate created: {$mandate->id}\n"; } catch (\Mollie\Api\Exceptions\ApiException $e) { echo "API call failed: " . htmlspecialchars($e->getMessage()); } ``` ## List Mandates ```php use Mollie\Api\Http\Requests\GetPaginatedMandateRequest; use Mollie\Api\Types\MandateQuery; use Mollie\Api\Types\MandateStatus; try { // List all mandates for a customer $response = $mollie->send( new GetPaginatedMandateRequest( customerId: 'cst_8wmqcHMN4U', scopes: [MandateQuery::SCOPE_CUSTOMER_NOT_PRESENT] ) ); foreach ($response as $mandate) { $status = $mandate->status instanceof MandateStatus ? $mandate->status->value : ($mandate->status ?? 'not available'); echo "Mandate {$mandate->id}:\n"; echo "- Method: " . ($mandate->method ?? 'not available') . "\n"; echo "- Status: {$status}\n"; if (isset($mandate->details->consumerName)) { echo "- Consumer: {$mandate->details->consumerName}\n"; } if (isset($mandate->details->consumerAccount)) { echo "- Account: {$mandate->details->consumerAccount}\n"; } echo "\n"; } } catch (\Mollie\Api\Exceptions\ApiException $e) { echo "API call failed: " . htmlspecialchars($e->getMessage()); } ``` ## Revoke a Mandate ```php use Mollie\Api\Http\Requests\RevokeMandateRequest; try { // Revoke a specific mandate $mollie->send( new RevokeMandateRequest( customerId: 'cst_8wmqcHMN4U', mandateId: 'mdt_h3gAaD5zP' ) ); echo "Mandate revoked\n"; } catch (\Mollie\Api\Exceptions\ApiException $e) { echo "API call failed: " . htmlspecialchars($e->getMessage()); } ``` ## The Response ```php $mandate->id; // "mdt_h3gAaD5zP" $mandate->status; // MandateStatus case, unknown raw string, or null $mandate->method; // Payment method string, or null $mandate->details; // Mandate details object, or null $mandate->customerId; // "cst_8wmqcHMN4U" $mandate->createdAt; // "2024-02-24T12:13:14+00:00" $mandate->signatureDate; // "2024-02-24" (optional) $mandate->mandateReference; // "YOUR-COMPANY-MD13804" (optional) ``` ## Additional Notes - Mandates are used for recurring payments - A customer can have multiple mandates - Only valid mandates can be used for payments - Available mandate methods: - `directdebit`: SEPA Direct Debit - `creditcard`: Credit card - Mandate status: - `valid`: The mandate is valid and can be used for payments - `pending`: The mandate is pending and cannot be used yet - `invalid`: The mandate is invalid and cannot be used - Mandates can be filtered by scope when listing: - `MandateQuery::SCOPE_CUSTOMER_PRESENT` - `MandateQuery::SCOPE_CUSTOMER_NOT_PRESENT`