Skip to content

rnopal/xendit-ruby

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xendit API Ruby Library

This library is the abstraction of Xendit API for access from applications written with Ruby/Rails.

API Documentation

Please check Xendit API Reference.

Requirements

  • Ruby 2.5+.

Installation

Add this line to your application’s Gemfile:

gem 'xendit'

And then execute:

$ bundle

Access the library in Ruby/Rails project:

require 'xendit'

Usage

First, start by setting up with your account's secret key obtained from your Xendit Dashboard. Once done, you are ready to use all services provided in this library.

require 'xendit'

# Provide api key
Xendit.api_key = 'xnd_...'

Invoice Service

Refer to Xendit API Reference for more info about methods' parameters

Create an invoice

# setup invoice details
invoice_params = {
    external_id: 'demo_147580196270',
    payer_email: 'sample_email@xendit.co',
    description: 'Trip to Bali',
    amount: 10_000_000
}
# create an invoice
created_invoice = Xendit::Invoice.create invoice_params

Get an invoice

# get an invoice
invoice = Xendit::Invoice.get '5efda8a20425db620ec35f43'

Get all invoices

# setup filters
filter_params = {
    limit: 3
}
# get invoices
invoices = Xendit::Invoice.get_all filter_params

Expire an invoice

# expire an invoice
expired_invoice = Xendit::Invoice.expire '5efda8a20425db620ec35f43'

Refund Service

Refer to Xendit API Reference for more info about methods' parameters

Create an refunds

 # create refund transaction
  refund_params = {
    invoice_id: '63652c5aeb10cf6e95053d1a',
    reference_id: 'Hello Refunds',
    reason: 'CANCELLATION',
    currency: 'PHP',
    amount: 10_000,
  }
  created_refund = Xendit::Refund.create refund_params
  puts created_refund

Get an Refund ID

# get an invoice
invoice = Xendit::Refund.get created_refund['id']

Balance Service

Refer to Xendit API Reference for more info about methods' parameters

Get Balance Service

# Check your current balance
  balance = Xendit::Balance.get_balance

  puts "\nBalance::"
  puts balance

About

Ruby REST Client for Xendit API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%