README.md in veritrans-2.0.0 vs README.md in veritrans-2.0.2
- old
+ new
@@ -1,14 +1,13 @@
# Veritrans ruby library
-## Installation
+[![Gem Version](https://badge.fury.io/rb/veritrans.svg)](http://badge.fury.io/rb/veritrans)
+[![Build Status](https://travis-ci.org/veritrans/veritrans-ruby.svg?branch=master)](https://travis-ci.org/veritrans/veritrans-ruby)
- $ gem install veritrans
-
## How to use (Rails)
-### Add veritrans to Gemfile
+### Add gem veritrans to Gemfile
```ruby
gem 'veritrans'
```
@@ -67,10 +66,11 @@
Veritrans.client_key = "<%= Veritrans.config.client_key %>";
</script>
```
Payment form:
+
```html
<form action="/charge_vtdirect" method="post" id="card_form">
<input type="hidden" name="token_id" id="card_token">
<input type="hidden" id="gross_amount" value="30000">
<p>
@@ -175,23 +175,26 @@
For every transaction success and failed we will send you HTTP POST notification (aka webhook)
First you should set callback url in our dashboard https://my.sandbox.veritrans.co.id/settings/vtweb_configuration
-In development mode please read our [Testing webhooks tutorial](https://github.com/Paxa/veritrans-ruby/blob/new_api/testing_webhooks.md)
+For testing in development phase please read our [Testing webhooks tutorial](https://github.com/Paxa/veritrans-ruby/blob/new_api/testing_webhooks.md) and [command line tool](#command-line-tool)
For rails:
```ruby
# config/routes.rb
match "/payments/receive_webhook" => "payments#receive_webhook", via: [:post]
# app/controllers/payments_controller.rb
def receive_webhook
- verified_data = Veritrans.status(params[:transaction_id])
+ post_body = request.body.read
+ callback_params = Veritrans.decode_notification_json(post_body)
+ verified_data = Veritrans.status(callback_params['transaction_id'])
+
if verified_data.status_code != 404
puts "--- Transaction callback ---"
puts "Payment: #{verified_data.data[:order_id]}"
puts "Payment type: #{verified_data.data[:payment_type]}"
puts "Payment status: #{verified_data.data[:transaction_status]}"
@@ -204,10 +207,12 @@
render text: "ok", :status => :not_found
end
end
```
+----
+
#### Veritrans::Events
Other option to handle callbacks is our rack-based handler
```ruby
@@ -229,24 +234,40 @@
end
```
#### Logging
-By default gem veritrans will show information via rails' logger. And in addition save important information to `RAILS_APP/config/veritrans.log`
+By default gem veritrans will show information via rails' logger. And in addition save important information to `RAILS_APP/log/veritrans.log`
It's configurable.
```ruby
-Veritrans.logger = Logger.new("/my/logs/veritrans.log")
+Veritrans.logger = Rails.logger
Veritrans.file_logger = Logger.new("/my/important_logs/veritrans.log")
```
`Veritrans.file_logger` save information about:
* "charge", "cancel", "approve" api calls
* Validation errors for "charge", "cancel", "approve"
* Received http notifications
* Errors and exception while processing http notifications
+
+----
+
+#### Command line tool
+
+**Installation**
+
+ $ gem install veritrans
+
+**Usage**
+
+Testing http notification:
+
+ $ veritrans testhook http://localhost:3000/vt_events
+ $ veritrans testhook -o my-order-1 -c ~/path/to/veritrans.yml http://localhost:3000/vt_events
+
#### Get help
* [Veritrans gem reference](https://github.com/Paxa/veritrans-ruby/blob/new_api/api_reference.md)