> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.mangopay.com/api-reference/preauthorizations/create-preauthorized-payin/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mangopay.com/_mcp/server. # Create a Preauthorized PayIn POST https://api.sandbox.mangopay.com/v2.01/{ClientId}/payins/preauthorized/direct Content-Type: application/json Create a Preauthorized PayIn Reference: https://docs.mangopay.com/api-reference/preauthorizations/create-preauthorized-payin ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. If your platform is using a [proxy](/guides/sca/proxy-management) to take SCA-triggering action on behalf of users, you also need to integrate [mTLS authentication](/guides/sca/platform) and use the `api-mtls` base URL. ## Servers - `https://api.sandbox.mangopay.com` (Sandbox, default) - `https://api.mangopay.com` (Production) - `https://api-mtls.sandbox.mangopay.com` (mTLS Sandbox) - `https://api-mtls.mangopay.com` (mTLS Production) ## Request ### Path parameters - `ClientId` (string, required) — Platform's API account identifier, associated with the API key. ### Body (application/json) This endpoint expects a CreateAPreauthorizedPayInRequest. - `DebitedFunds` (CreateAPreauthorizedPayInRequestDebitedFunds, required) — Information about the debited funds. - `Fees` (CreateAPreauthorizedPayInRequestFees, required) — Information about the fees. - `CreditedWalletId` (string, required) — The unique identifier of the credited wallet. - `PreauthorizationId` (string, required) — The unique identifier of the preauthorization. - `Tag` (string, optional) — Max. length: 255 characters Custom data that you can add to this object, such as unique identifiers in your system. To store multiple values, you can serialize them into a single string, for example a JSON object: `"{\"id_1\":AB123,\"id_2\":DE456}"`. - `AuthorId` (string, optional) — The unique identifier of the user at the source of the transaction. - `CreditedUserId` (string, optional) — **Default value:** The unique identifier of the owner of the credited wallet. The unique identifier of the user whose wallet is credited. ## Response ### 200 Success - `Id` (string, optional) — Max length: 128 characters (see [data formats](/api-reference/overview/data-formats) for details) The unique identifier of the object. - `Tag` (string, optional) — Max. length: 255 characters Custom data that you can add to this object, such as unique identifiers in your system. To store multiple values, you can serialize them into a single string, for example a JSON object: `"{\"id_1\":AB123,\"id_2\":DE456}"`. - `CreationDate` (integer, optional) — Unix timestamp (UTC) of the date and time the object was created. - `ResultCode` (string, optional) — The code indicating the result of the operation. This information is mostly used to handle errors or for filtering purposes. - `ResultMessage` (string, optional) — The explanation of the result code. - `AuthorId` (string, optional) — The unique identifier of the user at the source of the transaction. - `CreditedUserId` (string, optional) — **Default value:** The unique identifier of the owner of the credited wallet. The unique identifier of the user whose wallet is credited. - `DebitedFunds` (PreauthorizedPayInResponseDebitedFunds, optional) — Information about the debited funds. - `CreditedFunds` (PreauthorizedPayInResponseCreditedFunds, optional) — Information about the credited funds (`CreditedFunds` = `DebitedFunds` - `Fees`). - `Fees` (PreauthorizedPayInResponseFees, optional) — Information about the fees taken by the platform for this transaction (and hence transferred to the Fees Wallet). - `Status` (string, optional) — **Returned values:** `CREATED`, `SUCCEEDED`, `FAILED` The status of the transaction. - `ExecutionDate` (integer, optional) — Unix timestamp (UTC) of the date and time the status changed to `SUCCEEDED`, indicating that the transaction occurred. The statuses `CREATED` and `FAILED` return an `ExecutionDate` of `null`. - `Type` (string, optional) — **Returned values:** `PAYIN`, `TRANSFER`, `CONVERSION`, `PAYOUT` The type of the transaction. - `Nature` (string, optional) — **Returned values:** `REGULAR`, `REPUDIATION`, `REFUND`, `SETTLEMENT` The nature of the transaction, providing more information about the context in which the transaction occurred: - `REGULAR` – Relative to most of the transactions (pay-ins, payouts, and transfers) in a usual workflow. - `REPUDIATION` – Automatic withdrawal of funds from the platform's repudiation wallet as part of the dispute process (when the user has requested a chargeback). - `REFUND` – Reimbursement of a transaction to the user (pay-in refund), to a wallet (transfer refund), or of a payout (payout refund, only initiated by Mangopay). - `SETTLEMENT` – Transfer made to the repudiation wallet by the platform to settle a lost dispute. - `CreditedWalletId` (string, optional) — The unique identifier of the credited wallet. - `DebitedWalletId` (string, optional) — The unique identifier of the debited wallet. In the case of a pay-in, this value is always `null` since there is no debited wallet. - `PaymentType` (string, optional) — **Returned values:** `PREAUTHORIZED` The payment type of the pay-in. - `ExecutionType` (string, optional) — **Returned values:** `DIRECT` The execution type of the pay-in. - `PreauthorizationId` (string, optional) — The unique identifier of the preauthorization. - `AuthenticationResult` (AuthenticationResult, optional) — Information about the authentication result, based on the request made by Mangopay and the decision of the issuer regarding the type of authentication to be enforced (if applicable). ## Errors ### 400 Bad Request Error Bad Request - `Message` (string, optional) — Description of the error. - `Type` (string, optional) — The category of the error. - `Id` (string, optional) — Unique identifier of the error instance, useful when contacting Mangopay for support. - `Date` (double, optional) — Unix timestamp (UTC) of the date and time the error was triggered. - `errors` (map from string to string, optional, nullable) — Object containing one or more field-level errors. ## Types ### CreateAPreauthorizedPayInRequestDebitedFunds Information about the debited funds. - `Currency` (string, required) — **Allowed values:** The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings). The currency of the amount. - `Amount` (integer, required) — The amount of the currency in its minor unit. For example, EUR 12.60 would be represented as `1260` whereas JPY 12 would be represented as just `12`. ### CreateAPreauthorizedPayInRequestFees Information about the fees. - `Currency` (string, required) — **Allowed values:** The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings). The currency of the amount. - `Amount` (integer, required) — The amount of the currency in its minor unit. For example, EUR 12.60 would be represented as `1260` whereas JPY 12 would be represented as just `12`. ### PreauthorizedPayInResponseDebitedFunds Information about the debited funds. - `Currency` (string, optional) — **Allowed values:** The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings). The currency of the amount. - `Amount` (integer, optional) — The amount of the currency in its minor unit. For example, EUR 12.60 would be represented as `1260` whereas JPY 12 would be represented as just `12`. ### PreauthorizedPayInResponseCreditedFunds Information about the credited funds (`CreditedFunds` = `DebitedFunds` - `Fees`). - `Currency` (string, optional) — **Allowed values:** The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings). The currency of the amount. - `Amount` (integer, optional) — The amount of the currency in its minor unit. For example, EUR 12.60 would be represented as `1260` whereas JPY 12 would be represented as just `12`. ### PreauthorizedPayInResponseFees Information about the fees taken by the platform for this transaction (and hence transferred to the Fees Wallet). - `Currency` (string, optional) — **Allowed values:** The three-letter ISO 4217 code (EUR, GBP, etc.) of a supported currency (depends on feature, contract, and activation settings). The currency of the amount. - `Amount` (integer, optional) — The amount of the currency in its minor unit. For example, EUR 12.60 would be represented as `1260` whereas JPY 12 would be represented as just `12`. ### AuthenticationResult Information about the authentication result, based on the request made by Mangopay and the decision of the issuer regarding the type of authentication to be enforced (if applicable). - `AuthenticationType` (string, optional, nullable) — **Returned values:** `CHALLENGE`, `FRICTIONLESS`, `DIRECT_AUTHORIZATION` The type of authentication: - `CHALLENGE` – The issuer requested SCA to be enforced (for example, using 3DS). - `FRICTIONLESS` – The transaction was exempted from SCA because an exemption was granted by the issuer. - `DIRECT_AUTHORIZATION` – The transaction was sent to the issuer for authorization without any frictionless or challenge (for example, if SCA doesn't apply). A `null` value typically indicates that authentication was not requested (for example, because the request failed before being sent) or a decision was not received. A `null` value typically indicates that authentication was not requested (for example, because the request failed before being sent) or a decision was not received. ## Examples ### Successful capture **Request** ```json { "body": { "CreditedWalletId": "204089031", "DebitedFunds": { "Amount": 2000, "Currency": "EUR" }, "Fees": { "Amount": 200, "Currency": "EUR" }, "PreauthorizationId": "preauth_m_01HYG88W1QWJNNBGJJG0KQGX42" } } ``` **Response** ```json { "Id": "wt_8da11453-4231-4628-85c8-f8f8674b4ab8", "Tag": null, "CreationDate": 1771580679, "ResultCode": "000000", "ResultMessage": "Success", "AuthorId": "user_m_01KHRMAQT1ZPVBWK2KYM6S0N7M", "CreditedUserId": "user_m_01KH8RY4CGEYM6B5TA6JGKSYDJ", "DebitedFunds": { "Currency": "EUR", "Amount": 10000 }, "CreditedFunds": { "Currency": "EUR", "Amount": 9000 }, "Fees": { "Currency": "EUR", "Amount": 1000 }, "Status": "SUCCEEDED", "ExecutionDate": 1771580680, "Type": "PAYIN", "Nature": "REGULAR", "CreditedWalletId": "wlt_m_01KH8RY6BKXD2ZT7F76XH2TS7Z", "DebitedWalletId": null, "PaymentType": "PREAUTHORIZED", "ExecutionType": "DIRECT", "PreauthorizationId": "preauth_wt_064022a9-3640-4ed1-a4bd-3488426428fa", "AuthenticationResult": { "AuthenticationType": "CHALLENGE" } } ``` **SDK Code** ```python Successful capture from pprint import pprint import mangopay mangopay.client_id='your-client-id' mangopay.apikey='your-api-key' from mangopay.api import APIRequest handler = APIRequest(sandbox=True) from mangopay.resources import NaturalUser, PreAuthorizedPayIn from mangopay.utils import Money natural_user = NaturalUser.get('213753890') preauthorization_payin = PreAuthorizedPayIn( author_id = natural_user.id, debited_funds = Money(amount=1000, currency='GBP'), fees = Money(amount=0, currency='GBP'), credited_wallet_id = '213754077', preauthorization_id = '213944840', tag='Created using the Mangopay Python SDK' ) create_preauthorization_payin = preauthorization_payin.save() pprint(create_preauthorization_payin) ``` ```javascript Successful capture const mangopayInstance = require('mangopay4-nodejs-sdk') const mangopay = new mangopayInstance({ clientId: 'your-client-id', clientApiKey: 'your-api-key', }) let myPreauthorizedPayIn = { PaymentType: 'PREAUTHORIZED', ExecutionType: 'DIRECT', AuthorId: '192822811', Tag: 'Created with Mangopay Node.js SDK', CreditedUserId: '192822811', DebitedFunds: { Currency: 'EUR', Amount: 1000, }, Fees: { Currency: 'EUR', Amount: 100, }, CreditedWalletId: '192822814', PreauthorizationId: '192823192', } const createPreauthorizedPayin = async (payin) => { return await mangopay.PayIns.create(payin) .then((response) => { console.info(response) return response }) .catch((err) => { console.log(err) return false }) } createPreauthorizedPayin(myPreauthorizedPayIn) ``` ```java Successful capture import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.mangopay.MangoPayApi; import com.mangopay.core.Money; import com.mangopay.core.enumerations.CurrencyIso; import com.mangopay.entities.PayIn; import com.mangopay.entities.subentities.PayInExecutionDetailsDirect; import com.mangopay.entities.subentities.PayInPaymentDetailsPreAuthorized; public class CreatePreauthPayIn { public static void main(String[] args) throws Exception { MangoPayApi mangopay = new MangoPayApi(); mangopay.getConfig().setClientId("your-client-id"); mangopay.getConfig().setClientPassword("your-api-key"); var preauthId = "preauth_m_01J218VW84JAKDZS516PPTQWFW"; var userId = "user_m_01HT2NFK7Z2BRQNGNHMY30VVTT"; var walletId = "wlt_m_01HWAR863HPA3FAVEXA9J6JSYD"; PayIn payIn = new PayIn(); payIn.setCreditedWalletId(walletId); payIn.setAuthorId(userId); payIn.setTag("Created using the Mangopay Java SDK"); payIn.setDebitedFunds(new Money()); payIn.getDebitedFunds().setAmount(100); payIn.getDebitedFunds().setCurrency(CurrencyIso.EUR); payIn.setFees(new Money()); payIn.getFees().setAmount(0); payIn.getFees().setCurrency(CurrencyIso.EUR); payIn.setPaymentDetails(new PayInPaymentDetailsPreAuthorized()); ((PayInPaymentDetailsPreAuthorized) payIn.getPaymentDetails()).setPreauthorizationId(preauthId); payIn.setExecutionDetails(new PayInExecutionDetailsDirect()); ((PayInExecutionDetailsDirect) payIn.getExecutionDetails()).setSecureModeReturnUrl("https://docs.mangopay.com/please-ignore"); PayIn createPayIn = mangopay.getPayInApi().create(payIn); Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create(); String prettyJson = prettyPrint.toJson(createPayIn); System.out.println(prettyJson); } } ``` ```csharp Successful capture using MangoPay.SDK; using MangoPay.SDK.Core.Enumerations; using MangoPay.SDK.Entities; using MangoPay.SDK.Entities.POST; using Newtonsoft.Json; class Program { static async Task Main(string[] args) { MangoPayApi api = new MangoPayApi(); api.Config.ClientId = "your-client-id"; api.Config.ClientPassword = "your-api-key"; var userId = "user_m_01J2TZ261WZNDM0ZDRWGDYA4GN"; var walletId = "wlt_m_01J30991BXBB7VF28PBS82EWD3"; var preauthorizationId = "preauth_m_01J30NHM7E0TQ9W5NRQ964W7WF"; var preauthorizedPayIn = new PayInPreauthorizedDirectPostDTO ( userId, new Money { Amount = 1000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, walletId, preauthorizationId) { SecureModeReturnURL = "http://www.mangopay.com/please-ignore" }; var createPreauthorizedPayIn = await api.PayIns.CreatePreauthorizedDirectAsync(preauthorizedPayIn); string prettyPrint = JsonConvert.SerializeObject(createPreauthorizedPayIn, Formatting.Indented); Console.WriteLine(prettyPrint); } } ``` ```php Successful capture Config->ClientId = 'your-client-id'; $api->Config->ClientPassword = 'your-api-key'; $api->Config->TemporaryFolder = 'tmp/'; try { $userId = 'user_m_01HQK25M6KVHKDV0S36JY9NRKR'; $cardId = 'card_m_01J420XC7KAW655XPP12SC28HS'; $walletId = 'wlt_m_01HQT6422EER2N7FPRXWTSDCSV'; $preauthId = 'preauth_m_01JH3CJ75WGC9FMST9RH7SKBSC'; $preauthPayIn = new \MangoPay\PayIn(); $preauthPayIn->AuthorId = $userId; $preauthPayIn->CreditedWalletId = $walletId; $preauthPayIn->DebitedFunds = new Money(); $preauthPayIn->DebitedFunds->Amount = 1000; $preauthPayIn->DebitedFunds->Currency = 'EUR'; $preauthPayIn->Fees = new Money(); $preauthPayIn->Fees->Amount = 0; $preauthPayIn->Fees->Currency = 'EUR'; $preauthPayIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsPreAuthorized(); $preauthPayIn->PaymentDetails->PreauthorizationId = $preauthId; $preauthPayIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect(); $preauthPayIn->ExecutionDetails->SecureModeReturnURL = 'https://docs.mangopay.com/please-ignore'; $preauthPayIn->ExecutionDetails->Culture = 'FR'; $createPayIn = $api->PayIns->Create($preauthPayIn); print_r($createPayIn); } catch(MGPResponseException $e) { print_r($e); } catch(MGPException $e) { print_r($e); } ``` ```ruby Successful capture require 'mangopay' MangoPay.configure do |client| client.preproduction = true client.client_id = 'your-client-id' client.client_apiKey = 'your-api-key' client.log_file = File.join(Dir.pwd, 'mangopay.log') end def createPreauthorizedPayIn(payInObject) begin response = MangoPay::PayIn::PreAuthorized::Direct.create(payInObject) puts response return response rescue MangoPay::ResponseError => error puts "Failed to create preauthorized payin: #{error.message}" puts "Error details: #{error.details}" return false end end myPreauthorizedPayIn = { AuthorId: '192822811', Tag: 'Created with Mangopay Ruby SDK', CreditedUserId: '192822811', DebitedFunds: { Currency: 'EUR', Amount: 900, }, Fees: { Currency: 'EUR', Amount: 100, }, CreditedWalletId: '192822814', PreauthorizationId: '195059241' } createPreauthorizedPayIn(myPreauthorizedPayIn) ``` ### Failed: Amount greater than remaining funds **Request** ```json { "body": { "CreditedWalletId": "204089031", "DebitedFunds": { "Amount": 2000, "Currency": "EUR" }, "Fees": { "Amount": 200, "Currency": "EUR" }, "PreauthorizationId": "preauth_m_01HYG88W1QWJNNBGJJG0KQGX42" } } ``` **Response** ```json { "Id": "5ca9a5a3-8db0-4184-9322-acf521a4e210", "Tag": "capture attempt", "CreationDate": 1669115134, "ResultCode": "001505", "ResultMessage": "The PayIn DebitedFunds can't be higher than the PreAuthorization remaining amount", "AuthorId": "user_m_01HQK25M6KVHKDV0S36JY9NRKR", "CreditedUserId": "user_m_01HQK25M6KVHKDV0S36JY9NRKR", "DebitedFunds": { "Currency": "EUR", "Amount": 700 }, "CreditedFunds": { "Currency": "EUR", "Amount": 700 }, "Fees": { "Currency": "EUR", "Amount": 0 }, "Status": "FAILED", "ExecutionDate": null, "Type": "PAYIN", "Nature": "REGULAR", "CreditedWalletId": "wlt_m_01HT2J9Q2M6GMFW4Z7GYBAFJ4T", "DebitedWalletId": null, "PaymentType": "PREAUTHORIZED", "ExecutionType": "DIRECT", "PreauthorizationId": "preauth_m_01HYG88W1QWJNNBGJJG0KQGX42", "AuthenticationResult": { "AuthenticationType": "CHALLENGE" } } ``` **SDK Code** ```python Failed: Amount greater than remaining funds from pprint import pprint import mangopay mangopay.client_id='your-client-id' mangopay.apikey='your-api-key' from mangopay.api import APIRequest handler = APIRequest(sandbox=True) from mangopay.resources import NaturalUser, PreAuthorizedPayIn from mangopay.utils import Money natural_user = NaturalUser.get('213753890') preauthorization_payin = PreAuthorizedPayIn( author_id = natural_user.id, debited_funds = Money(amount=1000, currency='GBP'), fees = Money(amount=0, currency='GBP'), credited_wallet_id = '213754077', preauthorization_id = '213944840', tag='Created using the Mangopay Python SDK' ) create_preauthorization_payin = preauthorization_payin.save() pprint(create_preauthorization_payin) ``` ```javascript Failed: Amount greater than remaining funds const mangopayInstance = require('mangopay4-nodejs-sdk') const mangopay = new mangopayInstance({ clientId: 'your-client-id', clientApiKey: 'your-api-key', }) let myPreauthorizedPayIn = { PaymentType: 'PREAUTHORIZED', ExecutionType: 'DIRECT', AuthorId: '192822811', Tag: 'Created with Mangopay Node.js SDK', CreditedUserId: '192822811', DebitedFunds: { Currency: 'EUR', Amount: 1000, }, Fees: { Currency: 'EUR', Amount: 100, }, CreditedWalletId: '192822814', PreauthorizationId: '192823192', } const createPreauthorizedPayin = async (payin) => { return await mangopay.PayIns.create(payin) .then((response) => { console.info(response) return response }) .catch((err) => { console.log(err) return false }) } createPreauthorizedPayin(myPreauthorizedPayIn) ``` ```java Failed: Amount greater than remaining funds import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.mangopay.MangoPayApi; import com.mangopay.core.Money; import com.mangopay.core.enumerations.CurrencyIso; import com.mangopay.entities.PayIn; import com.mangopay.entities.subentities.PayInExecutionDetailsDirect; import com.mangopay.entities.subentities.PayInPaymentDetailsPreAuthorized; public class CreatePreauthPayIn { public static void main(String[] args) throws Exception { MangoPayApi mangopay = new MangoPayApi(); mangopay.getConfig().setClientId("your-client-id"); mangopay.getConfig().setClientPassword("your-api-key"); var preauthId = "preauth_m_01J218VW84JAKDZS516PPTQWFW"; var userId = "user_m_01HT2NFK7Z2BRQNGNHMY30VVTT"; var walletId = "wlt_m_01HWAR863HPA3FAVEXA9J6JSYD"; PayIn payIn = new PayIn(); payIn.setCreditedWalletId(walletId); payIn.setAuthorId(userId); payIn.setTag("Created using the Mangopay Java SDK"); payIn.setDebitedFunds(new Money()); payIn.getDebitedFunds().setAmount(100); payIn.getDebitedFunds().setCurrency(CurrencyIso.EUR); payIn.setFees(new Money()); payIn.getFees().setAmount(0); payIn.getFees().setCurrency(CurrencyIso.EUR); payIn.setPaymentDetails(new PayInPaymentDetailsPreAuthorized()); ((PayInPaymentDetailsPreAuthorized) payIn.getPaymentDetails()).setPreauthorizationId(preauthId); payIn.setExecutionDetails(new PayInExecutionDetailsDirect()); ((PayInExecutionDetailsDirect) payIn.getExecutionDetails()).setSecureModeReturnUrl("https://docs.mangopay.com/please-ignore"); PayIn createPayIn = mangopay.getPayInApi().create(payIn); Gson prettyPrint = new GsonBuilder().setPrettyPrinting().create(); String prettyJson = prettyPrint.toJson(createPayIn); System.out.println(prettyJson); } } ``` ```csharp Failed: Amount greater than remaining funds using MangoPay.SDK; using MangoPay.SDK.Core.Enumerations; using MangoPay.SDK.Entities; using MangoPay.SDK.Entities.POST; using Newtonsoft.Json; class Program { static async Task Main(string[] args) { MangoPayApi api = new MangoPayApi(); api.Config.ClientId = "your-client-id"; api.Config.ClientPassword = "your-api-key"; var userId = "user_m_01J2TZ261WZNDM0ZDRWGDYA4GN"; var walletId = "wlt_m_01J30991BXBB7VF28PBS82EWD3"; var preauthorizationId = "preauth_m_01J30NHM7E0TQ9W5NRQ964W7WF"; var preauthorizedPayIn = new PayInPreauthorizedDirectPostDTO ( userId, new Money { Amount = 1000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, walletId, preauthorizationId) { SecureModeReturnURL = "http://www.mangopay.com/please-ignore" }; var createPreauthorizedPayIn = await api.PayIns.CreatePreauthorizedDirectAsync(preauthorizedPayIn); string prettyPrint = JsonConvert.SerializeObject(createPreauthorizedPayIn, Formatting.Indented); Console.WriteLine(prettyPrint); } } ``` ```php Failed: Amount greater than remaining funds Config->ClientId = 'your-client-id'; $api->Config->ClientPassword = 'your-api-key'; $api->Config->TemporaryFolder = 'tmp/'; try { $userId = 'user_m_01HQK25M6KVHKDV0S36JY9NRKR'; $cardId = 'card_m_01J420XC7KAW655XPP12SC28HS'; $walletId = 'wlt_m_01HQT6422EER2N7FPRXWTSDCSV'; $preauthId = 'preauth_m_01JH3CJ75WGC9FMST9RH7SKBSC'; $preauthPayIn = new \MangoPay\PayIn(); $preauthPayIn->AuthorId = $userId; $preauthPayIn->CreditedWalletId = $walletId; $preauthPayIn->DebitedFunds = new Money(); $preauthPayIn->DebitedFunds->Amount = 1000; $preauthPayIn->DebitedFunds->Currency = 'EUR'; $preauthPayIn->Fees = new Money(); $preauthPayIn->Fees->Amount = 0; $preauthPayIn->Fees->Currency = 'EUR'; $preauthPayIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsPreAuthorized(); $preauthPayIn->PaymentDetails->PreauthorizationId = $preauthId; $preauthPayIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect(); $preauthPayIn->ExecutionDetails->SecureModeReturnURL = 'https://docs.mangopay.com/please-ignore'; $preauthPayIn->ExecutionDetails->Culture = 'FR'; $createPayIn = $api->PayIns->Create($preauthPayIn); print_r($createPayIn); } catch(MGPResponseException $e) { print_r($e); } catch(MGPException $e) { print_r($e); } ``` ```ruby Failed: Amount greater than remaining funds require 'mangopay' MangoPay.configure do |client| client.preproduction = true client.client_id = 'your-client-id' client.client_apiKey = 'your-api-key' client.log_file = File.join(Dir.pwd, 'mangopay.log') end def createPreauthorizedPayIn(payInObject) begin response = MangoPay::PayIn::PreAuthorized::Direct.create(payInObject) puts response return response rescue MangoPay::ResponseError => error puts "Failed to create preauthorized payin: #{error.message}" puts "Error details: #{error.details}" return false end end myPreauthorizedPayIn = { AuthorId: '192822811', Tag: 'Created with Mangopay Ruby SDK', CreditedUserId: '192822811', DebitedFunds: { Currency: 'EUR', Amount: 900, }, Fees: { Currency: 'EUR', Amount: 100, }, CreditedWalletId: '192822814', PreauthorizationId: '195059241' } createPreauthorizedPayIn(myPreauthorizedPayIn) ```