Passa al contenuto principale
In questa pagina

Inizia con NuPay#

Questa pagina fornisce una guida completa per integrare con successo NuPay con DEUNA.

NuPay è una piattaforma avanzata di proprietà di Nubank. NuPay semplifica i pagamenti online e le transazioni finanziarie, offrendo una soluzione sicura e affidabile per le tue esigenze di elaborazione dei pagamenti.

Requisiti#

I seguenti contenuti elencano tutti i requisiti per una corretta integrazione.

Le credenziali di produzione e sandbox NuPay devono essere richieste direttamente dal gestore del tuo account NuBank.

Ambienti:

Collezione Postman:

Procedura di integrazione#

Ora che i requisiti tecnici sono impostati, è possibile avviare l'integrazione.

1. Creare un order_token

Per effettuare un acquisto, è necessario creare un ordine DEUNA.

Fai una richiesta al Creare un Ordine endpoint.

L'API restituisce un order_token che viene utilizzato durante tutto il flusso.

Richiesta

JSON
{
  "order": {
    "order_id": "{{$randomUUID}}", // this can be updated using the "1.2 Update order"
    "store_code": "all", // very important is "all"
    "currency": "BRL",
    "items_total_amount": 1,
    "tax_amount": 0,
    "sub_total": 13000,
    "shipping_amount": 0,
    "payment_method": "wallet", // required for NuPay
    "shipping_tax_amount": 0,
    "total_tax_amount": 0,
    "total_amount": 13000,
    "discounts": [],
    "items": [
      {
        "id": "{{$randomUUID}}",
        "name": "Papas",
        "description": "Papas fritas con paprica",
        "total_amount": {
          "original_amount": 2100,
          "amount": 2050,
          "total_discount": 100,
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "unit_price": {
          "amount": 1050,
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "tax_amount": {
          "amount": 50,
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "quantity": 2,
        "image_url": "https://media-cdn.tripadvisor.com/media/photo-s/1a/e2/c6/68/porcion-de-papas-a-la.jpg",
        "taxable": true
      },
      {
        "id": "{{$randomUUID}}",
        "name": "Refresco",
        "description": "Coca-cola Sprite",
        "total_amount": {
          "original_amount": 75,
          "amount": 90,
          "total_discount": 0,
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "unit_price": {
          "amount": 75,
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "tax_amount": {
          "amount": 15,
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "quantity": 1,
        "image_url": "https://media-cdn.tripadvisor.com/media/photo-s/1a/e2/c6/68/porcion-de-papas-a-la.jpg",
        "taxable": true
      }
    ],
    "shipping_address": {
      "id": "{{$randomInt}}",
      "first_name": "Pablo",
      "last_name": "Murillo",
      "email": "johndoe@deuna.com",
      "identity_document": "58188896454", // required for NuPay
      "identity_document_type": "CPF", // required for NuPay
      "address1": "Praia de Botafogo St.,",
      "address2": "3o. Andar",
      "zipcode": "22251-050",
      "city": "Rio de Janeiro",
      "state_name": "Rio de Janeiro",
      "country_code": "BRA",
      "phone": "+551146733466",
      "lat": -22.943934,
      "lng": -43.182984,
      "additional_description": "confirmar",
      "address_type": "home"
    },
    "billing_address": {
      "id": "{{$randomInt}}",
      "first_name": "Jean",
      "last_name": "Roldan",
      "email": "jroldan@deuna.com",
      "identity_document": "58188896454", // required for NuPay
      "identity_document_type": "CPF", // required for NuPay
      "address1": "Rua Capote Valente",
      "address2": "Pinheiros",
      "zipcode": "05409-002",
      "city": "São Paulo",
      "state_name": "SP",
      "country_code": "BRA",
      "phone": "+5521988939196",
      "lat": -23.555425,
      "lng": -46.677048,
      "address_type": "home"
    },
    "metadata": {
      "origin": "core"
    },
    "browser_details": {
      "screen_height": 1000,
      "screen_width": 2000
    },
    **"webhook_urls": {
      "notify_order": "https://webhook.site/065ef7c7-38e8-48aa-9da7-49f73a2d7a2a" // URL for DEUNA to send webhooks
    }**
  }
}

Restituisce l’ordine elaborato con

JSON
{
  "token": "dca264ff-f608-4e0e-99b1-6fed95ddaaae",
  "order_type": "DEUNA_CHECKOUT",
  "order": {
    "order_id": "adb1ef51-e073-49f5-ba3b-a7e42344fd15",
    "store_code": "all",
    "currency": "BRL",
    "tax_amount": 0,
    "display_tax_amount": "BRL 0,00",
    "shipping_amount": 0,
    "display_shipping_amount": "BRL 0,00",
    "items_total_amount": 1,
    "display_items_total_amount": "BRL 0,01",
    "sub_total": 13000,
    "display_sub_total": "BRL 130,00",
    "total_amount": 13000,
    "display_total_amount": "BRL 130,00",
    "items": [
      {
        "id": "8791e81b-5c20-414d-a1ae-3d5ad29bd477",
        "name": "Papas",
        "description": "Papas fritas con paprica",
        "options": "",
        "total_amount": {
          "amount": 2050,
          "original_amount": 2100,
          "display_amount": "BRL 20,50",
          "display_original_amount": "BRL 21,00",
          "currency": "BRL",
          "currency_symbol": "R$",
          "total_discount": 100,
          "display_total_discount": "BRL 1,00"
        },
        "unit_price": {
          "amount": 1050,
          "display_amount": "BRL 10,50",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "tax_amount": {
          "amount": 50,
          "display_amount": "BRL 0,50",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "quantity": 2,
        "uom": "",
        "upc": "",
        "sku": "",
        "isbn": "",
        "brand": "",
        "manufacturer": "",
        "category": "",
        "color": "",
        "size": "",
        "weight": {
          "weight": 0,
          "unit": ""
        },
        "image_url": "https://media-cdn.tripadvisor.com/media/photo-s/1a/e2/c6/68/porcion-de-papas-a-la.jpg",
        "details_url": "",
        "type": "",
        "taxable": true,
        "discounts": [],
        "included_in_subscription": false,
        "subscription_id": "00000000-0000-0000-0000-000000000000",
        "item_details": []
      },
      {
        "id": "d4ee0dd0-22f2-44c8-9603-7a9c29a20afa",
        "name": "Refresco",
        "description": "Coca-cola Sprite",
        "options": "",
        "total_amount": {
          "amount": 90,
          "original_amount": 75,
          "display_amount": "BRL 0,90",
          "display_original_amount": "BRL 0,75",
          "currency": "BRL",
          "currency_symbol": "R$",
          "total_discount": 0,
          "display_total_discount": "BRL 0,00"
        },
        "unit_price": {
          "amount": 75,
          "display_amount": "BRL 0,75",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "tax_amount": {
          "amount": 15,
          "display_amount": "BRL 0,15",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "quantity": 1,
        "uom": "",
        "upc": "",
        "sku": "",
        "isbn": "",
        "brand": "",
        "manufacturer": "",
        "category": "",
        "color": "",
        "size": "",
        "weight": {
          "weight": 0,
          "unit": ""
        },
        "image_url": "https://media-cdn.tripadvisor.com/media/photo-s/1a/e2/c6/68/porcion-de-papas-a-la.jpg",
        "details_url": "",
        "type": "",
        "taxable": true,
        "discounts": [],
        "included_in_subscription": false,
        "subscription_id": "00000000-0000-0000-0000-000000000000",
        "item_details": []
      }
    ],
    "discounts": [],
    "shipping_address": {
      "id": 994,
      "user_id": "",
      "first_name": "Pablo",
      "last_name": "Murillo",
      "phone": "+551146733466",
      "identity_document": "58188896454",
      "lat": -22.943934,
      "lng": -43.182984,
      "address1": "Praia de Botafogo St.,",
      "address2": "3o. Andar",
      "city": "Rio de Janeiro",
      "zipcode": "22251-050",
      "state_name": "Rio de Janeiro",
      "country_code": "BRA",
      "additional_description": "confirmar",
      "address_type": "home",
      "is_default": false,
      "created_at": "0001-01-01T00:00:00Z",
      "updated_at": "0001-01-01T00:00:00Z",
      "identity_document_type": "CPF"
    },
    "shipping_options": {
      "type": "",
      "details": {
        "store_name": "",
        "address": "",
        "address_coordinates": {
          "lat": 0,
          "lng": 0
        },
        "contact": {
          "name": "",
          "phone": ""
        },
        "additional_details": {
          "pickup_time": "0001-01-01T00:00:00Z",
          "stock_location": ""
        }
      }
    },
    "user_instructions": "",
    "metadata": {
      "origin": "core"
    },
    "status": "pending",
    "payment": {
      "data": {
        "amount": {
          "amount": 0,
          "currency": ""
        },
        "metadata": {},
        "from_card": {
          "card_brand": "",
          "first_six": "",
          "last_four": "",
          "bank_name": "",
          "country_iso": ""
        },
        "updated_at": "0001-01-01 00:00:00 +0000 UTC",
        "method_type": "",
        "merchant": {
          "store_code": "",
          "id": ""
        },
        "created_at": "0001-01-01 00:00:00 +0000 UTC",
        "id": "",
        "processor": "",
        "customer": {
          "email": "",
          "id": "",
          "first_name": "",
          "last_name": ""
        },
        "status": "",
        "reason": "",
        "external_transaction_id": "",
        "merchant_payment_processor_name": "",
        "authorization_code": "",
        "installment_interest_calculations": null
      }
    },
    "gift_card": [],
    "redirect_url": "",
    "webhook_urls": null,
    "total_discount": 0,
    "display_total_discount": "BRL 0,00",
    "shipping": {
      "original_amount": 0,
      "total_discount": 0,
      "discounts": []
    },
    "cash_change": 0,
    "shipping_method": {
      "code": "",
      "name": "",
      "min_delivery_date": "",
      "max_delivery_date": "",
      "cost": 0,
      "display_cost": "",
      "tax_amount": 0,
      "display_tax_amount": "",
      "scheduler": []
    },
    "shipping_methods": [],
    "timezone": "",
    "scheduled_at": "",
    "billing_address": {
      "id": 688,
      "user_id": "",
      "first_name": "Jean",
      "last_name": "Roldan",
      "phone": "+5521988939196",
      "identity_document": "58188896454",
      "lat": -23.555425,
      "lng": -46.677048,
      "address1": "Rua Capote Valente",
      "address2": "Pinheiros",
      "city": "São Paulo",
      "zipcode": "05409-002",
      "state_name": "SP",
      "country_code": "BRA",
      "additional_description": "",
      "address_type": "home",
      "is_default": false,
      "created_at": "0001-01-01T00:00:00Z",
      "updated_at": "0001-01-01T00:00:00Z",
      "email": "jroldan@deuna.com",
      "identity_document_type": "CPF"
    },
    "payment_link": "",
    "display_shipping_tax_amount": "BRL 0,00",
    "display_total_tax_amount": "BRL 0,00",
    "shipping_tax_amount": 0,
    "total_tax_amount": 0,
    "user_id": "",
    "include_payment_options": [],
    "redirect_urls": {
      "success": "",
      "pending": "",
      "error": "",
      "fallback": "",
      "close": ""
    },
    "created_at": "2024-07-16 14:22:00.336911694 +0000 UTC",
    "updated_at": "",
    "payer_info": null,
    "discount_amount": 0,
    "shipping_discount_amount": 0,
    "device_fingerprint": "",
    "expired_at": "",
    "version": "0",
    "fraud": null,
    "total_interest_amount": 0,
    "display_total_interest_amount": "BRL 0,00",
    "payment_method": "",
    "token": "",
    "statement_descriptor": ""
  },
  "custom_fields": [],
  "checkout_modules": []
}

2. Ottenere informazioni di ordine

Fai una richiesta al Ordinare endpoint.

Utilizzare questo token per i prossimi passi.

Restituisce l’ordine elaborato con

JSON
{
  "token": "dca264ff-f608-4e0e-99b1-6fed95ddaaae",
  "order_type": "DEUNA_CHECKOUT",
  "order": {
    "order_id": "adb1ef51-e073-49f5-ba3b-a7e42344fd15",
    "store_code": "all",
    "currency": "BRL",
    "tax_amount": 0,
    "display_tax_amount": "BRL 0,00",
    "shipping_amount": 0,
    "display_shipping_amount": "BRL 0,00",
    "items_total_amount": 1,
    "display_items_total_amount": "BRL 0,01",
    "sub_total": 13000,
    "display_sub_total": "BRL 130,00",
    "total_amount": 13000,
    "display_total_amount": "BRL 130,00",
    "items": [
      {
        "id": "8791e81b-5c20-414d-a1ae-3d5ad29bd477",
        "name": "Papas",
        "description": "Papas fritas con paprica",
        "options": "",
        "total_amount": {
          "amount": 2050,
          "original_amount": 2100,
          "display_amount": "BRL 20,50",
          "display_original_amount": "BRL 21,00",
          "currency": "BRL",
          "currency_symbol": "R$",
          "total_discount": 100,
          "display_total_discount": "BRL 1,00"
        },
        "unit_price": {
          "amount": 1050,
          "display_amount": "BRL 10,50",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "tax_amount": {
          "amount": 50,
          "display_amount": "BRL 0,50",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "quantity": 2,
        "uom": "",
        "upc": "",
        "sku": "",
        "isbn": "",
        "brand": "",
        "manufacturer": "",
        "category": "",
        "color": "",
        "size": "",
        "weight": {
          "weight": 0,
          "unit": ""
        },
        "image_url": "https://media-cdn.tripadvisor.com/media/photo-s/1a/e2/c6/68/porcion-de-papas-a-la.jpg",
        "details_url": "",
        "type": "",
        "taxable": true,
        "discounts": [],
        "included_in_subscription": false,
        "subscription_id": "00000000-0000-0000-0000-000000000000",
        "item_details": []
      },
      {
        "id": "d4ee0dd0-22f2-44c8-9603-7a9c29a20afa",
        "name": "Refresco",
        "description": "Coca-cola Sprite",
        "options": "",
        "total_amount": {
          "amount": 90,
          "original_amount": 75,
          "display_amount": "BRL 0,90",
          "display_original_amount": "BRL 0,75",
          "currency": "BRL",
          "currency_symbol": "R$",
          "total_discount": 0,
          "display_total_discount": "BRL 0,00"
        },
        "unit_price": {
          "amount": 75,
          "display_amount": "BRL 0,75",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "tax_amount": {
          "amount": 15,
          "display_amount": "BRL 0,15",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "quantity": 1,
        "uom": "",
        "upc": "",
        "sku": "",
        "isbn": "",
        "brand": "",
        "manufacturer": "",
        "category": "",
        "color": "",
        "size": "",
        "weight": {
          "weight": 0,
          "unit": ""
        },
        "image_url": "https://media-cdn.tripadvisor.com/media/photo-s/1a/e2/c6/68/porcion-de-papas-a-la.jpg",
        "details_url": "",
        "type": "",
        "taxable": true,
        "discounts": [],
        "included_in_subscription": false,
        "subscription_id": "00000000-0000-0000-0000-000000000000",
        "item_details": []
      }
    ],
    "discounts": [],
    "shipping_address": {
      "id": 994,
      "user_id": "",
      "first_name": "Pablo",
      "last_name": "Murillo",
      "phone": "+551146733466",
      "identity_document": "58188896454",
      "lat": -22.943934,
      "lng": -43.182984,
      "address1": "Praia de Botafogo St.,",
      "address2": "3o. Andar",
      "city": "Rio de Janeiro",
      "zipcode": "22251-050",
      "state_name": "Rio de Janeiro",
      "country_code": "BRA",
      "additional_description": "confirmar",
      "address_type": "home",
      "is_default": false,
      "created_at": "0001-01-01T00:00:00Z",
      "updated_at": "0001-01-01T00:00:00Z",
      "identity_document_type": "CPF"
    },
    "shipping_options": {
      "type": "",
      "details": {
        "store_name": "",
        "address": "",
        "address_coordinates": {
          "lat": 0,
          "lng": 0
        },
        "contact": {
          "name": "",
          "phone": ""
        },
        "additional_details": {
          "pickup_time": "0001-01-01T00:00:00Z",
          "stock_location": ""
        }
      }
    },
    "user_instructions": "",
    "metadata": {
      "origin": "core"
    },
    "status": "pending",
    "payment": {
      "data": {
        "amount": {
          "amount": 0,
          "currency": ""
        },
        "metadata": {},
        "from_card": {
          "card_brand": "",
          "first_six": "",
          "last_four": "",
          "bank_name": "",
          "country_iso": ""
        },
        "updated_at": "0001-01-01 00:00:00 +0000 UTC",
        "method_type": "",
        "merchant": {
          "store_code": "",
          "id": ""
        },
        "created_at": "0001-01-01 00:00:00 +0000 UTC",
        "id": "",
        "processor": "",
        "customer": {
          "email": "",
          "id": "",
          "first_name": "",
          "last_name": ""
        },
        "status": "",
        "reason": "",
        "external_transaction_id": "",
        "merchant_payment_processor_name": "",
        "authorization_code": "",
        "installment_interest_calculations": null
      }
    },
    "gift_card": [],
    "redirect_url": "",
    "webhook_urls": null,
    "total_discount": 0,
    "display_total_discount": "BRL 0,00",
    "shipping": {
      "original_amount": 0,
      "total_discount": 0,
      "discounts": []
    },
    "cash_change": 0,
    "shipping_method": {
      "code": "",
      "name": "",
      "min_delivery_date": "",
      "max_delivery_date": "",
      "cost": 0,
      "display_cost": "",
      "tax_amount": 0,
      "display_tax_amount": "",
      "scheduler": []
    },
    "shipping_methods": [],
    "timezone": "",
    "scheduled_at": "",
    "billing_address": {
      "id": 688,
      "user_id": "",
      "first_name": "Jean",
      "last_name": "Roldan",
      "phone": "+5521988939196",
      "identity_document": "58188896454",
      "lat": -23.555425,
      "lng": -46.677048,
      "address1": "Rua Capote Valente",
      "address2": "Pinheiros",
      "city": "São Paulo",
      "zipcode": "05409-002",
      "state_name": "SP",
      "country_code": "BRA",
      "additional_description": "",
      "address_type": "home",
      "is_default": false,
      "created_at": "0001-01-01T00:00:00Z",
      "updated_at": "0001-01-01T00:00:00Z",
      "email": "jroldan@deuna.com",
      "identity_document_type": "CPF"
    },
    "payment_link": "",
    "display_shipping_tax_amount": "BRL 0,00",
    "display_total_tax_amount": "BRL 0,00",
    "shipping_tax_amount": 0,
    "total_tax_amount": 0,
    "user_id": "",
    "include_payment_options": [],
    "redirect_urls": {
      "success": "",
      "pending": "",
      "error": "",
      "fallback": "",
      "close": ""
    },
    "created_at": "2024-07-16 14:22:00.336911694 +0000 UTC",
    "updated_at": "",
    "payer_info": null,
    "discount_amount": 0,
    "shipping_discount_amount": 0,
    "device_fingerprint": "",
    "expired_at": "",
    "version": "0",
    "fraud": null,
    "total_interest_amount": 0,
    "display_total_interest_amount": "BRL 0,00",
    "payment_method": "",
    "token": "",
    "statement_descriptor": ""
  },
  "custom_fields": [],
  "checkout_modules": [],
  "refunds": []
}

Controlla il consenso del cliente mentre autorizza il pagamento nel proprio account.

Semplificare lo stato inquinando fino a quando lo stato cambia.

Stazioni di consenso:

  • pending

  • success

  • failed

Restituisce l’ordine elaborato con

JSON
{
  "id": "f9c35e61-d2ff-444a-9b3b-ce3c8e9f0597",
  "type": "transaction.authentication.pending",
  "created": "1721140413",
  "callback_url": "",
  "data": {
    "request_id": "",
    "order": {
      "order_token": "dca264ff-f608-4e0e-99b1-6fed95ddaaae",
      "transaction_id": "adb1ef51-e073-49f5-ba3b-a7e42344fd15",
      "external_transaction_id": ""
    },
    "consent": {
      "id": "020f896d-15f8-48c1-8358-01d50b70d5a9",
      "status": "pending",
      "expires_at": "2024-07-16T14:43:33.435273111Z",
      "authorization_id": "BzxEmevjvSU8D4_GI6CJeZzY9IcS4lDaP4Dmwr8WQSg"
    },
    "error": null
  }
}

Per ottenere lo stato attuale, si può.

  • Fai una richiesta di GET per vedere il nuovo stato.
  • Ricevi l'aggiornamento dello stato attraverso webhooks.

DEUNA invia l'aggiornamento dello stato attraverso un evento webhook.

Controllare che il campo status ora contiene il valore “success”.

Ottieni il consenso del cliente mentre autorizza il pagamento nel suo account.

Richiesta

curl --location '{{base_url}}/merchants/orders/{{order_token}}/consent' \
--header 'X-API-KEY: {{merchant_private_key}}' \
--header 'Content-Type: application/json' \
--header 'X-Request-Id: xxxxx' \
--header 'Authorization: {{user_token}}'

Restituisce l’ordine elaborato con

JSON
{
  "id": "75a2a589-ffe6-4d75-b3b3-6c4950f9fd6d",
  "type": "transaction.authentication.updated",
  "created": "1721140820",
  "callback_url": "",
  "data": {
    "request_id": "4e72819f-dec6-4d1d-b474-1f47e2ca24ba",
    "order": {
      "order_token": "dca264ff-f608-4e0e-99b1-6fed95ddaaae",
      "transaction_id": "adb1ef51-e073-49f5-ba3b-a7e42344fd15",
      "external_transaction_id": ""
    },
    "consent": {
      "id": "020f896d-15f8-48c1-8358-01d50b70d5a9",
      "status": "success",
      "expires_at": "2024-07-31T14:33:59.015219Z",
      "authorization_id": "BzxEmevjvSU8D4_GI6CJeZzY9IcS4lDaP4Dmwr8WQSg"
    },
    "error": null
  }
}

5. Ottenere metodi di pagamento

Confermare i metodi di pagamento per ottenere la configurazione NuPay.

Fai una richiesta al Ottieni metodi di pagamento endpoint.

La risposta contiene:

  • I metodi di pagamento disponibili per l'acquisto.
  • Il numero di rate che il cliente può utilizzare.

Risposte corrette per method_type" include:

  • "nupay_credit"
  • "nupay_debit"
  • "nupay_credit_with_additional_limit"

Restituisce l’ordine elaborato con

JSON
{
  "@type": "type.googleapis.com/external_merchant_api.v1.GetPaymentMethodsResponse",
  "data": [
    {
      "enabled": true,
      "method_type": "nupay_credit",
      "processor_name": "nupay",
      "specific_fields": null,
      "input_schema": [],
      "labels": {
        "es": ""
      },
      "exclude_cvv": false,
      "excluded_franchises": [],
      "extra_params": {},
      "installments": [
        {
          "installments": 1,
          "installments_amount": 13000,
          "display_installments_amount": "130.00",
          "installment_rate": 0,
          "display_installment_label": "",
          "plan_option_id": "c397a748-eda8-4878-a5b2-953415b51fad",
          "installment_total_amount": "13000",
          "amount_percentage": 10.0,
          "total_amount_percentage": 10.0,
          "installment_plan_additional_limit": 10.0,
          "installment_tax": [
          {
            "id": "INTERESTS",
            "rate": 0.05,
            "tax_amount": 1250
          },
          {
            "id": "IOF",
            "rate": 0.0038,
            "tax_amount": 125
          },
          {
            "id": "CET",
            "rate": 0.054,
            "tax_amount": 0
          }
         ]
        },
        {
          "installments": 2,
          "installments_amount": 6500,
          "display_installments_amount": "65.00",
          "installment_rate": 0,
          "display_installment_label": "",
          "plan_option_id": "cc39c974-5650-468e-ae1e-1a57b369fc74",
          "installment_total_amount": "6500",
          "amount_percentage": 10.0,
          "total_amount_percentage": 10.0,
          "installment_plan_additional_limit": 9.0,
          "installment_tax": [
          {
            "id": "INTERESTS",
            "rate": 0.05,
            "tax_amount": 1250
          },
          {
            "id": "IOF",
            "rate": 0.0038,
            "tax_amount": 125
          },
          {
            "id": "CET",
            "rate": 0.054,
            "tax_amount": 0
          }
         ]
        }
      ],
      "credentials": {
        "public_api_key": "",
        "external_merchant_id": ""
      }
    }
  ]
}

6. Effettua un acquisto

Fai una richiesta al Acquisto V2 endpoint e processare il pagamento.

Restituisce l’ordine elaborato con

JSON
{
  "order": {
    "cash_change": 0,
    "currency": "USD",
    "discounts": [],
    "display_items_total_amount": "",
    "display_shipping_amount": "",
    "display_sub_total": "",
    "display_tax_amount": "",
    "display_total_amount": "",
    "display_total_discount": "",
    "gift_card": [],
    "items": [
      {
        "brand": "",
        "category": "",
        "color": "",
        "description": "Papa Fritas",
        "details_url": "",
        "discounts": [],
        "id": "001",
        "image_url": "https://images-staging.getduna.com/95463fb5-6279-4ec3-8ff9-fe07aacd2142/cd928351d12c6b96_domicilio_316_744x744.png?d=600x600",
        "isbn": "",
        "manufacturer": "",
        "name": "Papa Fritas",
        "options": "",
        "quantity": 1,
        "size": "",
        "sku": "",
        "tax_amount": {
          "amount": 44,
          "currency": "USD",
          "currency_symbol": "$",
          "display_amount": ""
        },
        "taxable": false,
        "total_amount": {
          "amount": 594,
          "currency": "USD",
          "currency_symbol": "$",
          "display_amount": "",
          "display_original_amount": "",
          "display_total_discount": "",
          "original_amount": 0,
          "total_discount": 0
        },
        "type": "",
        "unit_price": {
          "amount": 550,
          "currency": "USD",
          "currency_symbol": "$",
          "display_amount": ""
        },
        "uom": "",
        "upc": "",
        "weight": {
          "unit": "",
          "weight": 0
        }
      },
      {
        "brand": "",
        "category": "",
        "color": "",
        "description": "Hamburguesa ",
        "details_url": "",
        "discounts": [],
        "id": "002",
        "image_url": "https://images-staging.getduna.com/95463fb5-6279-4ec3-8ff9-fe07aacd2142/cd928351d12c6b96_domicilio_51330_744x744_1646338877.png?d=600x600",
        "isbn": "",
        "manufacturer": "",
        "name": "Hamburguesa",
        "options": "",
        "quantity": 2,
        "size": "",
        "sku": "",
        "tax_amount": {
          "amount": 88,
          "currency": "USD",
          "currency_symbol": "$",
          "display_amount": ""
        },
        "taxable": false,
        "total_amount": {
          "amount": 3088,
          "currency": "USD",
          "currency_symbol": "$",
          "display_amount": "",
          "display_original_amount": "",
          "display_total_discount": "",
          "original_amount": 0,
          "total_discount": 0
        },
        "type": "",
        "unit_price": {
          "amount": 1500,
          "currency": "USD",
          "currency_symbol": "$",
          "display_amount": ""
        },
        "uom": "",
        "upc": "",
        "weight": {
          "unit": "",
          "weight": 0
        }
      }
    ],
    "items_total_amount": 3682,
    "metadata": {
      "key1": "NO REQUERIDO",
      "key2": "NO REQUERIDO"
    },
    "order_id": "order116",
    "payment": {
      "data": {
        "amount": {
          "amount": 3770,
          "currency": "USD"
        },
        "authorization_3ds": {
          "html_content": "<div></div>",
          "url_challenge": "",
          "version": "1.1.1"
        },
        "authorization_code": "TEST00",
        "created_at": "2022-07-22 20:22:48.408419489 +0000 UTC",
        "customer": {
          "email": "jhondoe@deuna.com",
          "id": "xxxxxx-0eb3-450f-8b26-4ff23208470f"
        },
        "from_card": {
          "card_brand": "Visa",
          "first_six": "411111",
          "last_four": "1111"
        },
        "id": "order116",
        "installments": {
          "installment_amount": 5999,
          "installment_rate": 0.12,
          "installment_type": "MCI",
          "installments": 3,
          "plan_id": "7471ed27-094d-44c4-a62d-225644b782f7",
          "plan_option_id": "87309ea8-3942-4fdf-95ec-ce29a792aff2"
        },
        "merchant": {
          "id": "9a85e296-cc3d-454b-b591-208d6e538126",
          "store_code": "all"
        },
        "metadata": {
          "authorization_code": "TEST00"
        },
        "method_type": "credit_card",
        "processor": "paymentez",
        "reason": "",
        "status": "processed",
        "updated_at": "2022-07-22 20:22:48.408809765 +0000 UTC"
      }
    },
    "redirect_url": "",
    "scheduled_at": "",
    "shipping": null,
    "shipping_address": {
      "additional_description": "Piso 9",
      "address_type": "home",
      "address1": "Av. de los Incas 15-33, Ambato 180202, Ecuador",
      "address2": "Av. de los Incas 15-33, Ambato 180202, Ecuador",
      "city": "Ambato",
      "country_code": "EC",
      "created_at": "0001-01-01T00:00:00Z",
      "first_name": "Jhon",
      "id": 0,
      "identity_document": "146565656",
      "is_default": true,
      "last_name": "Doe",
      "lat": -1.2480678792202227,
      "lng": -78.62532788804577,
      "phone": " 946565665",
      "state_name": "Tungurahua",
      "updated_at": "0001-01-01T00:00:00Z",
      "user_id": "xxxxx4e2-xxxx-xxxx-xxxx-xxxxx5b7b2e",
      "zipcode": "180202"
    },
    "shipping_amount": 0,
    "shipping_method": null,
    "shipping_methods": [],
    "shipping_options": {},
    "status": "succeeded",
    "store_code": "",
    "sub_total": 3550,
    "tax_amount": 132,
    "timezone": "",
    "total_amount": 3770,
    "total_discount": 0,
    "user_instructions": "Piso 9",
    "webhook_urls": null
  },
  "order_token": "0b98dbe8-d265-49bc-b80d-536cea46509c"
}

Test e integrazione dei dati#

Questa sezione fornisce informazioni di prova e risposta per una corretta integrazione con NuPay.

Installazioni di pagamento

È necessario che l'oggetto di installazione sia riempito con plan_option_id attributo. Per un pagamento, utilizzare 1 installment.

Richiesta

JSON
{
    "transaction_id": "{{transaction_id}}",
    "amount": {{total_amount}},
    "device_id": "{{$randomUUID}}",
    "order_token": "{{order_token}}",
    "payer_info": {
        "email": "eposada@deuna.com" // email of the purchaser
    },
    "payment_source": {
        "method_type": "nupay_credit",
        "processor": "NUPAY",
        **"installment": {
            "plan_option_id": "{{plan_option_id}}" // Here you must send the plan_option_id for 1x installment, for debit or credit.
        }
    }
}

Restituisce l’ordine elaborato con

JSON
{
  "order_type": "DEUNA_CHECKOUT",
  "order_token": "dca264ff-f608-4e0e-99b1-6fed95ddaaae",
  "order": {
    "order_id": "adb1ef51-e073-49f5-ba3b-a7e42344fd15",
    "store_code": "all",
    "currency": "BRL",
    "tax_amount": 0,
    "display_tax_amount": "",
    "shipping_amount": 0,
    "display_shipping_amount": "BRL 0,00",
    "items_total_amount": 1,
    "display_items_total_amount": "BRL 0,01",
    "sub_total": 13000,
    "display_sub_total": "BRL 130,00",
    "total_amount": 13000,
    "display_total_amount": "BRL 130,00",
    "items": [
      {
        "id": "8791e81b-5c20-414d-a1ae-3d5ad29bd477",
        "name": "Papas",
        "description": "Papas fritas con paprica",
        "options": "",
        "total_amount": {
          "amount": 2050,
          "original_amount": 2100,
          "display_amount": "BRL 20,50",
          "display_original_amount": "BRL 21,00",
          "currency": "BRL",
          "currency_symbol": "R$",
          "total_discount": 100,
          "display_total_discount": "BRL 1,00"
        },
        "unit_price": {
          "amount": 1050,
          "display_amount": "BRL 10,50",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "tax_amount": {
          "amount": 50,
          "display_amount": "BRL 0,50",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "quantity": 2,
        "uom": "",
        "upc": "",
        "sku": "",
        "isbn": "",
        "brand": "",
        "manufacturer": "",
        "category": "",
        "color": "",
        "size": "",
        "weight": {
          "weight": 0,
          "unit": ""
        },
        "image_url": "https://media-cdn.tripadvisor.com/media/photo-s/1a/e2/c6/68/porcion-de-papas-a-la.jpg",
        "details_url": "",
        "type": "",
        "taxable": true,
        "discounts": [],
        "included_in_subscription": false,
        "subscription_id": "00000000-0000-0000-0000-000000000000",
        "item_details": []
      },
      {
        "id": "d4ee0dd0-22f2-44c8-9603-7a9c29a20afa",
        "name": "Refresco",
        "description": "Coca-cola Sprite",
        "options": "",
        "total_amount": {
          "amount": 90,
          "original_amount": 75,
          "display_amount": "BRL 0,90",
          "display_original_amount": "BRL 0,75",
          "currency": "BRL",
          "currency_symbol": "R$",
          "total_discount": 0,
          "display_total_discount": "BRL 0,00"
        },
        "unit_price": {
          "amount": 75,
          "display_amount": "BRL 0,75",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "tax_amount": {
          "amount": 15,
          "display_amount": "BRL 0,15",
          "currency": "BRL",
          "currency_symbol": "R$"
        },
        "quantity": 1,
        "uom": "",
        "upc": "",
        "sku": "",
        "isbn": "",
        "brand": "",
        "manufacturer": "",
        "category": "",
        "color": "",
        "size": "",
        "weight": {
          "weight": 0,
          "unit": ""
        },
        "image_url": "https://media-cdn.tripadvisor.com/media/photo-s/1a/e2/c6/68/porcion-de-papas-a-la.jpg",
        "details_url": "",
        "type": "",
        "taxable": true,
        "discounts": [],
        "included_in_subscription": false,
        "subscription_id": "00000000-0000-0000-0000-000000000000",
        "item_details": []
      }
    ],
    "discounts": [],
    "shipping_address": {
      "id": 994,
      "user_id": "",
      "first_name": "Pablo",
      "last_name": "Murillo",
      "phone": "+551146733466",
      "identity_document": "58188896454",
      "lat": -22.943934,
      "lng": -43.182984,
      "address1": "Praia de Botafogo St.,",
      "address2": "3o. Andar",
      "city": "Rio de Janeiro",
      "zipcode": "22251-050",
      "state_name": "Rio de Janeiro",
      "country_code": "BRA",
      "additional_description": "confirmar",
      "address_type": "home",
      "is_default": false,
      "created_at": "0001-01-01T00:00:00Z",
      "updated_at": "0001-01-01T00:00:00Z",
      "identity_document_type": "CPF"
    },
    "shipping_options": null,
    "user_instructions": "",
    "metadata": {
      "origin": "core"
    },
    "status": "pending",
    "payment": {
      "data": {
        "amount": {
          "amount": 13000,
          "currency": "BRL"
        },
        "metadata": {
          "authorization_code": "",
          "external_transaction_id": "afa0a436-6f4a-4583-84c4-430639f5e7d9"
        },
        "from_card": {
          "card_brand": "",
          "first_six": "",
          "last_four": "",
          **"installment": {
            "installments": 1,
            "plan_id": "f90e1c3e-eb23-4706-90aa-8e289a38d382",
            "plan_option_id": "c397a748-eda8-4878-a5b2-953415b51fad",
            "installment_type": "MCI",
            "installment_rate": 0,
            "installment_amount": 0**
          },
          "bank_name": "",
          "country_iso": ""
        },
        "updated_at": "2024-07-16 14:55:17.393166774 +0000 UTC",
        "method_type": "credit",
        "merchant": {
          "store_code": "all",
          "id": "20a5bc23-f349-489b-a183-a3e0f09556a6"
        },
        "created_at": "2024-07-16 14:55:17.392079806 +0000 UTC",
        "id": "adb1ef51-e073-49f5-ba3b-a7e42344fd15",
        "processor": "nupay",
        "customer": {
          "email": "eposada@deuna.com",
          "id": "40c3ec29-8562-41c6-bb47-96ca7c852e01",
          "first_name": "",
          "last_name": ""
        },
        "status": "processing",
        "reason": "",
        "external_transaction_id": "afa0a436-6f4a-4583-84c4-430639f5e7d9",
        "merchant_payment_processor_name": "",
        "authorization_code": "",
        "installment_interest_calculations": null
      }
    },
    "gift_card": [],
    "redirect_url": "",
    "webhook_urls": null,
    "total_discount": 0,
    "display_total_discount": "BRL 0,00",
    "shipping": null,
    "cash_change": 0,
    "shipping_method": null,
    "shipping_methods": [],
    "timezone": "",
    "scheduled_at": "",
    "billing_address": {
      "id": 688,
      "user_id": "",
      "first_name": "Jean",
      "last_name": "Roldan",
      "phone": "+5521988939196",
      "identity_document": "58188896454",
      "lat": -23.555425,
      "lng": -46.677048,
      "address1": "Rua Capote Valente",
      "address2": "Pinheiros",
      "city": "São Paulo",
      "zipcode": "05409-002",
      "state_name": "SP",
      "country_code": "BRA",
      "additional_description": "",
      "address_type": "home",
      "is_default": false,
      "created_at": "0001-01-01T00:00:00Z",
      "updated_at": "0001-01-01T00:00:00Z",
      "email": "jroldan@deuna.com",
      "identity_document_type": "CPF"
    },
    "payment_link": "",
    "display_shipping_tax_amount": "BRL 0,00",
    "display_total_tax_amount": "BRL 0,00",
    "shipping_tax_amount": 0,
    "total_tax_amount": 0,
    "user_id": "",
    "include_payment_options": [],
    "redirect_urls": {
      "success": "",
      "pending": "",
      "error": "",
      "fallback": "",
      "close": ""
    },
    "created_at": "",
    "updated_at": "",
    "payer_info": null,
    "discount_amount": 0,
    "shipping_discount_amount": 0,
    "device_fingerprint": "",
    "expired_at": "",
    "version": "0",
    "fraud": {
      "analysis": {
        "score": 0.0405804,
        "processor": "SIFT",
        "risk_level": "",
        "status": "automatic_decision",
        "type": "",
        "fraud_decision": "",
        "details": "",
        "processor_response": ""
      }
    },
    "display_total_interest_amount": "",
    "payment_method": "",
    "token": "",
    "statement_descriptor": ""
  }
}

Rimborsi

Per i rimborsi, utilizzare il V2 Rimborso endpoint.

NuPay torna sempre refunding stato e supporta più rimborsi parziali.

Ascolta i webhooks di DEUNA per ricevere notifica dello stato finale di un rimborso.

Richiesta

JSON
{
    "reason": "refund requested",
    "amount": 13000 //Here the amount can be total or partial. If you don't send this parameter, then the refund will be total.
}

Restituisce l’ordine elaborato con

JSON
{
  "data": {
    "refund_id": "58635dc5-a968-4da2-bb71-617f74bb3723",
    "status": "refunding",
    "refund_amount": {
      "amount": "13000",
      "currency": "BRL"
    },
    "order": null,
    "refunds": [ // lists all the refunds associated to the same order
      {
        "refund_id": "58635dc5-a968-4da2-bb71-617f74bb3723",
        "refund_amount": {
          "amount": "13000",
          "currency": "BRL"
        },
        "refunded_on": "2024-07-16T14:58:30Z",
        "status": "refunding",
        "external_transaction_id": "3dbd1cce-85b8-4c8c-b745-b894825e9866"
      }
    ]
  },
  "error": null
}

Test di Sandbox

È possibile utilizzare i dati forniti nelle tabelle seguenti per testare NuPay nel vostro ambiente sandbox.

Documenti o CPF per la prova:

Numero CPFDescrizione
58188896454Autorizzazione accettata dal cliente per qualsiasi tipo di carica.
31457612500Autorizzazione negata dal cliente.

Risposte di installazione simulanti:

Gamma di assemblaggioScenario della simulazione
Importo tra R$ 0.01 e R$ 100.00Debito
Importo tra R$ 101.00 e R$ 200.00Credito
Importo tra R$ 201.00 e R$ 500.00Credito con interesse
Importo con qualsiasi importo superiore R$501.00Ritiro, credito e credito con interesse. Un massimo di 3 raccordi sono mostrati nel corpo di risposta.

Codici di errore

Utilizzare le informazioni fornite nelle tabelle seguenti per confermare la vostra integrazione se qualcosa è andato storto durante qualsiasi passo.

consenso del cliente:

CodiceMessaggioStato HTTPAzioneMessaggioMotivazione
DP-4024Invalid merchant ID400Contatto Supporto DEUNAfallitoCredential mismatch, verifica le credenziali.
DP-3000Carico di pagamento non valido400RetribuzionifallitoVerificare il carico utile fornito per la richiesta di consenso.
DP-5002Errore interno500Contatto Supporto DEUNAfallitoErrore DEUNA interno.
DP-4025Creazione di un consenso fallito400RetribuzionifallitoVerifica la configurazione del processore nel portale amministrativo DEUNAs.

Ottieni metodi di pagamento

CodiceMessaggioProssima azione
DP-20001Non riuscito ottenere l'autorizzazioneVerificare l'organismo di richiesta e riprovare la richiesta.
DP-20002Non è riuscito a get TokenVerificare l'organismo di richiesta e riprovare la richiesta.
DP-20003Non è possibile ottenere condizioni di pagamentoVerificare l'organismo di richiesta e riprovare la richiesta.

Acquisti

CodiceMessaggioMotivazione
DP-4026SYSTEM_ERRORIl sistema non può elaborare questo pagamento ora. Ti prego, riprova più tardi.
DP-4026CANCELLED_BY_USERL'utente ha annullato il pagamento.
DP-4026CANCELLED_BY_TIMEOUTQuesto pagamento è stato annullato a causa di timeout.
DP-4026CANCELLED_BY_INSTITUTIONL'istituzione ha annullato il pagamento.
DP-4026CANCELLED_BY_SELLERIl venditore ha annullato il pagamento.

In questa sezione