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, you must use the 'refund request' endpoint to schedule a bank transfer into the customer's account.

샘플

  • cURL
  • Node.js
  • Ruby
curl -X POST https://komoju.com/api/v1/payments/7mom8rbw56emtroziokdt9q2i/refund \
  -u sk_123456: \
  -d "amount=1000" 
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': '1000'
});

var post_options = {
  host: 'komoju.com',
  port: '443',
  path: '/api/v1/payments/7mom8rbw56emtroziokdt9q2i/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/7mom8rbw56emtroziokdt9q2i/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: "1000"
}

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

puts res.body
{
  "id": "7mom8rbw56emtroziokdt9q2i",
  "resource": "payment",
  "status": "refunded",
  "amount": 1000,
  "tax": 0,
  "customer": null,
  "payment_deadline": null,
  "payment_details": {
    "type": "paidy",
    "email": "test@example.com",
    "redirect_url": "https://komoju.com/offsite/new?uuid=4cv3ovhe3hgzkh4wtwaktoqwe"
  },
  "payment_method_fee": 0,
  "total": 1000,
  "currency": "JPY",
  "description": null,
  "captured_at": "2020-06-07T14:59:59Z",
  "external_order_num": "ORDER19",
  "metadata": {
  },
  "created_at": "2020-06-09T07:42:23Z",
  "amount_refunded": 1000,
  "locale": "en",
  "refunds": [
    {
      "id": "0tiab9hqx25hevdpockz35258",
      "resource": "refund",
      "status": "completed",
      "redirect_url": null,
      "amount": 1000,
      "currency": "JPY",
      "payment": "7mom8rbw56emtroziokdt9q2i",
      "description": null,
      "created_at": "2020-06-09T07:42:24Z",
      "chargeback": false
    }
  ],
  "refund_requests": [

  ]
}

파라미터

성명 설명
amount
임의

The amount to be charged before tax. Must be equal or greater than 0, without thousands separator. The amount cannot be a decimal value. For example, for an amount of 10 and currency of EUR, the payment will be 0.10 EUR.

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.