> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fedapay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send payment to user



## OpenAPI

````yaml post /transactions/{mode}
openapi: 3.0.0
info:
  title: Customer API
  version: v1
servers:
  - url: https://sandbox-api.fedapay.com/v1
  - url: https://api.fedapay.com/v1
security: []
paths:
  /transactions/{mode}:
    post:
      summary: Send payment to user
      parameters:
        - in: path
          name: mode
          schema:
            type: string
          required: true
          description: Transaction mode.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                token:
                  type: integer
                  description: Transaction token
                  example: 1
                phone_number:
                  type: object
                  description: Phone number details
                  properties:
                    number:
                      type: string
                      description: Phone number
                      example: '+22997808080'
                    country:
                      type: string
                      description: Country code
                      example: BJ
              required:
                - token
                - mode
      responses:
        '200':
          description: Transaction sent successfully.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    reference:
                      type: string
                      description: Payment intent reference.
                      example: pi_xdc_123456
                    amount:
                      type: integer
                      description: Payout amount.
                      example: 1000
                    status:
                      type: string
                      description: >-
                        Intent status (e.g., 'pending', 'scheduled', 'sent',
                        'failed').
                      example: pending
                    currency_id:
                      type: integer
                      description: Currency ID associated with the payout.
                      example: 840
                    mode:
                      type: string
                      description: Payout mode.
                      example: automatic
                    last_error_code:
                      type: string
                      description: Last error code encountered during the payout.
                      example: NO_ERROR
                    created_at:
                      type: string
                      format: date-time
                      description: Date and time of payout creation.
                      example: '2024-10-23T14:00:00Z'
                    updated_at:
                      type: string
                      format: date-time
                      description: Date and time of last payout update.
                      example: '2024-10-23T14:00:00Z'
                    approved_at:
                      type: string
                      format: date-time
                      description: Date and time the payout was sent.
                      example: '2024-10-23T14:31:00Z'
                    canceled_at:
                      type: string
                      format: date-time
                      description: Date and time the payout failed.
                      example: '2024-10-23T14:32:00Z'
                    deleted_at:
                      type: string
                      format: date-time
                      description: Date and time of payout deletion.
                      example: '2024-10-23T14:33:00Z'
                    payment_method_id:
                      type: integer
                      description: Payment method ID used for the payout.
                      example: 1
                    transaction_key:
                      type: string
                      description: Unique key associated with the payout.
                      example: TRANSACTION-XYZ
                    account_id:
                      type: integer
                      description: Account ID associated with the payout.
                      example: 5
        '400':
          description: Invalid request body.
        '404':
          description: Payout not found.
        '422':
          description: Validation error.
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          label: NodeJs
          source: >-
            const transaction = await Transaction.create(...);

            const token = transaction.generateToken().token;

            const mode = 'METHODE_PAIEMENT'; // Exemple : 'mtn', 'moov',
            'mtn_ci', 'moov_tg'

            const phoneNumber = { // Ce paramètre n'est pas obligatoire
              number: '64000001',
              country: 'bj'
            };

            await transaction.sendNowWithToken(mode, token, phoneNumber);
        - lang: PHP
          source: >-
            $transaction = \FedaPay\Transaction::create(...);

            $token = $transaction->generateToken()->token;

            $mode = 'METHODE_PAIEMENT'; // Exemple : 'mtn', 'moov', 'mtn_ci',
            'moov_tg'

            $phoneNumber = [ // Ce paramètre n'est pas obligatoire
                'number' => '64000001',
                'country' => 'bj'
            ];

            $transaction->sendNowWithToken($mode, $token, $phoneNumber);
        - lang: Ruby
          source: |-
            require 'fedapay'

            FedaPay.api_key = 'YOUR_SECRET_API_KEY'
            FedaPay.environment = 'sandbox'

            transaction = FedaPay::Transaction.create(
              amount: 1000,
              currency: { iso: 'XOF' },
              customer: { id: 1 },
              description: 'Payment for order #1234',
              callback_url: 'https://example.com/callback',
              mode: 'mtn_open'
            )

            puts "Transaction successfully created: #{transaction.inspect}"
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````