Create charge

POST/orders/create-charge

Creates a new payment charge and starts the payment flow for the order.

This endpoint can be used with different payment methods such as:

  • PIX
  • Bank Billet
  • Credit Card

For PIX and Bank Billet payments, the charge can be created directly by sending the payment data in the request.

For Credit Card payments, the flow is slightly different. Before creating the charge, the card data must be encrypted using the EasyFlow JavaScript SDK. The encrypted token returned by the SDK should then be sent in payments.creditCard.token when creating the charge.

The encrypted card token goes only in this request. No response and no webhook returns it: they show only the display fields of the card (last4Numbers, holderName, expiresAtMonth, expiresAtYear, flag and nickname).

Credit card flow:

  1. Retrieve installment options for the charge amount.
  2. Encrypt the credit card data using the EasyFlow SDK.
  3. Create the charge using the encrypted card token.

EasyFlow JavaScript SDK: https://github.com/easyflow-cash/easyflow-javascript-sdk

Example SDK initialization:

<script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
window.easyflowSDK.configure({
  businessId: 'your-business-id',
})

Example card encryption:

const encryptedCard = await window.easyflowSDK.encrypt({
  cardNumber: '5480832801033311',
  holderName: 'JOHN DOE',
  month: '12',
  year: '2035',
  cvv: '123',
})

Recurring payment links:

A payment link with subscription cannot be charged with this endpoint. When paymentLinkId (or, when it is omitted, items[].paymentLinkId of the first item) points to a recurring payment link, the API returns 400 with Invalid param: [paymentLinkId] and errorCode PAYMENT_LINK_RECURRING_USE_SUBSCRIBE. The buyer subscribes through the Easyflow checkout of the payment link.

Headers

  • x-api-keystringrequired

    Api key provided on integrations tab in Easyflow platform.

  • x-api-secretstringrequired

    Api Secret provided on integrations tab in Easyflow platform.

Request body

Content typeapplication/jsonobject

  • businessIdstringrequired
  • customerIdstring

    ID of a customer of the business, a 24-character hexadecimal identifier. When it is sent, buyer is not required and the buyer data comes from the customer. If buyer.customerId is also sent, both must have the same value. For bank billet payments, the customer must have an address.

  • paymentLinkIdstring · uuid

    ID of a payment link. When it is sent, the order is linked to the payment link and the seller is the business of the payment link. It takes precedence over items[].paymentLinkId. A recurring payment link (with subscription) is refused with errorCode PAYMENT_LINK_RECURRING_USE_SUBSCRIBE.

  • buyerobject
    Show child attributesHide child attributes
    • customerIdstring

      If this property is provided, it is not necessary to inform the other buyer details. However, please note that if the payment method is boleto, the informed user must have their address details filled in; otherwise, the order will be canceled.

    • namestring
    • emailstring
    • addressobject
      Show child attributesHide child attributes
      • zipCodestring
      • streetstring
      • complementstring
      • neighborhoodstring
      • citystring
      • statestring

        Possible values:ACALAPAMBACEDFESGOMAMTMSMGPAPBPRPEPIRJRNRSRORRSCSPSETO

      • numberstring
    • deliveryAddressobject
      Show child attributesHide child attributes
      • zipCodestring
      • streetstring
      • complementstring
      • neighborhoodstring
      • citystring
      • statestring

        Possible values:ACALAPAMBACEDFESGOMAMTMSMGPAPBPRPEPIRJRNRSRORRSCSPSETO

      • numberstring
    • documentobject
      Show child attributesHide child attributes
      • typestring

        Possible values:CPFCNPJ

      • numberstring
    • phoneobject
      Show child attributesHide child attributes
      • areaCodestring

        Example:+55

      • dddstring

        Example:11

      • numberstring

        Example:912345678

      • isMobileboolean
  • itemsarray of objectsrequired
    Show child attributesHide child attributes
    • externalReferenceIdstring
    • namestringrequired
    • descriptionstringrequired
    • imageReferencestring
    • quantityintegerrequired
    • priceInCentsintegerrequired
    • paymentLinkIdstring
    • commissionedParticipantsarray of objects
      Show child attributesHide child attributes
      • commissionedIdstring

        The ID of the business to which you want to split the funds

      • commissionedValueInCentsinteger
      • commissionedPercentageinteger
  • metadataarray of objects
    Show child attributesHide child attributes
    • keystring
    • valuestring
  • paymentsarray of objectsrequired
    Show child attributesHide child attributes
    • methodstringrequired

      Possible values:pixcredit-cardbank-billet

    • numberInstallmentsintegerrequired
    • valueInCentsintegerrequired

      Value of the payment, in cents, without interest and without the fees paid by the buyer. The sum of valueInCents of the payments must be equal to the sum of priceInCents times quantity of the items plus shipping.valueInCents; otherwise the API returns 400 with Invalid param: [totalPaymentValueInCents]. Easyflow adds the fees that the buyer pays and the interest of numberInstallments to the payment.

    • pixobject
      Show child attributesHide child attributes
      • expirationInMinutesnumber
    • bankBilletobject
      Show child attributesHide child attributes
      • expirationInDaysnumber
    • creditCardobject

      Card data. Required, with all its fields, for credit card payments. The encrypted card token is sent only in this request and is never returned in a response or a webhook.

      Show child attributesHide child attributes
      • tokenstring

        Encrypted card token returned by the Easyflow JavaScript SDK. Sent only in this request. No response and no webhook returns it.

      • flagstring

        Possible values:visamastercardamerican-expressdiners-clubdiscoverjcbunionpaymaestromirelohiperhipercard

      • last4Numbersstring
      • expiresAtMonthinteger
      • expiresAtYearinteger
      • holderNamestring
  • shippingobject
    Show child attributesHide child attributes
    • valueInCentsnumber
    • deliveryTimeobject
      Show child attributesHide child attributes
      • daysnumber
      • typestring

        Possible values:business-dayscalendar-days

Responses

200order creation was successful

order creation was successful

Content typeapplication/jsonobject

  • statusCodeinteger

    Example:200

  • dataobject
    Show child attributesHide child attributes
    • orderIdstring
    • paymentsarray of strings
400If the provided parameter is invalid, the API will return the following error response:

If the provided parameter is invalid, the API will return the following error response:

Content typeapplication/jsonobject

  • messagestring

    Invalid param: []

    Example:Invalid param: []

  • errorstring

    Bad Request

    Example:Bad Request

  • statusCodeinteger

    400

    Example:400

  • errorCodestring

    Code that identifies the error. Present only on some errors.

401If the request is unauthorized, the API will return the following error response:

If the request is unauthorized, the API will return the following error response:

Content typeapplication/jsonobject

  • messagestring

    Invalid field

    Example:Unauthorized

  • errorstring

    Unauthorized

    Example:Unauthorized

  • statusCodeinteger

    401

    Example:401

403If the request is forbidden, the API will return the following error response:

If the request is forbidden, the API will return the following error response:

Content typeapplication/jsonobject

  • messagestring

    Forbidden resource

    Example:Forbidden resource

  • errorstring

    Forbidden

    Example:Forbidden

  • statusCodeinteger

    403

    Example:403

500If an unexpected condition occurs and the server cannot process the request, the API will return the following error response. This response has no error field.

If an unexpected condition occurs and the server cannot process the request, the API will return the following error response. This response has no error field.

Content typeapplication/jsonobject

  • statusCodeinteger

    HTTP status code.

    Example:500

  • messagestring

    Explanation of the error.

    Example:Internal Server Error