veritrans 1.2.6 → 2.0.0beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +111 -0
- data/README.md +258 -0
- data/Rakefile +7 -0
- data/api_reference.md +219 -0
- data/bin/veritrans +59 -48
- data/example/index.erb +118 -0
- data/example/response.erb +28 -0
- data/example/sinatra.rb +76 -0
- data/example/style.css +45 -0
- data/example/veritrans.yml +12 -0
- data/lib/generators/templates/assets/credit_card_form.js +50 -0
- data/lib/generators/templates/payments_controller.rb +81 -0
- data/lib/generators/templates/veritrans.rb +43 -0
- data/lib/generators/templates/veritrans.yml +13 -0
- data/lib/generators/templates/views/_credit_card_form.erb +42 -0
- data/lib/generators/templates/views/_veritrans_include.erb +10 -0
- data/lib/generators/templates/views/payments/create.erb +15 -0
- data/lib/generators/templates/views/payments/new.erb +6 -0
- data/lib/generators/veritrans/install_generator.rb +32 -0
- data/lib/generators/veritrans/payment_form_generator.rb +45 -0
- data/lib/veritrans/api.rb +90 -0
- data/lib/veritrans/cli.rb +166 -0
- data/lib/veritrans/client.rb +77 -209
- data/lib/veritrans/config.rb +48 -62
- data/lib/veritrans/events.rb +125 -0
- data/lib/veritrans/result.rb +81 -0
- data/lib/veritrans/version.rb +1 -41
- data/lib/veritrans.rb +79 -15
- data/license.txt +202 -0
- data/spec/cli_spec.rb +86 -0
- data/spec/configs/veritrans.yml +7 -0
- data/spec/configs/veritrans_flat.yml +2 -0
- data/spec/fixtures/approve_failed.yml +48 -0
- data/spec/fixtures/cancel_failed.yml +48 -0
- data/spec/fixtures/cancel_success.yml +106 -0
- data/spec/fixtures/capture_failed.yml +48 -0
- data/spec/fixtures/charge.yml +50 -0
- data/spec/fixtures/charge_direct.yml +56 -0
- data/spec/fixtures/charge_vtweb.yml +50 -0
- data/spec/fixtures/cli_test_1111-not-exists.yml +45 -0
- data/spec/fixtures/cli_test_not_exists.yml +45 -0
- data/spec/fixtures/cli_test_real_txn.yml +55 -0
- data/spec/fixtures/cli_test_unauthorized.yml +47 -0
- data/spec/fixtures/events_test_real_txn.yml +55 -0
- data/spec/fixtures/status_fail.yml +46 -0
- data/spec/fixtures/status_success.yml +109 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/veritrans_client_spec.rb +83 -0
- data/spec/veritrans_config_spec.rb +48 -0
- data/spec/veritrans_events_spec.rb +70 -0
- data/spec/veritrans_logger_spec.rb +46 -0
- data/testing_webhooks.md +80 -0
- data/veritrans.gemspec +23 -0
- metadata +82 -31
- data/config/veritrans.yml +0 -24
- data/lib/generators/install_generator.rb +0 -78
- data/lib/generators/templates/app/controllers/vtlink/merchant_controller.rb +0 -7
- data/lib/generators/templates/app/controllers/vtlink/veritrans_controller.rb +0 -112
- data/lib/generators/templates/app/views/layouts/layout_auto_post.html.erb +0 -15
- data/lib/generators/templates/app/views/vtlink/merchant/checkout.html.erb +0 -43
- data/lib/generators/templates/app/views/vtlink/veritrans/cancel.html.erb +0 -2
- data/lib/generators/templates/app/views/vtlink/veritrans/confirm.html.erb +0 -13
- data/lib/generators/templates/app/views/vtlink/veritrans/error.html.erb +0 -2
- data/lib/generators/templates/app/views/vtlink/veritrans/finish.html.erb +0 -2
- data/lib/generators/templates/app/views/vtlink/veritrans/pay.html.erb +0 -2
- data/lib/generators/templates/config/veritrans.yml +0 -13
- data/lib/veritrans/hash_generator.rb +0 -19
- data/lib/veritrans/post_data.rb +0 -163
- data/lib/veritrans/v_t_direct.rb +0 -145
data/lib/veritrans/config.rb
CHANGED
@@ -1,74 +1,60 @@
|
|
1
|
-
require
|
1
|
+
require 'yaml'
|
2
2
|
|
3
|
-
# :nodoc:
|
4
3
|
module Veritrans
|
5
4
|
|
6
|
-
# hold constants configuration define in server merchant
|
7
5
|
module Config
|
6
|
+
extend self
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
SETTLEMENT_TYPE_CARD = "01" #Paymanet Type
|
35
|
-
|
36
|
-
# Flag: Sales and Sales Credit, 0: only 1 credit. If not specified, 0
|
37
|
-
CARD_CAPTURE_FLAG = "1"
|
38
|
-
|
39
|
-
def Config.included(mod)
|
40
|
-
class <<self
|
41
|
-
template = {
|
42
|
-
'merchant_id' => nil,
|
43
|
-
'merchant_hash_key' => nil,
|
44
|
-
'finish_payment_return_url' => nil,
|
45
|
-
'unfinish_payment_return_url' => nil,
|
46
|
-
'error_payment_return_url' => nil,
|
47
|
-
'server_key' => nil,
|
48
|
-
'server_host' => nil,
|
49
|
-
'charges_url' => nil,
|
50
|
-
'token_url' => nil
|
51
|
-
}
|
52
|
-
@@config_env = ::Object.const_defined?(:Rails) ? Rails.env : "development"
|
53
|
-
@@config = File.exists?("./config/veritrans.yml") ? YAML.load_file("./config/veritrans.yml") : {}
|
54
|
-
@@config['development'] = {} if !@@config['development']
|
55
|
-
@@config['production' ] = {} if !@@config['production']
|
56
|
-
@@config['development'] = template.clone.merge(@@config['development'])
|
57
|
-
@@config['production'] = template.clone.merge(@@config['production'])
|
58
|
-
#@@config['production' ].merge!(template)
|
59
|
-
end
|
8
|
+
@api_host = "https://api.sandbox.veritrans.co.id"
|
9
|
+
|
10
|
+
def client_key
|
11
|
+
@client_key
|
12
|
+
end
|
13
|
+
|
14
|
+
def client_key=(value)
|
15
|
+
@client_key = value
|
16
|
+
end
|
17
|
+
|
18
|
+
def server_key
|
19
|
+
@server_key
|
20
|
+
end
|
21
|
+
|
22
|
+
def server_key=(value)
|
23
|
+
@server_key = value
|
24
|
+
end
|
25
|
+
|
26
|
+
def api_host
|
27
|
+
@api_host
|
28
|
+
end
|
29
|
+
|
30
|
+
def api_host=(value)
|
31
|
+
@api_host = value
|
32
|
+
end
|
60
33
|
|
61
|
-
|
34
|
+
def load_config(filename)
|
35
|
+
yml_file, yml_section = filename.to_s.split('#')
|
36
|
+
config_data = YAML.load(File.read(yml_file))
|
62
37
|
|
63
|
-
|
64
|
-
|
38
|
+
if defined?(Rails) && !yml_section
|
39
|
+
yml_section = Rails.env.to_s
|
65
40
|
end
|
66
41
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
42
|
+
apply(yml_section ? config_data[yml_section] : config_data)
|
43
|
+
end
|
44
|
+
|
45
|
+
alias :load_yml :load_config
|
71
46
|
|
47
|
+
def inspect
|
48
|
+
"<Veritrans::Config @api_host=#{@api_host.inspect} @server_key=#{@server_key.inspect} @client_key=#{@client_key.inspect}>"
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def apply(hash)
|
54
|
+
hash.each do |key, value|
|
55
|
+
send(:"#{key}=", value)
|
56
|
+
end
|
72
57
|
end
|
73
58
|
end
|
74
|
-
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# Rack based event notification callback processor
|
2
|
+
#
|
3
|
+
# Usage:
|
4
|
+
#
|
5
|
+
# Rails.application.routes.draw do
|
6
|
+
# ...
|
7
|
+
# mount Veritrans::Events.new => '/vt_events'
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# Veritrans.events.subscribe('payment.success') do |payment|
|
11
|
+
# payment.mark_paid!(payment.masked_card)
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
|
15
|
+
# All possible events:
|
16
|
+
#
|
17
|
+
# * payment.success == ['authorize', 'capture', 'settlement']
|
18
|
+
# * payment.failed == ['deny', 'canel', 'expire']
|
19
|
+
# * payment.challenge # when payment.froud_status == 'challenge'
|
20
|
+
#
|
21
|
+
# * payment.authorize
|
22
|
+
# * payment.capture
|
23
|
+
# * payment.settlement
|
24
|
+
# * payment.deny
|
25
|
+
# * payment.canel
|
26
|
+
# * payment.expire
|
27
|
+
#
|
28
|
+
# * error
|
29
|
+
|
30
|
+
# For sinatra you can use Rack::URLMap
|
31
|
+
#
|
32
|
+
# run Rack::URLMap.new("/" => MyApp.new, "/payment_events" => Veritrans::Events.new)
|
33
|
+
#
|
34
|
+
|
35
|
+
module Veritrans
|
36
|
+
class Events
|
37
|
+
|
38
|
+
# This is rack application
|
39
|
+
def call(env)
|
40
|
+
Veritrans.logger.info "Receive notification callback"
|
41
|
+
|
42
|
+
post_body = env["rack.input"].read
|
43
|
+
env["rack.input"].rewind
|
44
|
+
request_data = Veritrans.decode_notification_json(post_body)
|
45
|
+
|
46
|
+
Veritrans.file_logger.info("Callback for order: " +
|
47
|
+
"#{request_data['order_id']} #{request_data['transaction_status']}\n" +
|
48
|
+
post_body + "\n"
|
49
|
+
)
|
50
|
+
|
51
|
+
verified_data = Veritrans.status(request_data['transaction_id'])
|
52
|
+
|
53
|
+
if verified_data.status_code != 404
|
54
|
+
#puts "--- Transaction callback ---"
|
55
|
+
#puts "Payment: #{verified_data.data[:order_id]}"
|
56
|
+
#puts "Payment type: #{verified_data.data[:payment_type]}"
|
57
|
+
#puts "Payment status: #{verified_data.data[:transaction_status]}"
|
58
|
+
#puts "Fraud status: #{verified_data.data[:fraud_status]}" if verified_data.data[:fraud_status]
|
59
|
+
#puts "Payment amount: #{verified_data.data[:gross_amount]}"
|
60
|
+
#puts "--- Transaction callback ---"
|
61
|
+
|
62
|
+
event_name = verified_data.data[:transaction_status]
|
63
|
+
if verified_data.data[:fraud_status] == 'challenge'
|
64
|
+
event_name = 'challenge'
|
65
|
+
end
|
66
|
+
|
67
|
+
Veritrans::Events.dispatch("payment.#{event_name}", verified_data)
|
68
|
+
|
69
|
+
if %w{capture authorize settlement}.include?(event_name)
|
70
|
+
Veritrans::Events.dispatch("payment.success", verified_data)
|
71
|
+
elsif event_name != 'challenge'
|
72
|
+
Veritrans::Events.dispatch("payment.failed", verified_data)
|
73
|
+
end
|
74
|
+
|
75
|
+
return send_text("ok", 200)
|
76
|
+
else
|
77
|
+
Veritrans::Events.dispatch("error", request_data)
|
78
|
+
Veritrans.file_logger.info("Callback verification failed:" +
|
79
|
+
"#{request_data['order_id']} #{request_data['transaction_status']}}\n" +
|
80
|
+
verified_data.body + "\n"
|
81
|
+
)
|
82
|
+
return send_text("Can not verify payment via Payment API: #{verified_data.status_message}", 404)
|
83
|
+
end
|
84
|
+
|
85
|
+
rescue Object => error
|
86
|
+
Veritrans.file_logger.info("Callback proccesing failed. \n" +
|
87
|
+
"RAW_POST_DATA: #{env["rack.input"].read}\n" +
|
88
|
+
error.message +
|
89
|
+
error.backtrace.join("\n") + "\n"
|
90
|
+
)
|
91
|
+
Veritrans::Events.dispatch("error", verified_data || request_data || post_body)
|
92
|
+
return send_text("Server error:\n#{error.message}", 500)
|
93
|
+
end
|
94
|
+
|
95
|
+
def send_text(body, status = 200)
|
96
|
+
[status, {"Content-Type" => "text/html"}, [body]]
|
97
|
+
end
|
98
|
+
|
99
|
+
# processing events
|
100
|
+
|
101
|
+
class << self
|
102
|
+
attr_accessor :listeners
|
103
|
+
|
104
|
+
def subscribe(*event_types, &handler)
|
105
|
+
@listeners ||= []
|
106
|
+
event_types.each do |event_type|
|
107
|
+
@listeners << [event_type, handler]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def dispatch(new_event, event_data)
|
112
|
+
@listeners.each do |pair|
|
113
|
+
event_type, handler = *pair
|
114
|
+
|
115
|
+
if event_type.is_a?(String) && event_type == new_event
|
116
|
+
handler.call(event_data)
|
117
|
+
elsif event_type.is_a?(Regexp) && event_type =~ new_event
|
118
|
+
handler.call(event_data, new_event)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Veritrans
|
2
|
+
class Result
|
3
|
+
attr_reader :data
|
4
|
+
attr_reader :status
|
5
|
+
attr_reader :response
|
6
|
+
|
7
|
+
def initialize(response, url, options, time)
|
8
|
+
begin
|
9
|
+
if url =~ %r{/v2/.+/transcript$}
|
10
|
+
@data = {}
|
11
|
+
else
|
12
|
+
@data = Veritrans._json_decode(response.body)
|
13
|
+
|
14
|
+
# Failback for Hash#symbolize_keys
|
15
|
+
@data.keys.each do |key|
|
16
|
+
@data[(key.to_sym rescue key) || key] = @data.delete(key)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
rescue => e
|
21
|
+
Veritrans.logger.info "Error parsing papi response #{e.message}"
|
22
|
+
Veritrans.logger.info e.backtrace.join("\n")
|
23
|
+
@data = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
@time = time
|
27
|
+
@status = response.status
|
28
|
+
@response = response
|
29
|
+
@url = url
|
30
|
+
@options = options
|
31
|
+
end
|
32
|
+
|
33
|
+
def success?
|
34
|
+
@data[:status_code] == '200' || @data[:status_code] == '201'
|
35
|
+
end
|
36
|
+
|
37
|
+
# for VT-Link
|
38
|
+
def created?
|
39
|
+
@data[:status_code] == '201'
|
40
|
+
end
|
41
|
+
|
42
|
+
# Docs http://docs.veritrans.co.id/sandbox/status_code.html
|
43
|
+
def status_code
|
44
|
+
@data[:status_code].to_i
|
45
|
+
end
|
46
|
+
|
47
|
+
def status_message
|
48
|
+
@data[:status_message]
|
49
|
+
end
|
50
|
+
|
51
|
+
def redirect_url
|
52
|
+
@data[:redirect_url]
|
53
|
+
end
|
54
|
+
|
55
|
+
def messages
|
56
|
+
if @data[:message].present?
|
57
|
+
@data[:message].chomp(']').sub(/^\[/, '').split(',').map(&:strip)
|
58
|
+
else
|
59
|
+
[]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def body
|
64
|
+
response.body
|
65
|
+
end
|
66
|
+
|
67
|
+
def method_missing(method_name, *args)
|
68
|
+
if args.size == 0 && @data && @data.has_key?(method_name)
|
69
|
+
return @data[method_name]
|
70
|
+
else
|
71
|
+
super
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def inspect
|
76
|
+
time_ms = (@time * 1000).round
|
77
|
+
data = @data.inspect.gsub(/:([^\s]+)=>/, "\\1: ")
|
78
|
+
"#<Veritrans::Result:#{object_id} ^^ http_status: #{@status} time: #{time_ms}ms ^^ data: #{data}>"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/veritrans/version.rb
CHANGED
@@ -1,43 +1,3 @@
|
|
1
|
-
# :nodoc:
|
2
1
|
module Veritrans
|
3
|
-
|
4
|
-
# it use class methods to generate it
|
5
|
-
#
|
6
|
-
# Example:
|
7
|
-
#
|
8
|
-
# Veritrans::Version.to_s
|
9
|
-
class Version
|
10
|
-
|
11
|
-
class <<self
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
# :nodoc:
|
16
|
-
def major
|
17
|
-
1
|
18
|
-
end
|
19
|
-
|
20
|
-
# :nodoc:
|
21
|
-
def minor
|
22
|
-
2
|
23
|
-
end
|
24
|
-
|
25
|
-
# :nodoc:
|
26
|
-
def patch
|
27
|
-
6
|
28
|
-
end
|
29
|
-
|
30
|
-
# :nodoc:
|
31
|
-
def pre
|
32
|
-
nil
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# ==== Return:
|
37
|
-
#
|
38
|
-
# * <tt>String</tt> - version information
|
39
|
-
def self.to_s
|
40
|
-
[major, minor, patch, pre].compact.join('.')
|
41
|
-
end
|
42
|
-
end
|
2
|
+
VERSION = "2.0.0beta"
|
43
3
|
end
|
data/lib/veritrans.rb
CHANGED
@@ -1,19 +1,83 @@
|
|
1
|
-
|
1
|
+
require 'veritrans/version'
|
2
|
+
require 'veritrans/config'
|
3
|
+
require 'veritrans/client'
|
4
|
+
require 'veritrans/api'
|
5
|
+
require 'veritrans/result'
|
2
6
|
|
3
|
-
|
4
|
-
require '
|
5
|
-
|
6
|
-
require "addressable/uri"
|
7
|
-
require 'faraday'
|
7
|
+
if defined?(::Rails)
|
8
|
+
require 'veritrans/events'
|
9
|
+
end
|
8
10
|
|
9
|
-
# root namespace
|
10
11
|
module Veritrans
|
11
|
-
|
12
|
+
extend Veritrans::Client
|
13
|
+
extend Veritrans::Api
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
class << self
|
16
|
+
def config(&block)
|
17
|
+
if block
|
18
|
+
instance_eval(&block)
|
19
|
+
else
|
20
|
+
Veritrans::Config
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
alias_method :setup, :config
|
25
|
+
|
26
|
+
# General logger
|
27
|
+
# for rails apps it's === Rails.logger
|
28
|
+
# for non-rails apps it's logging to stdout
|
29
|
+
def logger
|
30
|
+
return @logger if @logger
|
31
|
+
if defined?(Rails)
|
32
|
+
Rails.logger
|
33
|
+
else
|
34
|
+
unless @log
|
35
|
+
require 'logger'
|
36
|
+
@log = Logger.new(STDOUT)
|
37
|
+
@log.level = Logger::INFO
|
38
|
+
end
|
39
|
+
@log
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def logger=(value)
|
44
|
+
@logger = value
|
45
|
+
end
|
46
|
+
|
47
|
+
# Logger to file, only important information
|
48
|
+
# For rails apps it will write log to RAILS_ROOT/log/veritrans.log
|
49
|
+
def file_logger
|
50
|
+
if !@file_logger
|
51
|
+
if defined?(Rails) && Rails.root
|
52
|
+
@file_logger = Logger.new(Rails.root.join("log/veritrans.log").to_s)
|
53
|
+
else
|
54
|
+
@file_logger = Logger.new("/dev/null")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
@file_logger
|
59
|
+
end
|
60
|
+
|
61
|
+
def file_logger=(value)
|
62
|
+
@file_logger = value
|
63
|
+
end
|
64
|
+
|
65
|
+
def events
|
66
|
+
Veritrans::Events if defined?(Veritrans::Events)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Note: Veritrans sending notification data as json, encoded twice
|
70
|
+
# so we should call JSON.parse twice
|
71
|
+
def decode_notification_json(input)
|
72
|
+
if input.start_with?('"{') && input.end_with?('}"')
|
73
|
+
# ruby's JSON library can't excpect only hash or array. To decode string I wrap it in array.
|
74
|
+
request_data = Veritrans::Client._json_decode('[' + input + ']').first
|
75
|
+
return Veritrans::Client._json_decode(request_data)
|
76
|
+
else
|
77
|
+
# in case we will make it in expected way later
|
78
|
+
return Veritrans::Client._json_decode(input)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
data/license.txt
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|