Class: Veritrans::VTDirect
- Inherits:
-
Object
- Object
- Veritrans::VTDirect
- Includes:
- Config
- Defined in:
- lib/veritrans/v_t_direct.rb
Overview
:nodoc:
Constant Summary collapse
- @@attr =
[:token_id, :order_id, :order_items, :gross_amount, :email, :shipping_address, :billing_address]
Constants included from Config
Config::CARD_CAPTURE_FLAG, Config::CHARGES_URL, Config::CUSTOMER_SPECIFICATION_FLAG, Config::PAYMENT_REDIRECT_URL, Config::REQUEST_KEY_URL, Config::SERVER_HOST, Config::SETTLEMENT_TYPE_CARD, Config::TOKENS_URL, Config::VOID_URL
Instance Method Summary collapse
-
#charges ⇒ Object
Example:.
-
#charges_url ⇒ Object
:nodoc:.
-
#initialize ⇒ VTDirect
constructor
constructor to create instance of Veritrans::Client.
-
#server_host ⇒ Object
:nodoc:.
-
#server_key ⇒ Object
:nodoc:.
-
#server_key=(new_server_key) ⇒ Object
:nodoc:.
-
#tokens_url ⇒ Object
:nodoc:.
- #void ⇒ Object
-
#void_url ⇒ Object
:nodoc:.
Methods included from Config
Constructor Details
#initialize ⇒ VTDirect
constructor to create instance of Veritrans::Client
12 13 14 15 16 17 18 |
# File 'lib/veritrans/v_t_direct.rb', line 12 def initialize class <<self self end.class_eval do attr_accessor *@@attr end end |
Instance Method Details
#charges ⇒ Object
Example:
vt_direct = Veritrans::VTDirect.new
vt_direct.token_id = "32eeeb9f-8ac3-b824-eb6d-faaa25240d27"
vt_direct.order_id = "order_5"
vt_direct.order_items = [
{
id: "10",
price: 100,
qty: 1,
name1: "Mie",
name2: "Goreng"
},
{
id: "11",
price: 100,
qty: 1,
name1: "Mie",
name2: "Kuah"
}
]
vt_direct.gross_amount = 200
vt_direct.email = "[email protected]"
vt_direct.shipping_address = {
first_name: "Sam",
last_name: "Anthony",
address1: "Buaran I",
address2: "Pulogadung",
city: "Jakarta",
country_code: "IDN",
postal_code: "16954",
phone: "0123456789123"
}
vt_direct.billing_address = {
first_name: "Sam",
last_name: "Anthony",
address1: "Buaran I",
address2: "Pulogadung",
city: "Jakarta",
country_code: "IDN",
postal_code: "16954",
phone: "0123456789123"
}
vt_direct.charges
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/veritrans/v_t_direct.rb', line 65 def charges parms = prepare_params(@@attr).to_json basic = Base64.encode64("#{server_key}:") copt = {:url => server_host} copt[:ssl] = { :ca_path => VTDirect.config["ca_path"] } if VTDirect.config["ca_path"] #"/usr/lib/ssl/certs" conn = Faraday.new( copt ) @resp = conn.post do |req| req.url(charges_url) req.headers['Content-Type'] = 'application/json' req.headers['Authorization'] = "Basic #{basic}" req.body = parms end.env @data = @resp[:body] end |
#charges_url ⇒ Object
:nodoc:
100 101 102 |
# File 'lib/veritrans/v_t_direct.rb', line 100 def charges_url return Client.config["charges_url"] ? Client.config["charges_url"] : Config::CHARGES_URL end |
#server_host ⇒ Object
:nodoc:
90 91 92 |
# File 'lib/veritrans/v_t_direct.rb', line 90 def server_host return VTDirect.config["server_host"] ? VTDirect.config["server_host"] : Config::SERVER_HOST end |
#server_key ⇒ Object
:nodoc:
110 111 112 |
# File 'lib/veritrans/v_t_direct.rb', line 110 def server_key return VTDirect.config["server_key"] end |
#server_key=(new_server_key) ⇒ Object
:nodoc:
115 116 117 |
# File 'lib/veritrans/v_t_direct.rb', line 115 def server_key= new_server_key VTDirect.config["server_key"] = new_server_key end |
#tokens_url ⇒ Object
:nodoc:
95 96 97 |
# File 'lib/veritrans/v_t_direct.rb', line 95 def tokens_url return Client.config["tokens_url"] ? Client.config["tokens_url"] : Config::TOKENS_URL end |
#void ⇒ Object
80 81 82 |
# File 'lib/veritrans/v_t_direct.rb', line 80 def void api_call(void_url) end |