### Run Mangopay Ruby SDK Tests Source: https://github.com/mangopay/mangopay2-ruby-sdk/blob/master/README.md This command installs dependencies and runs the RSpec tests for the Mangopay Ruby SDK. Ensure you have Bundler installed. This is a prerequisite for submitting pull requests. ```bash bundle && bundle exec rspec ``` -------------------------------- ### Start MANGOPAY Console (Non-Rails) Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Home Command to launch a Ruby console with the MANGOPAY gem pre-loaded for non-Rails environments. ```bash mangopay ``` -------------------------------- ### Install MANGOPAY Gem (Non-Rails) Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Home Instructions to install the MANGOPAY gem globally or add it to a non-Rails project's Gemfile. ```bash gem install mangopay ``` ```ruby gem 'mangopay' ``` ```bash bundle install ``` -------------------------------- ### Install MANGOPAY Gem in Rails Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Home Instructions to add the MANGOPAY gem to a Rails application's Gemfile and install it using bundler. ```ruby gem 'mangopay', '~> 3.0.0' ``` ```bash bundle install ``` -------------------------------- ### Fetch All Users - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/User/User This snippet demonstrates how to retrieve a list of all users managed by MangoPay using the Ruby SDK. It requires no arguments and returns an array of User objects. Ensure the MangoPay gem is installed and configured. ```ruby MangoPay::User.fetch() ``` -------------------------------- ### GET /users/{userId}/bankaccounts/{bankAccountId} Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/BankAccounts/BankAccounts Retrieves a specific bank account for a given user. ```APIDOC ## GET /users/{userId}/bankaccounts/{bankAccountId} ### Description Retrieves the details of a specific bank account associated with a user. ### Method GET ### Endpoint `/users/{userId}/bankaccounts/{bankAccountId}` ### Parameters #### Path Parameters - **userId** (Integer) - Required - The ID of the user. - **bankAccountId** (Integer) - Required - The ID of the bank account to retrieve. ### Response #### Success Response (200) - **BankAccount** (Object) - The requested BankAccount Object. #### Response Example ```json { "Id": 32132, "Tag": "Default Account", "CreationDate": 1678886400, "UserId": 87323, "Type": "IBAN", "OwnerName": "Jane Doe", "OwnerAddress": "Some Address", "IBAN": "GB29NWBK60161331926819", "BIC": "NWBKGB2L" } ``` ``` -------------------------------- ### GET /users/{userId}/bankaccounts Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/BankAccounts/BankAccounts Retrieves all bank accounts associated with a given user. ```APIDOC ## GET /users/{userId}/bankaccounts ### Description Retrieves a list of all bank accounts associated with a specified user. ### Method GET ### Endpoint `/users/{userId}/bankaccounts` ### Parameters #### Path Parameters - **userId** (Integer) - Required - The ID of the user whose bank accounts are to be fetched. ### Response #### Success Response (200) - **BankAccounts** (Array) - An array of BankAccount Objects belonging to the user. #### Response Example ```json [ { "Id": 32132, "Tag": "Default Account", "CreationDate": 1678886400, "UserId": 87323, "Type": "IBAN", "OwnerName": "Jane Doe", "OwnerAddress": "Some Address", "IBAN": "GB29NWBK60161331926819", "BIC": "NWBKGB2L" }, { "Id": 32133, "Tag": "Secondary Account", "CreationDate": 1678972800, "UserId": 87323, "Type": "IBAN", "OwnerName": "Jane Doe", "OwnerAddress": "Some Address", "IBAN": "DE89370400440532013000", "BIC": "COBADEFFXXX" } ] ``` ``` -------------------------------- ### GET /payin/{payin_web_card_id} Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/PayIn/PayIn Retrieves a specific PayInWebCard object using its ID. ```APIDOC ## GET /payin/{payin_web_card_id} ### Description Retrieves a specific PayInWebCard object using its ID. ### Method GET ### Endpoint /payin/{payin_web_card_id} ### Parameters #### Path Parameters - **payin_web_card_id** (Integer) - Required - The ID of the PayInWebCard to fetch. ### Response #### Success Response (200) - **PayInWebCard** (Object) - The requested PayInWebCard object. ``` -------------------------------- ### GET /wallets/{wallet_id}/transactions Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Transaction/Transaction Retrieves a list of all transactions for a specific wallet. You can filter the transactions by various criteria. ```APIDOC ## GET /wallets/{wallet_id}/transactions ### Description Retrieves all transactions for a given wallet, with optional filtering. ### Method GET ### Endpoint `/wallets/{wallet_id}/transactions` ### Parameters #### Path Parameters * **wallet_id** (string) - Required - The ID of the wallet to fetch transactions from. #### Query Parameters * **Status** (string) - Optional - Filters transactions by status. Possible values: `CREATED`, `SUCCEEDED`, `FAILED`. * **Type** (string) - Optional - Filters transactions by type. Possible values: `PAY_IN`, `PAY_OUT`, `TRANSFER`. * **Nature** (string) - Optional - Filters transactions by nature. Possible values: `NORMAL`, `REFUND`, `REPUDIATION`. * **Direction** (string) - Optional - Filters transactions by direction. Possible values: `DEBIT`, `CREDIT`. * **BeforeDate** (Date) - Optional - Filters transactions that occurred before this date. * **AfterDate** (Date) - Optional - Filters transactions that occurred after this date. ### Request Example ```ruby MangoPay::Transaction.fetch(new_wallet['Id']) ``` ### Response #### Success Response (200) - **transactions** (Array) - An array of Transaction objects. #### Response Example ```json [ { "Id": 12345, "Tag": "some_tag", "CreationDate": 1678886400, "AuthorId": 67890, "CreditedUserId": 11223, "DebitedFunds": {"Currency": "EUR", "Amount": 5000}, "CreditedFunds": {"Currency": "EUR", "Amount": 4900}, "Fees": {"Currency": "EUR", "Amount": 100}, "Status": "SUCCEEDED", "ResultCode": "00.00.00", "ExecutionDate": 1678886410, "Type": "PAY_IN", "Nature": "NORMAL" } ] ``` ``` -------------------------------- ### Create Client Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Client/Client Creates a new MangoPay client with the provided details. ```APIDOC ## POST /clients ### Description Creates a new MangoPay client. ### Method POST ### Endpoint /clients ### Parameters #### Request Body - **ClientID** (String) - Required - The client identifier. - **Name** (String) - Required - The name of the client. - **Email** (String) - Required - The email address of the client. - **Passphrase** (String) - Required - The passphrase for the client. - **Tag** (String) - Optional - An additional tag for the client. ### Request Example ```json { "ClientID": "example", "Name": "Example Company", "Email": "my@email.com", "Passphrase": "secret123" } ``` ### Response #### Success Response (201) - **Id** (Integer) - The unique identifier for the created client. - **CreationDate** (Date) - The date and time the client was created. - **ClientID** (String) - The client identifier. - **Name** (String) - The name of the client. - **Email** (String) - The email address of the client. - **Passphrase** (String) - The passphrase for the client. - **Tag** (String) - An optional tag for the client. #### Response Example ```json { "Id": 12345, "CreationDate": "2023-10-27T10:00:00Z", "ClientID": "example", "Name": "Example Company", "Email": "my@email.com", "Passphrase": "secret123", "Tag": "optional_tag" } ``` ``` -------------------------------- ### Create Wallet Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Wallet/Wallet Creates a new wallet with specified details. Requires owner IDs, currency, and optional description and tag. ```APIDOC ## POST /wallets ### Description Creates a new wallet with the provided details. ### Method POST ### Endpoint /wallets ### Parameters #### Request Body - **Owners** (Array) - Required - An array of user IDs who will own this wallet. - **Description** (String) - Optional - A description for the wallet (max 200 characters). - **Currency** (String) - Required - The ISO currency code for the wallet (e.g., 'EUR', 'USD'). - **Tag** (String) - Optional - A tag for the wallet. ### Request Example ```ruby MangoPay::Wallet.create({ Owners: [43243], Description: 'A test wallet', Currency: 'EUR', Tag: 'Test Time' }) ``` ### Response #### Success Response (200) - **Id** (Integer) - The unique identifier for the created wallet. - **Tag** (String) - The tag associated with the wallet. - **CreationDate** (Time) - The date and time when the wallet was created. - **Owners** (Array) - The IDs of the wallet owners. - **Description** (String) - The description of the wallet. - **Balance** (Money) - The current balance of the wallet, including currency and amount. - **Currency** (String) - The ISO currency code of the wallet. #### Response Example ```json { "Id": 12345, "Tag": "Test Time", "CreationDate": 1678886400, "Owners": [43243], "Description": "A test wallet", "Balance": { "Currency": "EUR", "Amount": 0 }, "Currency": "EUR" } ``` ``` -------------------------------- ### Create MangoPay Wallet - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Wallet/Wallet Creates a new wallet with specified ownership, description, currency, and an optional tag. Requires MangoPay SDK and valid arguments. ```ruby MangoPay::Wallet.create({ Owners: [43243], Description: 'A test wallet', Currency: 'EUR', Tag: 'Test Time' }) ``` -------------------------------- ### Configure Mangopay Ruby SDK Source: https://github.com/mangopay/mangopay2-ruby-sdk/blob/master/README.md Configures the Mangopay Ruby SDK with essential credentials and settings like client ID, API key, and logging. It supports preproduction environments and custom HTTP timeouts. Ensure you replace placeholders with your actual credentials. ```ruby require 'mangopay' # configuration MangoPay.configure do |c| c.preproduction = true c.client_id = 'YOUR_CLIENT_ID' c.client_apiKey = 'YOUR_CLIENT_API_KEY' c.log_file = File.join('mypath', 'mangopay.log') c.http_timeout = 10000 end ``` -------------------------------- ### Create LegalUser Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/LegalUser/LegalUser Creates a new LegalUser with the provided details. ```APIDOC ## POST /legalusers ### Description Creates a new LegalUser with the provided details. ### Method POST ### Endpoint /legalusers ### Parameters #### Request Body - **legal_user** (Hash) - Required - A hash containing the LegalUser details: - **Name** (String) - Required - **Email** (String) - Required - **LegalPersonType** (String) - Required - **HeadquartersAddress** (String) - Optional - **LegalRepresentativeFirstName** (String) - Required - **LegalRepresentativeLastName** (String) - Required - **LegalRepresentativeAdress** (String) - Optional - **LegalRepresentativeEmail** (String) - Optional - **LegalRepresentativeBirthday** (Date) - Required - **LegalRepresentativeNationality** (String) - Required - **LegalRepresentativeCountryOfResidence** (String) - Required - **Statute** (String) - Optional - **ProofOfRegistration** (String) - Optional - **ShareholderDeclaration** (String) - Optional - **Tag** (String) - Optional ### Request Example ```ruby MangoPay::LegalUser.create({ Name: 'Super', Email: 'contact@super.com', LegalPersonType: 'BUSINESS', HeadquartersAddress: 'Here', LegalRepresentativeFirstName: 'John', LegalRepresentativeLastName: 'Doe', LegalRepresentativeAddress: 'Here', LegalRepresentativeEmail: 'john@doe.com', LegalRepresentativeBirthday: Date.strptime("01/01/2000", "%m/%d/%Y").to_time.to_i, LegalRepresentativeNationality: 'FR', LegalRepresentativeCountryOfResidence: 'FR' }) ``` ### Response #### Success Response (200) - **LegalUser Object** (Object) - A LegalUser object representing the newly created user. #### Response Example ```json { "Id": "39217", "Name": "Super", "Email": "contact@super.com", "LegalPersonType": "BUSINESS", "HeadquartersAddress": "Here", "LegalRepresentativeFirstName": "John", "LegalRepresentativeLastName": "Doe", "LegalRepresentativeAddress": "Here", "LegalRepresentativeEmail": "john@doe.com", "LegalRepresentativeBirthday": 946684800, "LegalRepresentativeNationality": "FR", "LegalRepresentativeCountryOfResidence": "FR", "Statute": null, "ProofOfRegistration": null, "ShareholderDeclaration": null, "Tag": null } ``` ``` -------------------------------- ### Create MangoPay Client - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Client/Client Creates a new MangoPay client using provided details. Requires ClientID, Name, and Email. Optionally accepts a Tag. Returns a Client Object upon successful creation. ```ruby MangoPay::Client.create({ 'ClientID' => 'example', 'Name' => 'Example Company', 'Email' => 'my@email.com' }) ``` -------------------------------- ### Manage Multiple Mangopay Configurations (Ruby) Source: https://github.com/mangopay/mangopay2-ruby-sdk/blob/master/README.md Enables the creation and management of multiple distinct configuration objects for the Mangopay Ruby SDK. This is useful for applications interacting with different Mangopay accounts or environments simultaneously. Configurations are added by name and can be applied on demand. ```ruby config = MangoPay::Configuration.new config.client_id = 'your-client-id' config.client_apiKey = 'your-api-key' config.preproduction = true MangoPay.add_config('config1', config) MangoPay.get_config('config1').apply_configuration ``` -------------------------------- ### Fetch All Users with Pagination (Ruby) Source: https://github.com/mangopay/mangopay2-ruby-sdk/blob/master/README.md Retrieves a list of all users, implementing pagination to manage large datasets. It shows how to specify the page number and items per page, and also how to access pagination metadata. ```ruby # get all users (with pagination) pagination = {'page' => 1, 'per_page' => 8} # get 1st page, 8 items per page users = MangoPay::User.fetch(pagination) # => [{...}, ...]: list of 8 users data hashes pagination # => {"page"=>1, "per_page"=>8, "total_pages"=>748, "total_items"=>5978} ``` -------------------------------- ### Retrieving all Users Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/User/User Fetches an array of all users available in the system. ```APIDOC ## GET /users ### Description Fetches an array of all users. ### Method GET ### Endpoint /users ### Parameters #### Path Parameters None #### Query Parameters None ### Request Example ```ruby MangoPay::User.fetch() ``` ### Response #### Success Response (200) - **Users** (Array) - An array of User objects. #### Response Example ```json [ { "Id": "12345", "Tag": "user1", "CreationDate": 1678886400, "PersonType": "NATURAL", "Email": "user1@example.com" }, { "Id": "67890", "Tag": "user2", "CreationDate": 1678886400, "PersonType": "LEGAL", "Name": "Example Corp" } ] ``` ``` -------------------------------- ### Create NaturalUser with MangoPay Ruby SDK Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/NaturalUser/NaturalUser Demonstrates how to create a new NaturalUser object using the MangoPay Ruby SDK. Requires a hash containing user details. Returns a NaturalUser object upon successful creation. ```ruby MangoPay::NaturalUser.create({ Tag: 'test', Email: 'my@email.com', FirstName: 'John', LastName: 'Doe', Address: 'Here', Birthday: Date.parse('01-01-2000').to_time.to_i, Birthplace: 'Paris', Nationality: 'FR', CountryOfResidence: 'FR', Occupation: 'Worker', IncomeRange: 1 }) ``` -------------------------------- ### Create PayOutBankWire Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/PayOut/PayOut Creates a new bank wire payout with specified details. ```APIDOC ## POST /v2.01/payouts/bankwire ### Description Creates a new bank wire payout. ### Method POST ### Endpoint /v2.01/payouts/bankwire ### Parameters #### Request Body - **payout_bank_wire** (Hash) - Required - A hash containing the payout details: - **AuthorId** (Integer) - Required - **DebitedFunds** (Money) - Required - Hash { Currency: 'EUR', Amount: 10 } - **Fees** (Money) - Required - Hash { Currency: 'EUR', Amount: 10 } - **DebitedWalletId** (Integer) - Required - **BankAccountsId** (Integer) - Required - **Communication** (String) - Optional - **Tag** (String) - Optional ### Request Example ```json { "AuthorId": 432432, "DebitedFunds": { "Currency": "EUR", "Amount": 500 }, "Fees": { "Currency": "EUR", "Amount": 0 }, "DebitedWalletId": 432432, "BankAccountId": 432423, "Communication": "This is a test", "Tag": "Test Bank Wire" } ``` ### Response #### Success Response (200) - **PayOutBankWire Object** (Object) - Contains the details of the created payout. - Id (Integer) - Tag (String) - CreationDate (Date) - AuthorId (Integer) - CreditedUserId (Integer) - DebitedFunds (Money) - CreditedFunds (Money) - Fees (Money) - Status (String) - ResultCode (Integer) - ExecutionDate (Date) - Type (String) - Nature (String) - DebitedWalletID (Integer) - MeanOfPaymentType (String) - BankAccountsId (Integer) - Communication (String) #### Response Example ```json { "Id": 12345, "Tag": "Test Bank Wire", "CreationDate": 1678886400, "AuthorId": 432432, "CreditedUserId": 67890, "DebitedFunds": { "Currency": "EUR", "Amount": 500 }, "CreditedFunds": { "Currency": "EUR", "Amount": 495 }, "Fees": { "Currency": "EUR", "Amount": 5 }, "Status": "SUCCEEDED", "ResultCode": 0, "ExecutionDate": 1678886405, "Type": "PAY_OUT", "Nature": "NORMAL", "DebitedWalletID": 432432, "MeanOfPaymentType": "BANK_WIRE", "BankAccountsId": 432423, "Communication": "This is a test" } ``` ``` -------------------------------- ### POST /users/{userId}/bankaccounts Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/BankAccounts/BankAccounts Creates a new bank account for a given user. ```APIDOC ## POST /users/{userId}/bankaccounts ### Description Creates a new bank account for a specified user. Requires user ID and bank details. ### Method POST ### Endpoint `/users/{userId}/bankaccounts` ### Parameters #### Path Parameters - **userId** (Integer) - Required - The ID of the user to add a bank account to. #### Request Body - **bank_details** (Hash) - Required - Contains the details for the bank account: - **Type** (String) - Required - The type of the bank account (e.g., 'IBAN'). - **OwnerName** (String) - Required - The name of the account owner. - **OwnerAddress** (String) - Required - The address of the account owner. - **IBAN** (String) - Required - The International Bank Account Number. - **BIC** (String) - Required - The Bank Identifier Code. - **Tag** (String) - Optional - A tag for the bank account. ### Request Example ```json { "Type": "IBAN", "OwnerName": "John", "OwnerAddress": "Here", "IBAN": "FR7630004000031234567890143", "BIC": "BNPAFRPP", "Tag": "Test Time" } ``` ### Response #### Success Response (200) - **BankAccount** (Object) - The newly created BankAccount Object. #### Response Example ```json { "Id": 12345, "Tag": "Test Time", "CreationDate": 1678886400, "UserId": 78329, "Type": "IBAN", "OwnerName": "John", "OwnerAddress": "Here", "IBAN": "FR7630004000031234567890143", "BIC": "BNPAFRPP" } ``` ``` -------------------------------- ### Create PayInWebCard in Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/PayIn/PayIn Creates a new PayInWebCard for processing payments via web. Requires author, credited user, debited funds, fees, credited wallet, return URL, card type, culture, and an optional tag. Returns a PayInWebCard object upon success. ```ruby MangoPay::PayIn::Card::Web.create({ AuthorId: 54324, CreditedUserId: 43243, DebitedFunds: { Currency: 'EUR', Amount: 1000 }, Fees: { Currency: 'EUR', Amount: 0 }, CreditedWalletId: 543455, ReturnURL: 'https://your.company.com', CardType: 'CB_VISA_MASTERCARD', Culture: 'FR', Tag: 'Test Card' }) ``` -------------------------------- ### BankAccount Object Attributes Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/BankAccounts/BankAccounts This section details the properties of the BankAccount object. ```APIDOC ## BankAccount Object Attributes ### Description Details the properties available for a BankAccount object. ### Parameters #### Attributes - **Id** (Integer) - Unique identifier for the bank account. - **Tag** (String) - An optional tag for the bank account. - **CreationDate** (Time) - The date and time when the bank account was created. - **UserId** (Integer) - The ID of the user to whom this bank account belongs. - **Type** (String) - The type of bank account (e.g., 'IBAN'). - **OwnerName** (String) - The name of the account owner. - **OwnerAddress** (String) - The address of the account owner. - **IBAN** (String) - The International Bank Account Number. - **BIC** (String) - The Bank Identifier Code. ``` -------------------------------- ### POST /payin/card/web Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/PayIn/PayIn Creates a new PayInWebCard object. Requires a hash containing payment details. ```APIDOC ## POST /payin/card/web ### Description Creates a new PayInWebCard object with the provided details. ### Method POST ### Endpoint /payin/card/web ### Parameters #### Request Body - **payin_web_card** (Hash) - Required - A hash containing the details for the PayInWebCard. - **AuthorId** (Integer) - Required - **CreditedUserId** (Integer) - Required - **DebitedFunds** (Money) - Required - Hash { Currency: 'EUR', Amount: 10 } - **Fees** (Money) - Required - Hash { Currency: 'EUR', Amount: 10 } - **CreditedWalletId** (Integer) - Required - **ReturnURL** (String) - Required - URL Format expected - **CardType** (String) - Required - either CB_VISA_MASTERCARD or AMEX - **Culture** (String) - Required - **Tag** (String) - Optional ### Request Example ```json { "payin_web_card": { "AuthorId": 54324, "CreditedUserId": 43243, "DebitedFunds": { "Currency": "EUR", "Amount": 1000 }, "Fees": { "Currency": "EUR", "Amount": 0 }, "CreditedWalletId": 543455, "ReturnURL": "https://your.company.com", "CardType": "CB_VISA_MASTERCARD", "Culture": "FR", "Tag": "Test Card" } } ``` ### Response #### Success Response (200) - **PayInWebCard** (Object) - The created PayInWebCard object. ``` -------------------------------- ### PayInWebCard Object Properties Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/PayIn/PayIn Details of the properties available for the PayInWebCard object. ```APIDOC ## PayInWebCard Object Properties | Property | Type | More | |---------------------|-----------|-------------------------------------| | Id | Integer | | | Tag | String | | | CreationDate | Time | | | AuthorId | Integer | | | CreditedFunds | Integer | | | DebitedFunds | Money | Hash { Currency: 'EUR', Amount: 10 } | | CreditedFunds | Money | Hash { Currency: 'EUR', Amount: 10 } | | Fees | Money | Hash { Currency: 'EUR', Amount: 10 } | | Status | String | either CREATED, SUCCEEDED or FAILED | | ResultCode | Integer | | | ExecutionDate | Date | | | Type | String | either PAY_IN, PAY_OUT or TRANSFER | | Nature | String | either NORMAL, REFUND or REPUDIATION | | CreditedWalletId | Integer | | | PaymentType | String | either CARD, BANK_WIRE, AUTOMATIC_DEBIT or DIRECT_DEBIT | | ExecutionType | String | either WEB, TOKEN, DIRECT, PREAUTHORIZED or RECURRING_ORDER_EXECUTION | | CardType | String | either CB_VISA_MASTERCARD or AMEX | | RedirectURL | String | URL Format expected | | ReturnURL | String | URL Format expected | | TemplateURL | String | URL Format expected | | ShowRegisteredCard | Boolean | | | RegisterCard | Boolean | | | Culture | String | | | Mode3DS | String | either DEFAULT or FORCE | ``` -------------------------------- ### Fetch and Update User Data (Ruby) Source: https://github.com/mangopay/mangopay2-ruby-sdk/blob/master/README.md Demonstrates how to retrieve a user's information by their ID and subsequently update their details, specifically the last name. This operation requires a valid user ID. ```ruby # get some user by id john = MangoPay::User.fetch(john_id) # => {FirstName=>"John", "LastName"=>"Doe", ...} # update some of his data MangoPay::NaturalUser.update(john_id, {'LastName' => 'CHANGED'}) # => {FirstName=>"John", "LastName"=>"CHANGED", ...} ``` -------------------------------- ### Create BankAccount - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/BankAccounts/BankAccounts Creates a new bank account for a given user. Requires user ID and a hash containing bank details such as Type, OwnerName, OwnerAddress, IBAN, BIC, and an optional Tag. ```ruby MangoPay::BankAccount.create(78329, { Type: 'IBAN', OwnerName: 'John', OwnerAddress: 'Here', IBAN: 'FR7630004000031234567890143', BIC: 'BNPAFRPP', Tag: 'Test Time' }) ``` -------------------------------- ### Fetch Transaction Reports with Filters (Ruby) Source: https://github.com/mangopay/mangopay2-ruby-sdk/blob/master/README.md Fetches transaction reports based on specified filters, such as minimum and maximum fees amount and currency. This allows for targeted retrieval of financial data. ```ruby # pass custom filters (transactions reporting filters) filters = {'MinFeesAmount' => 1, 'MinFeesCurrency' => 'EUR', 'MaxFeesAmount' => 1000, 'MaxFeesCurrency' => 'EUR'} reports = MangoPay::Report.fetch(filters) # => [{...}, ...]: list of transaction reports between 1 and 1000 EUR ``` -------------------------------- ### Create LegalUser in Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/LegalUser/LegalUser Creates a new LegalUser object with the provided attributes. Requires mandatory fields such as Name, Email, LegalPersonType, and legal representative details. Returns the created LegalUser object. ```ruby MangoPay::LegalUser.create({ Name: 'Super', Email: 'contact@super.com', LegalPersonType: 'BUSINESS', HeadquartersAddress: 'Here', LegalRepresentativeFirstName: 'John', LegalRepresentativeLastName: 'Doe', LegalRepresentativeAddress: 'Here', LegalRepresentativeEmail: 'john@doe.com', LegalRepresentativeBirthday: Date.strptime("01/01/2000", "%m/%d/%Y").to_time.to_i, LegalRepresentativeNationality: 'FR', LegalRepresentativeCountryOfResidence: 'FR' }) ``` -------------------------------- ### Handle Mangopay API Errors (Ruby) Source: https://github.com/mangopay/mangopay2-ruby-sdk/blob/master/README.md Demonstrates robust error handling for Mangopay API calls using a begin-rescue block. It specifically catches `MangoPay::ResponseError` and accesses detailed error information, including messages, types, IDs, and specific field errors. ```ruby # error handling begin MangoPay::NaturalUser.create({}) rescue MangoPay::ResponseError => ex ex # => # ex.details # => { # "Message"=>"One or several required parameters are missing or incorrect. [...]", # "Type"=>"param_error", # "Id"=>"5c080105-4da3-467d-820d-0906164e55fe", # "Date"=>1409048671.0, # "errors"=>{ # "FirstName"=>"The FirstName field is required.", # "LastName"=>"The LastName field is required.", ...}, # "Code"=>"400", # "Url"=>"/v2/.../users/natural" # } end ``` -------------------------------- ### Refund PayIn in Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/PayIn/PayIn Initiates a refund for a previously made PayIn. This operation requires the ID of the PayIn to be refunded and a hash containing refund details such as tag, author ID, debited funds, and fees. It returns a Refund object. ```ruby MangoPay::PayIn.refund(430293, { AuthorId: 313212 }) ``` -------------------------------- ### Update Wallet Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Wallet/Wallet Updates an existing wallet's description and tag. Requires the wallet ID and the fields to update. ```APIDOC ## PUT /wallets/{wallet_id} ### Description Updates the description and/or tag of an existing wallet. ### Method PUT ### Endpoint /wallets/{wallet_id} ### Parameters #### Path Parameters - **wallet_id** (Integer) - Required - The ID of the wallet to update. #### Request Body - **Description** (String) - Optional - The new description for the wallet (max 200 characters). - **Tag** (String) - Optional - The new tag for the wallet. ### Request Example ```ruby MangoPay::Wallet.update(new_wallet['Id'], { Description: 'Updated Description', Tag: 'Updated Tag' }) ``` ### Response #### Success Response (200) - **Id** (Integer) - The unique identifier for the wallet. - **Tag** (String) - The updated tag associated with the wallet. - **CreationDate** (Time) - The date and time when the wallet was created. - **Owners** (Array) - The IDs of the wallet owners. - **Description** (String) - The updated description of the wallet. - **Balance** (Money) - The current balance of the wallet, including currency and amount. - **Currency** (String) - The ISO currency code of the wallet. #### Response Example ```json { "Id": 12345, "Tag": "Updated Tag", "CreationDate": 1678886400, "Owners": [43243], "Description": "Updated Description", "Balance": { "Currency": "EUR", "Amount": 0 }, "Currency": "EUR" } ``` ``` -------------------------------- ### Fetch MangoPay Wallet - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Wallet/Wallet Retrieves a specific MangoPay wallet by its ID. Returns the Wallet object. Requires the wallet ID as an argument. ```ruby MangoPay::Wallet.fetch(32132) ``` -------------------------------- ### Fetch NaturalUser with MangoPay Ruby SDK Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/NaturalUser/NaturalUser Illustrates how to retrieve a specific NaturalUser object by its ID using the MangoPay Ruby SDK. Requires the user's ID as an argument and returns the corresponding NaturalUser object. ```ruby MangoPay::NaturalUser.fetch(87323) ``` -------------------------------- ### Fetch Specific User by ID - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/User/User This snippet shows how to fetch a single user from MangoPay by providing their unique identifier. The function takes the user's ID as an argument and returns the corresponding User object. Proper authentication with the MangoPay API is necessary. ```ruby MangoPay::User.fetch(42344) ``` -------------------------------- ### Create PayOutBankWire Transaction - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/PayOut/PayOut Creates a new PayOutBankWire transaction. Requires a Hash containing AuthorId, DebitedFunds, Fees, DebitedWalletId, BankAccountId, Communication, and Tag. Returns a PayOutBankWire object. ```ruby MangoPay::PayOut::BankWire.create({ AuthorId: 432432, DebitedFunds: { Currency: 'EUR', Amount: 500 }, Fees: { Currency: 'EUR', Amount: 0 }, DebitedWalletId: 432432, BankAccountId: 432423, Communication: 'This is a test', Tag: 'Test Bank Wire' }) ``` -------------------------------- ### Access Mangopay Rate Limiting Headers (Ruby) Source: https://github.com/mangopay/mangopay2-ruby-sdk/blob/master/README.md Retrieves rate limiting information provided by the Mangopay API. The SDK automatically updates these headers, which include the limit, remaining requests, and reset time, allowing developers to monitor and manage API usage effectively. ```ruby MangoPay.ratelimit { :limit=>["74", "74", "75", "908"], :remaining=>["2226", "4426", "8725", "104692"], :reset=>["1495615620", "1495616520", "1495618320", "1495701060"] } ``` -------------------------------- ### Create Transfer - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Transfer/Transfer Creates a new transfer with specified debited and credited funds, fees, and user/wallet IDs. Requires AuthorId, CreditedUserId, DebitedFunds, Fees, DebitedWalletId, CreditedWalletId, and an optional Tag. ```ruby MangoPay::Transfer.create({ AuthorId: 43233, CreditedUserId: 43123, DebitedFunds: { Currency: 'EUR', Amount: 500}, Fees: { Currency: 'EUR', Amout: 0}, DebitedWalletId: 43244, CreditedWalletId: 54341, Tag: 'Test Transfer' }) ``` -------------------------------- ### Retrieving a specific User Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/User/User Fetches a specific user (natural or legal) by their ID. ```APIDOC ## GET /users/{user_id} ### Description Fetches a specific user (natural or legal) by their ID. ### Method GET ### Endpoint /users/{user_id} ### Parameters #### Path Parameters - **user_id** (long) - Required - The ID of the user to fetch. #### Query Parameters None ### Request Example ```ruby MangoPay::User.fetch(42344) ``` ### Response #### Success Response (200) - **User** (Object) - A User object containing the details of the requested user. #### Response Example ```json { "Id": "42344", "Tag": "specific_user", "CreationDate": 1678886400, "PersonType": "NATURAL", "Email": "specific@example.com", "FirstName": "John", "LastName": "Doe", "Address": "123 Main St", "Birthday": "1990-01-01", "Birthplace": "Anytown", "Nationality": "US", "CountryOfResidence": "US", "Occupation": "Engineer", "IncomeRange": 4, "ProofOfIdentity": "proof_id.jpg", "ProofOfAddress": "proof_address.jpg" } ``` ``` -------------------------------- ### Update MangoPay Wallet - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Wallet/Wallet Updates the description and/or tag of an existing MangoPay wallet identified by its ID. Returns the updated Wallet object. Requires the wallet ID and a hash containing the fields to update. ```ruby MangoPay::Wallet.update(new_wallet['Id'], { Description: 'Updated Description', Tag: 'Updated Tag' }) ``` -------------------------------- ### Fetch User Bank Accounts (Ruby) Source: https://github.com/mangopay/mangopay2-ruby-sdk/blob/master/README.md Retrieves a list of bank accounts associated with a specific user ID. The retrieval is paginated by default, returning a set number of accounts per page. ```ruby # get John's bank accounts accounts = MangoPay::BankAccount.fetch(john_id) # => [{...}, ...]: list of accounts data hashes (10 per page by default) ``` -------------------------------- ### Retrieve Wallet Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/Wallet/Wallet Retrieves the details of a specific wallet using its ID. ```APIDOC ## GET /wallets/{wallet_id} ### Description Retrieves the details of a specific wallet. ### Method GET ### Endpoint /wallets/{wallet_id} ### Parameters #### Path Parameters - **wallet_id** (Integer) - Required - The ID of the wallet to retrieve. ### Response #### Success Response (200) - **Id** (Integer) - The unique identifier for the wallet. - **Tag** (String) - The tag associated with the wallet. - **CreationDate** (Time) - The date and time when the wallet was created. - **Owners** (Array) - The IDs of the wallet owners. - **Description** (String) - The description of the wallet. - **Balance** (Money) - The current balance of the wallet, including currency and amount. - **Currency** (String) - The ISO currency code of the wallet. #### Response Example ```ruby MangoPay::Wallet.fetch(32132) ``` ```json { "Id": 32132, "Tag": "Sample Tag", "CreationDate": 1678886400, "Owners": [12345], "Description": "A sample wallet description", "Balance": { "Currency": "GBP", "Amount": 1000 }, "Currency": "GBP" } ``` ``` -------------------------------- ### POST /payin/{payin_id}/refund Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/PayIn/PayIn Refunds a specific PayIn using its ID. Requires refund details. ```APIDOC ## POST /payin/{payin_id}/refund ### Description Refunds a specific PayIn using its ID. Requires refund details. ### Method POST ### Endpoint /payin/{payin_id}/refund ### Parameters #### Path Parameters - **payin_id** (Integer) - Required - The ID of the PayIn to refund. #### Request Body - **refund** (Hash) - Required - A hash containing refund details. - **Tag** (String) - Optional - **AuthorId** (Integer) - Optional - **DebitedFunds** (Money) - Optional - Hash { Currency: 'EUR', Amount: 10 } - **Fees** (Money) - Optional - Hash { Currency: 'EUR', Amount: 10 } ### Request Example ```json { "refund": { "AuthorId": 313212 } } ``` ### Response #### Success Response (200) - **Refund** (Object) - The resulting Refund object. ``` -------------------------------- ### Fetch All User BankAccounts - Ruby Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/BankAccounts/BankAccounts Retrieves an array of all bank accounts associated with a specific user. This requires the user ID as an argument. ```ruby MangoPay::BankAccount.fetch(new_iban_bank_detail['UserId']) ``` -------------------------------- ### Update NaturalUser with MangoPay Ruby SDK Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/NaturalUser/NaturalUser Shows how to update an existing NaturalUser record identified by its ID using the MangoPay Ruby SDK. Accepts the user ID and a hash of fields to update. Returns the updated NaturalUser object. ```ruby MangoPay::NaturalUser.update(39217, { FirstName: 'Jack', LastName: 'Dah' }) ``` -------------------------------- ### Update LegalUser Source: https://github.com/mangopay/mangopay2-ruby-sdk/wiki/LegalUser/LegalUser Updates an existing LegalUser identified by its ID. ```APIDOC ## PUT /legalusers/{legal_user_id} ### Description Updates an existing LegalUser identified by its ID. ### Method PUT ### Endpoint /legalusers/{legal_user_id} ### Parameters #### Path Parameters - **legal_user_id** (String) - Required - The ID of the legal user to update. #### Request Body - **legal_user** (Hash) - Required - A hash containing the fields to update: - **LegalPersonType** (String) - Optional - **HeadquartersAddress** (String) - Optional - **LegalRepresentativeFirstName** (String) - Optional - **LegalRepresentativeLastName** (String) - Optional - **LegalRepresentativeAdress** (String) - Optional - **LegalRepresentativeEmail** (String) - Optional - **LegalRepresentativeBirthday** (Date) - Optional - **LegalRepresentativeNationality** (String) - Optional - **LegalRepresentativeCountryOfResidence** (String) - Optional - **Statute** (String) - Optional - **ProofOfRegistration** (String) - Optional - **ShareholderDeclaration** (String) - Optional - **Tag** (String) - Optional ### Request Example ```ruby MangoPay::LegalUser.update(39217, { LegalRepresentativeFirstName: 'Jack', LegalRepresentativeLastName: 'Dah' }) ``` ### Response #### Success Response (200) - **LegalUser Object** (Object) - A LegalUser object representing the updated user. #### Response Example ```json { "Id": "39217", "Name": "Super", "Email": "contact@super.com", "LegalPersonType": "BUSINESS", "HeadquartersAddress": "Here", "LegalRepresentativeFirstName": "Jack", "LegalRepresentativeLastName": "Dah", "LegalRepresentativeAddress": "Here", "LegalRepresentativeEmail": "john@doe.com", "LegalRepresentativeBirthday": 946684800, "LegalRepresentativeNationality": "FR", "LegalRepresentativeCountryOfResidence": "FR", "Statute": null, "ProofOfRegistration": null, "ShareholderDeclaration": null, "Tag": null } ``` ```