Skip to main content

Generating a charge to the user's wallet

With a valid access_token, the process of generating a charge on the customer's wallet is extremely simple and seamless. The charge must be generated through the endpoint v1/payments/charge, indicating the amount to be debited in the body of the request. In the example below, we are requesting a charge of BRL 3.00 to the user's wallet.

Endpoint#

POST https://ecommerce-api.svc.picpay.com/v1/payments/charge

Request example#

curl --location --request POST 'https://ecommerce-api.svc.picpay.com/v1/payments/charge' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--header 'x-Idempotency-Key: {{idempotency_key}}' \
--data '{
"value": 3.0,
"reference_id": "c413fcb5-d963-4b93-8218-3b776f656553",
"auto_capture": true,
"description": "{PRODUCT_DESCRIPTION}",
"transaction_initiator": "{INITIATOR_ENUM}"
}'

Body parameters#

FieldTypeRequiredDescription
valuefloatYesCharge amount (max. 5 integer digits, 2 decimal places)
reference_idstringNoExternal identifier from the seller
auto_capturebooleanNoDefault: true. If false, enables deferred capture
descriptionstringNoPurchase description (max. 256 characters)
transaction_initiatorenumNoMIT (seller initiated) or CIT (consumer initiated)
info

The description field refers to the purchase description. This field is configurable and requires prior alignment with the business team.

info

The transaction_initiator field indicates who initiated the transaction flow. This field is optional and, when provided, must be one of the ENUM values below:

  • MIT — The seller initiated the transaction flow (e.g., recurring payment).
  • CIT — The consumer initiated the transaction flow.

If not provided, the field will be null.

Important: This field is not included in the responses from the charge endpoint, even if it is provided in the request. Its usage is restricted to internal control of payment flows.

Resulting statuses#

StatusScenario
PAIDApproved with automatic capture
AUTHORIZEDApproved with deferred capture (auto_capture: false)
REFUSEDDeclined (any reason)
ERRORTimeout (>30s) — transaction automatically reversed

Below is an example of a successful response. The transaction_id and reference_id fields should be stored as they are the keys for refund, capture, and lookup processes.

{
"transaction_id": "e646263b-2b4d-4b2c-93d8-2568fbffb744",
"reference_id": "04c923a4-34d6-43e8-89db-1b563f887b53",
"created_at": "2021-02-22 19:29:16"
}

What will be the source of funds?#

The charge amount may be debited from the credit card, balance, or both (balance + card). If the customer has the Use balance option enabled in the App, we will first consume the user's balance and subsequently (if there is not enough balance), charge the card.

Example: I'm making a purchase of R$60 and have a balance of R$19 in my wallet. PicPay will consume R$19 and charge the registered card for R$41.

Error messages#

business_codeHTTPDescription
INSUFFICIENT_FUNDS200Insufficient balance. The user must add funds or register a card
INVALID_FUNDING_SOURCE422Invalid card. Do not retry
FUNDING_SOURCE_UNAVAILABLE422Payment method unavailable
RISK_DECLINED422Declined by risk analysis
ACCOUNT_CLOSED422Account closed
ACCOUNT_ON_HOLD422Account temporarily blocked
TRANSACTION_EXCEEDS_LIMIT422Exceeds account limit
TRANSACTION_EXCEEDS_MONTHLY_LIMIT422Exceeds monthly limit
TRANSACTION_ENRICHMENT_BAD_REQUEST422Incorrect product/profile configuration
USER_RETRIES_EXCEEDED422Allowed retry attempts exceeded
DUPLICATED_TRANSACTION409Duplicate transaction
DUPLICATED_REFERENCE_ID409reference_id already used by this seller
REQUEST_TIMEOUT502Timeout (>30s). Transaction automatically reversed
PSP_PAYMENT_ERROR502Payment provider error
SERVICE_UNAVAILABLE502Service temporarily unavailable

For card declines, the response includes acquirer_response with reason_code and reason_message per card network (ABECS 021).

Charge timeout#

A payment currently has a default timeout of 30 seconds. If the payment takes longer than 30 seconds, the API will return HTTP 502 with business_code: REQUEST_TIMEOUT. If the payment is resolved later, it will automatically be reversed through an automatic refund.

{
"message": "Request took too long to process.",
"business_code": "REQUEST_TIMEOUT"
}