POST /api/v1/payments/:id/refund
Refund Payments

Refunds an arbitrary amount of money from an existing payment. If no amount is specified, the whole payment is refunded. When the payment has been fully refunded KOMOJU will send payment.refunded webhook.

For cash-based payment methods, Japanese customers must be redirected to redirect_url on the refund object to complete their refund. Upon navigating to redirect_url customers can select a convenience store where they can receive a receipt code for a cash refund. KOMOJU will send payment.refunded webhook once the customer has received their refund.

サンプル

  • cURL
  • Node.js
  • Ruby
curl -X POST https://komoju.com/api/v1/payments/b63kr222rtkvn3z6hhw7i4j3x/refund \
  -u sk_123456: \
  -d "amount=500" 
var querystring = require('querystring');
var https = require('https');
var secret_key = 'sk_123456'
var auth = 'Basic ' + Buffer.from(secret_key + ':').toString('base64');
var post_data = querystring.stringify({
  'amount': '500'
});

var post_options = {
  host: 'komoju.com',
  port: '443',
  path: '/api/v1/payments/b63kr222rtkvn3z6hhw7i4j3x/refund',
  method: 'POST',
  headers: {
    'Authorization': auth,
    'Content-Length': Buffer.byteLength(post_data)
  }
};

var post_req = https.request(post_options, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
        console.log(chunk);
    });
});

post_req.write(post_data);
post_req.end();
require 'uri'
require 'net/https'
require 'json'
require 'base64'
require 'pp'
uri = URI.parse('https://komoju.com/api/v1/payments/b63kr222rtkvn3z6hhw7i4j3x/refund')
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
secret_key = 'sk_123456'
auth = Base64.encode64("#{secret_key}:")
headers = {
  'Content-Type' => 'application/json',
  'Authorization' => "Basic #{auth}"
}

body = {
  amount: "500"
}

res = https.post(
  uri.path,
  body.to_json,
  headers
)

puts res.body
{
  "id": "b63kr222rtkvn3z6hhw7i4j3x",
  "resource": "payment",
  "status": "captured",
  "amount": 1000,
  "tax": 100,
  "customer": null,
  "payment_deadline": "2020-06-16T14:59:59Z",
  "payment_details": {
    "type": "credit_card",
    "email": "test@example.com",
    "brand": "visa",
    "last_four_digits": "1111",
    "month": 1,
    "year": 2025
  },
  "payment_method_fee": 0,
  "total": 1100,
  "currency": "JPY",
  "description": null,
  "captured_at": "2020-06-09T07:42:20Z",
  "external_order_num": null,
  "metadata": {
  },
  "created_at": "2020-06-09T07:42:19Z",
  "amount_refunded": 500,
  "locale": "ja",
  "refunds": [
    {
      "id": "3iytpjriy703rjjd50jco87nm",
      "resource": "refund",
      "status": "completed",
      "redirect_url": null,
      "amount": 500,
      "currency": "JPY",
      "payment": "b63kr222rtkvn3z6hhw7i4j3x",
      "description": null,
      "created_at": "2020-06-09T07:42:20Z",
      "chargeback": false
    }
  ],
  "refund_requests": [

  ]
}

パラメータ

名前 説明
amount
任意

The amount to be charged before tax. Must be equal or greater than 0. Use a ‘.’ as a decimal separator, and no thousands separator.

description
任意

Plaintext description for annotating a resource.

name
任意

The name of the customer.

email
任意

The e-mail address of the customer.

phone
任意

The phone number of the customer.