返金を行う
Smartpayはマーチャントパートナーであるお客様の指示に従い、返金処理を行います。返金のリクエストは、Smartpayのダッシュボードまたは返金APIコールで行うことができます。
Smartpay のダッシュボードで
1. 返金を希望する注文を探す
Smartpay のダッシュボードにログインすると、お客様の注文の一覧が表示されます。「注文 ID」、「お客様名」、「お客様 E メールアドレス」で特定の注文を検索することができます。
該当する注文が見つかったら、それをクリックすると注文の詳細ページが表示されます。
2. 返金を行う
注文の詳細ページで「返金する」をクリックします。
返金したい金額と、オプションの説明をフォームに記入します。「返金する」をクリックします。
Smartpay API の使用
1. 返金を希望する注文を取得する
返金したい注文の注文 ID を使用して、Smartpay API を使用して注文オブジェクトを取得します。
curl --request GET \
--url 'https://api.smartpay.co/v1/orders/order_test_bA1znhGULw5lROfDTpHChv?expand=no' \
--header 'Accept: application/json' \
--header 'Authorization: Basic {secretKey}'
返されたオブジェクトには、注文に対して作成された支払 ID を持つpayments
フィールドがあります。返金を行うには、このpaymentId
を取得する必要があります。
{
"id": "order_test_bA1znhGULw5lROfDTpHChv",
"object": "order",
"amount": 2100,
"createdAt": 1644978270631,
"currency": "JPY",
"discounts": [],
"expiresAt": 1645583167495,
"lineItems": [
"li_test_Lj1ofPS7HabmT3i0XsyB4V"
],
"metadata": {},
"payments": [
"payment_test_GDEATBKK8XAp9XGf6J4U4"
],
"shippingInfo": {
...
},
"status": "succeeded",
"test": true,
"updatedAt": 1644978437889
}
2. 返金を行う
注文のpaymentId
を使用して、Smartpay API を使用して返金を作成します。
引数の詳細については、返金用API エンドポイント作成 をご覧ください。
以下の項目は必須です。
- amount: この支払額のうちいくら払い戻すかを示す正の値です。払い戻しできるのは、払い戻しできない残りの金額までです。
- currency: 3 文字の ISO 通貨コード、大文字。対応している通貨である必要があります。
- payment: Payment オブジェクトの一意な識別子です。
- reason: 返金の理由(
requested_by_customer
またはfraudulent
)
curl --request POST \
--url https://api.smartpay.co/v1/refunds \
--header 'Accept: application/json' \
--header 'Authorization: Basic {secretKey}' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 1000,
"currency": "JPY",
"description": "Customer return",
"lineItems": [],
"payment": "payment_test_GDEATBKK8XAp9XGf6J4U4",
"reason": "requested_by_customer",
"reference": "my_merchant_refund_reference"
}
'
$api = new \Smartpay\Api(getenv('SECRET_KEY'), getenv('PUBLIC_KEY'));
$payment = $api->createRefund([
'amount' => 1500,
'currency' => 'JPY',
'description' => 'Description for my Smartpay refund',
'lineItems' => [],
'payment' => 'payment_test_GDEATBKK8XAp9XGf6J4U4',
'reason' => 'requested_by_customer',
'reference' => 'my_merchant_refund_reference'
]);
Smartpay.configure do |config|
config.public_key = ENV['PUBLIC_KEY']
config.secret_key = ENV['SECRET_KEY']
end
payment = Smartpay::Api.create_refund({
amount: 1500,
currency: 'JPY',
description: 'Description for my Smartpay refund',
lineItems: [],
payment: 'payment_test_GDEATBKK8XAp9XGf6J4U4',
reason: 'requested_by_customer',
reference: 'my_merchant_refund_reference',
})
SECRET_KEY = os.environ.get('SECRET_KEY', '<YOUR_SECRET_KEY>')
PUBLIC_KEY = os.environ.get('PUBLIC_KEY', '<YOUR_PUBLIC_KEY>')
smartpay = Smartpay(SECRET_KEY, public_key=PUBLIC_KEY)
payment = smartpay.create_refund(
payment="payment_test_GDEATBKK8XAp9XGf6J4U4",
amount=1500,
currency="JPY",
reference="my_merchant_refund_reference",
reason="requested_by_customer",
description="Description for my Smartpay refund"
):
Updated about 1 month ago