Module: Veritrans::Api
- Included in:
- Veritrans
- Defined in:
- lib/veritrans/api.rb
Instance Method Summary collapse
-
#approve(payment_id, options = {}) ⇒ Object
POST /v2/id/approve Docs docs.veritrans.co.id/sandbox/other_commands.html.
-
#cancel(payment_id, options = {}) ⇒ Object
POST /v2/id/cancel Docs docs.veritrans.co.id/sandbox/other_commands.html.
-
#capture(payment_id, gross_amount, options = {}) ⇒ Object
POST /v2/capture Docs docs.veritrans.co.id/sandbox/other_features.html.
-
#charge(payment_type, data = nil) ⇒ Object
POST /v2/charge { payment_type: “vtlink” } Docs docs.veritrans.co.id/vtdirect/integration_cc.html#step2 Docs docs.veritrans.co.id/sandbox/charge.html.
-
#create_vtlink(data) ⇒ Object
POST /v2/charge { payment_type: “vtlink” }.
-
#delete_vtlink(id, options) ⇒ Object
DELETE /v2/vtlink/id.
-
#status(payment_id) ⇒ Object
GET /v2/id/status Docs docs.veritrans.co.id/sandbox/other_commands.html.
Instance Method Details
#approve(payment_id, options = {}) ⇒ Object
POST /v2/id/approve Docs docs.veritrans.co.id/sandbox/other_commands.html
57 58 59 |
# File 'lib/veritrans/api.rb', line 57 def approve(payment_id, = {}) request_with_logging(:post, config.api_host + "/v2/#{URI.escape(payment_id)}/approve", ) end |
#cancel(payment_id, options = {}) ⇒ Object
POST /v2/id/cancel Docs docs.veritrans.co.id/sandbox/other_commands.html
51 52 53 |
# File 'lib/veritrans/api.rb', line 51 def cancel(payment_id, = {}) request_with_logging(:post, config.api_host + "/v2/#{URI.escape(payment_id)}/cancel", ) end |
#capture(payment_id, gross_amount, options = {}) ⇒ Object
POST /v2/capture Docs docs.veritrans.co.id/sandbox/other_features.html
73 74 75 |
# File 'lib/veritrans/api.rb', line 73 def capture(payment_id, gross_amount, = {}) post(config.api_host + "/v2/capture", .merge(transaction_id: payment_id, gross_amount: gross_amount)) end |
#charge(payment_type, data = nil) ⇒ Object
POST /v2/charge { payment_type: “vtlink” } Docs docs.veritrans.co.id/vtdirect/integration_cc.html#step2 Docs docs.veritrans.co.id/sandbox/charge.html
Example: Veritrans.charge(
payment_type: "credit_card",
credit_card: { token_id: "<token from client>" },
transaction_details: {
order_id: "order_123",
gross_amount: 100_000
}
)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/veritrans/api.rb', line 21 def charge(payment_type, data = nil) if payment_type.kind_of?(Hash) && data.nil? data = payment_type payment_type = nil end data = data.deep_symbolize_keys if data.respond_to?(:deep_symbolize_keys) data[:payment_type] = payment_type if payment_type if data.has_key?(:payment_options) data[ payment_type.to_sym ] = data.delete(:payment_options) end # Rename keys: # payment -> transaction_details # transaction -> transaction_details # items -> item_details # customer -> customer_details data[:transaction_details] = data.delete(:payment) if data[:payment] data[:transaction_details] = data.delete(:transaction) if data[:transaction] data[:item_details] = data.delete(:items) if data[:items] data[:customer_details] = data.delete(:customer) if data[:customer] request_with_logging(:post, config.api_host + "/v2/charge", data) end |
#create_vtlink(data) ⇒ Object
POST /v2/charge { payment_type: “vtlink” }
78 79 80 81 82 |
# File 'lib/veritrans/api.rb', line 78 def create_vtlink(data) data = data.dup data[:payment_type] = "vtlink" request_with_logging(:post, config.api_host + "/v2/charge", data) end |
#delete_vtlink(id, options) ⇒ Object
DELETE /v2/vtlink/id
85 86 87 |
# File 'lib/veritrans/api.rb', line 85 def delete_vtlink(id, ) request_with_logging(:delete, config.api_host + "/v2/vtlink/#{URI.escape(id)}", ) end |
#status(payment_id) ⇒ Object
GET /v2/id/status Docs docs.veritrans.co.id/sandbox/other_commands.html
63 64 65 66 67 68 69 |
# File 'lib/veritrans/api.rb', line 63 def status(payment_id) if !payment_id || payment_id == "" raise ArgumentError, "parameter payment_id can not be bank" end get(config.api_host + "/v2/#{URI.escape(payment_id)}/status") end |