NuPay
NuPayを使い始める#
このページでは、NuPayをDEUNAに統合するための手順を詳しく説明します。
NuPayはNubankが提供する高度なプラットフォームです。オンライン決済と金融取引を簡素化し、安全で信頼性の高い決済処理を実現します。
要件#
以下に、統合を正常に完了するためのすべての要件を示します。
NuPay のサンドボックスおよび本番環境の認証情報は、直接 NuBank のアカウントマネージャーから取得する必要があります。
環境で使用:
- サンドボックス: https://api.sandbox.deuna.io
- 本番環境: https://api.deuna.io
Postman 集合:
統合手順#
技術要件が設定されたら、統合を開始できます。
1. 次の操作を実行してください。 order_token
購入を行うには、DEUNA の注文を作成する必要があります。
V2の「Purchase」エンドポイントへのリクエストを送信してください。 注文の作成 endpoint.
API は、 order_token フロー全体で使用されます。
要求
{
"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
}**
}
}応答
{
"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. 注文情報の取得
V2の「Purchase」エンドポイントへのリクエストを送信してください。 Get Order endpoint.
このトークンを、次の手順で使用してください。
応答
{
"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": []
}3. 顧客の同意の取得
アカウントで支払いを行う際に、顧客の同意状況を確認します。
ステータスの確認には、ステータスが変更されるまでポーリングを行います。
同意状態:
-
pending -
success -
failed
応答
{
"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
}
}現在のステータスを確認するには、以下の手順に従ってください。
- 新しいステータスを確認するために、GETリクエストを実行します。
- ウェブフックを通じてステータス更新を受信します。
4. 同意状況の取得
DEUNA は、webhook イベントを通じてステータス更新を送信します。
以下のフィールドが有効であることを確認してください。 status 現在、以下の値を含みます “success”.
顧客がアカウントで支払いを行う際に、支払いの承認を同時に取得します。
要求
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}}'const response = await fetch("{{base_url}}/merchants/orders/{{order_token}}/consent", {
method: "GET",
headers: {
"X-API-KEY": "{{merchant_private_key}}",
"Content-Type": "application/json",
"X-Request-Id": "xxxxx",
"Authorization": "{{user_token}}"
}
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();import requests
response = requests.request(
"GET",
"{{base_url}}/merchants/orders/{{order_token}}/consent",
headers={
"X-API-KEY": "{{merchant_private_key}}",
"Content-Type": "application/json",
"X-Request-Id": "xxxxx",
"Authorization": "{{user_token}}"
},
)
response.raise_for_status()
data = response.json()<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "{{base_url}}/merchants/orders/{{order_token}}/consent",
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-API-KEY: {{merchant_private_key}}",
"Content-Type: application/json",
"X-Request-Id: xxxxx",
"Authorization: {{user_token}}"
]
]);
$response = curl_exec($curl);
curl_close($curl);import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{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}}")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(
request, HttpResponse.BodyHandlers.ofString()
);
System.out.println(response.body());
}
}package main
import (
"fmt"
"io"
"net/http"
)
func main() {
request, err := http.NewRequest("GET", "{{base_url}}/merchants/orders/{{order_token}}/consent", nil)
if err != nil { panic(err) }
request.Header.Set("X-API-KEY", "{{merchant_private_key}}")
request.Header.Set("Content-Type", "application/json")
request.Header.Set("X-Request-Id", "xxxxx")
request.Header.Set("Authorization", "{{user_token}}")
response, err := http.DefaultClient.Do(request)
if err != nil { panic(err) }
defer response.Body.Close()
body, _ := io.ReadAll(response.Body)
fmt.Println(string(body))
}応答
{
"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. 支払い方法の取得
支払い方法を確認し、NuPayの設定を取得します。
V2の「Purchase」エンドポイントへのリクエストを送信してください。 支払い方法の取得 endpoint.
レスポンスには以下の情報が含まれます:
- 購入可能な支払い方法。
- 顧客が利用できる分割回数。
以下のレスポンスが正しい: method_type" (例)
"nupay_credit""nupay_debit""nupay_credit_with_additional_limit"
応答
{
"@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. 購入を実行する
V2の「Purchase」エンドポイントへのリクエストを送信してください。 Purchase V2 エンドポイントとプロセスを実行します。
応答
{
"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"
}テストと統合データ#
このセクションには、NuPayとの成功的な統合のためのテストデータとレスポンス情報が記載されています。
支払い分割
分割オブジェクトには、以下の情報が必要です。 plan_option_id 属性。1回の決済の場合、 1 installment.
要求
{
"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.
}
}
}応答
{
"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": ""
}
}払い戻し
返金については、V2 Refundを使用してください。 V2 Refund endpoint.
NuPayは常に refunding ステータスは、複数の部分的な返金をサポートします。
DEUNAのウェブフックを監視することで、返金の最終ステータスを通知を受け取ることができます。
要求
{
"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.
}応答
{
"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
}サンドボックスでのテスト
NuPayを、以下の表に記載されたデータを使用して、サンドボックス環境でテストできます。
テスト用のドキュメントまたはCPF:
| CPF番号 | 説明 |
|---|---|
| 58188896454 | 顧客による、あらゆる種類の取引に対する承認。 |
| 31457612500 | 顧客による取引拒否。 |
分割払い応答のシミュレーション:
| 金額範囲 | シミュレーションシナリオ |
|---|---|
| 金額:R$ 0.01 ~ R$ 100.00 | デビット |
| 101.00~200.00レアル | クレジット |
| 201.00~500.00レアル | 利息付きクレジット |
| 501.00レアル以上の金額 | デビット、クレジット、利息付きクレジット。レスポンスボディには、最大3回の分割が示されます。 |
エラーコード
統合の検証に、以下の表の情報を使用してください。もし、手順のいずれかで問題が発生した場合。
顧客の同意:
| コード | メッセージ | HTTP ステータス | アクション | メッセージ | 理由 |
|---|---|---|---|---|---|
| DP-4024 | Invalid merchant ID | 400 | DEUNA サポートにお問い合わせください | 失敗 | 認証情報が一致しません。認証情報を確認してください。 |
| DP-3000 | 無効なペイロード | 400 | 再試行 | 失敗 | 同意リクエストの提供されたペイロードを確認してください。 |
| DP-5002 | 内部エラー | 500 | DEUNA サポートにお問い合わせください | 失敗 | 内部 DEUNA エラー。 |
| DP-4025 | 同意の作成に失敗 | 400 | 再試行 | 失敗 | DEUNA の管理ポータルで、プロセッサの設定を確認してください。 |
支払い方法を取得
| コード | メッセージ | 次のアクション |
|---|---|---|
| DP-20001 | 認証の取得に失敗 | リクエスト本文を確認し、リクエストを再試行してください。 |
| DP-20002 | トークン取得に失敗 | リクエスト本文を確認し、リクエストを再試行してください。 |
| DP-20003 | 支払い条件の取得に失敗 | リクエスト本文を確認し、リクエストを再試行してください。 |
購入
| コード | メッセージ | 理由 |
|---|---|---|
| DP-4026 | SYSTEM_ERROR | 現在、システムではこの支払いを処理できません。後で再度お試しください。 |
| DP-4026 | CANCELLED_BY_USER | ユーザーが支払いをキャンセルしました。 |
| DP-4026 | CANCELLED_BY_TIMEOUT | Este pago fue cancelado debido a un tiempo de espera. |
| DP-4026 | CANCELLED_BY_INSTITUTION | 機関が支払いをキャンセルしました。 |
| DP-4026 | CANCELLED_BY_SELLER | 販売者がこの支払いをキャンセルしました。 |