Create a Refund
Create a refund for an existing Transaction in the system that is refundable.
Accepts a RefundRequest object.
Returns a RefundResponse object.
require 'uri'
require 'net/http'
url = URI("https://api.opentransact.com/v1/refunds")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["authorization"] = "Bearer #{API_KEY}"
request["content-type"] = 'application/vnd.api+json'
request.body = {
"data": {
"type": "refunds",
"attributes": {
"amount": 100,
"memo": "Test Transaction Refund",
},
"relationships": {
"transaction": {
"data": {
"id": transaction_id,
"type": "transactions"
}
}
}
}
}.to_json
response = http.request(request)
puts response.read_body
curl --request POST \
--url https://api.opentransact.com/v1/refunds \
--header 'authorization: Bearer $API_KEY' \
--header 'content-type: application/vnd.api+json' \
--data '{
"data": {
"type": "refunds",
"attributes": {
"amount": 100,
"memo": "Test Transaction Refund"
},
"relationships": {
"transaction": {
"data": {
"id": transaction_id,
"type": "transactions"
}
}
}
}
}'