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

# Create Payin with Global Markup

> Create a payin charge using global markup configuration.

# Create Payin with Global Markup

When creating a payin charge, you can use the **global markup** configuration that has been set up for your merchant. With global markup, you **do not need to send** the `markup` object in the request payload.

<Note>
  **Global markup is applied automatically**: If the merchant has the markup feature enabled (`enable_markup = true`), the system will automatically search for and apply the global markup configuration for the submerchant.
</Note>

## How It Works

1. **Validation**: The system checks if the `enable_markup` flag is active for the submerchant.

2. **Markup Search**: If enabled, the system automatically searches for the global markup configuration based on:
   * `account_id` (submerchant ID)
   * `product` (payin)
   * `payment_method` (pix, boleto, etc.)

3. **Application**: If a global markup is found, it is automatically applied to the charge.

4. **Priority**: If you send an inline `markup` object, it takes precedence over the global markup.

## Request Examples

<CodeGroup>
  ```json PIX with Global Markup theme={null}
  {
    "payment_method": "pix",
    "invoice": "YOUR-CODE1234",
    "currency": "BRL",
    "amount": 10000,
    "country": "BR",
    "buyer": {
      "name": "Buyer Name",
      "document": {
        "type": "CPF",
        "number": "34960826312"
      },
      "email": "buyer-email@wepayments.com.br"
    },
    "pix": {
      "expire_date": "2025-12-31T23:59:59"
    }
  }
  ```

  ```json Boleto with Global Markup theme={null}
  {
    "payment_method": "boleto",
    "invoice": "YOUR-INVOICE-CODE",
    "currency": "BRL",
    "amount": 50000,
    "country": "BR",
    "buyer": {
      "name": "Buyer Name",
      "email": "buyer@example.com",
      "document": {
        "type": "CPF",
        "number": "12345678901"
      },
      "address": {
        "street": "Street Name",
        "number": "123",
        "complement": "Apt 456",
        "zipcode": "12345000",
        "city": "City Name",
        "district": "District Name",
        "state_code": "SP"
      }
    },
    "originator_legal_entity": {
      "name": "Company Name",
      "document": "12345678901",
      "helpdesk": "company.com"
    },
    "boleto": {
      "expire_date": "2025-12-31"
    }
  }
  ```

  ```bash cURL - PIX with Global Markup theme={null}
  curl -X POST "https://api.sandbox.wepayout.com.br/v2/payin/payments" \
    -H "Authorization: Bearer YOUR_TOKEN_HERE" \
    -H "Content-Type: application/json" \
    -d '{
      "payment_method": "pix",
      "invoice": "YOUR-CODE1234",
      "currency": "BRL",
      "amount": 10000,
      "country": "BR",
      "buyer": {
        "name": "Buyer Name",
        "document": {
          "type": "CPF",
          "number": "34960826312"
        },
        "email": "buyer-email@wepayments.com.br"
      },
      "pix": {
        "expire_date": "2025-12-31T23:59:59"
      }
    }'
  ```
</CodeGroup>

## Response

<ResponseField name="id" type="integer">
  WEpayment's auto generated id, use this id to perform conciliation or perform queries via API / Dashboard.
</ResponseField>

<ResponseField name="merchant" type="object">
  Merchant object.

  <Expandable title="Merchant">
    <ResponseField name="id" type="integer">
      Id of the WE account that created the payin.
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of the WE account that created the payin.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="hash" type="string">
  WEpayments auto generated hash, use this hash to send your user to the payment page.
</ResponseField>

<ResponseField name="payment_page" type="string">
  The WEpayments payment page is the place where you will redirect the end customer to pay the bill.
</ResponseField>

<ResponseField name="invoice" type="string">
  Your identification number.
</ResponseField>

<ResponseField name="payment_method" type="string">
  Payment method that will be used in payin.

  Values: `pix`, `boleto`
</ResponseField>

<ResponseField name="amount" type="integer">
  The payin total amount in cents.
</ResponseField>

<ResponseField name="currency" type="object">
  Currency object.

  <Expandable title="Currency">
    <ResponseField name="id" type="integer">
      Currency id.
    </ResponseField>

    <ResponseField name="code" type="string">
      Currency code (ISO 4217).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="status" type="string">
  Current status of the payin.

  Example: `pending`
</ResponseField>

<ResponseField name="markup" type="object">
  Global markup configuration applied to this charge.

  <Expandable title="Markup Object">
    <ResponseField name="mode" type="string">
      Markup mode applied.

      Values: `fixed`, `percent`
    </ResponseField>

    <ResponseField name="amount" type="number">
      Markup value configured for this charge.
    </ResponseField>

    <ResponseField name="min_charge_value" type="number or null">
      Minimum markup value when `mode` is `percent`. Will be `null` when `mode` is `fixed`.
    </ResponseField>

    <ResponseField name="max_charge_value" type="number or null">
      Maximum markup value when `mode` is `percent`. Will be `null` when `mode` is `fixed` or when not specified.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json 201 Created - PIX Charge with Global Markup theme={null}
  {
    "id": 51687,
    "merchant": {
      "id": 477,
      "name": "Merchant Name"
    },
    "hash": "abc123def456",
    "payment_page": "https://payment.wepayments.com.br/abc123def456",
    "invoice": "YOUR-CODE1234",
    "payment_method": "pix",
    "amount": 10000,
    "currency": {
      "id": 1,
      "code": "BRL"
    },
    "status": "pending",
    "markup": {
      "mode": "percent",
      "amount": 2.5,
      "min_charge_value": 0.50,
      "max_charge_value": 10.00
    }
  }
  ```

  ```json 422 Unprocessable Entity - Markup Required theme={null}
  {
    "status": false,
    "message": "Validation error",
    "data": {
      "markup": [
        "O campo markup é obrigatório."
      ]
    }
  }
  ```

  ```json 422 Unprocessable Entity - Error Verifying Markup theme={null}
  {
    "message": "Os dados fornecidos são inválidos.",
    "errors": {
      "markup": [
        "Error verifying markup configuration. Please try again or contact support."
      ]
    }
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": "Internal server error"
  }
  ```
</ResponseExample>

## Business Rules

<Warning>
  **Markup Required**: If `enable_markup = true` for the submerchant and there is no global markup configuration, you must send an inline `markup` object. Otherwise, the request will fail with a 422 error.
</Warning>

<Info>
  **Automatic Application**: When `enable_markup = true` and a global markup exists, it is automatically applied without requiring the `markup` object in the request.
</Info>

## Error Scenarios

### Scenario 1: enable\_markup = true, No Global Markup, No Inline Markup

If the submerchant has `enable_markup = true` but:

* No global markup configuration exists
* No inline markup object is sent in the request

**Result**: Returns 422 error with message "O campo markup é obrigatório."

### Scenario 2: Error Verifying Global Markup

If there is an error while searching for or verifying the global markup configuration.

**Result**: Returns 422 error with message "Error verifying markup configuration. Please try again or contact support."

## Related Resources

<CardGroup cols={2}>
  <Card title="Create Payin with Inline Markup" icon="code" href="/api-reference/markup/payin/create-payin-with-inline-markup">
    Learn how to create payin with inline markup
  </Card>

  <Card title="Create Merchant Markup" icon="plus" href="/api-reference/markup/account/create-merchant-markup">
    Configure global markup for merchants
  </Card>

  <Card title="About Markup" icon="circle-info" href="/markup/about-markup">
    Understand markup types and configuration levels
  </Card>

  <Card title="Create Charge" icon="file" href="/api-reference/cash-in/payin/create-charge">
    Complete documentation for creating payin charges
  </Card>
</CardGroup>
