xendit-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9e766f68f5bfdb0463c6dc08b2ed7ddc2ac3591a68a93ce1313bb424931e422
4
- data.tar.gz: afba098d3de38edf092f7aab550925badbf920cfb628a717f730d07a9ce3a8f0
3
+ metadata.gz: f23491d5516272d1c6d105f20e04a1be7cf855209a48ec3b5c67963aa0477612
4
+ data.tar.gz: a24c3250857189f2e48be30dcfaaf61d9c1581da3958dced8b3ee2788fb1b236
5
5
  SHA512:
6
- metadata.gz: 4aae8d5b504b24fd44c635f1d3206326d9d76b984131ee60d69ea6dfedf7861fa32230ae2745115aaea29161ecb0142f76e51854b08a8c0020d1eb7fe9b3424a
7
- data.tar.gz: 54de86d3006d565353ea922ba7f195b49a26045b4947a68abaa62f416f7273a615d8c015ee2bf3f98e16f541a3bfc73130d716d97c777ab00df51db329ec0475
6
+ metadata.gz: c132337f5c2afcdc7858a93906aefde745581452d23605436cdb256b8828a815428065806fd8ee1ca003b344fa732a90ab0b14cf8f4b62c8ff954efb10a2ed85
7
+ data.tar.gz: e333d80698781a88e50987bbcaba44475e90b09ec0c3465a6561f3e615ba8229b3e3c131d49250ba08a685b6b42fd322092922fd93b32e4a0764b0a000a471a6
@@ -1,7 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xendit
4
+ # Xendit's base controller
4
5
  class ApplicationController < ActionController::API
5
- # protect_from_forgery with: :exception
6
+ before_action :verify_token!
7
+
8
+ private
9
+
10
+ def verify_token!
11
+ return true if token_valid?
12
+
13
+ head :unauthorized
14
+ false
15
+ end
16
+
17
+ def token_valid?
18
+ callback_token = Xendit.callback_token
19
+ if Xendit.callback_token.nil?
20
+ raise XenditTokenNotConfiguredError, "Callback token is not set."
21
+ end
22
+
23
+ request.headers["x-callback-token"] == callback_token
24
+ end
6
25
  end
26
+ class XenditTokenNotConfiguredError < StandardError; end
7
27
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_dependency "xendit/application_controller"
4
4
  require_dependency "xendit/invoice/payment_receiver"
5
+
5
6
  module Xendit
6
7
  class Callbacks::InvoicesController < ApplicationController
7
8
  def paid_or_expired
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "xendit"
3
4
  require "xendit/rails/engine"
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Xendit
4
+ class << self
5
+ attr_accessor :callback_token
6
+ end
7
+ end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Xendit
4
- autoload :TimestampMapable, "xendit/concerns/orderable"
5
4
  module Rails
6
5
  class Engine < ::Rails::Engine
7
6
  isolate_namespace Xendit
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Xendit
4
4
  module Rails
5
- VERSION = '0.0.2'
5
+ VERSION = "0.0.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,49 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xendit-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yana Agun Siswanto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-12 00:00:00.000000000 Z
11
+ date: 2020-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 6.0.2
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 6.0.2.2
19
+ version: 5.2.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: 6.0.2
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
- version: 6.0.2.2
26
+ version: 5.2.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: sqlite3
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - ">="
38
32
  - !ruby/object:Gem::Version
39
- version: '0'
40
- type: :development
33
+ version: 1.3.13
34
+ type: :runtime
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - ">="
45
39
  - !ruby/object:Gem::Version
46
- version: '0'
40
+ version: 1.3.13
47
41
  description: Quickly add payment to your rails app using xendit.
48
42
  email:
49
43
  - yana.developer@gmail.com
@@ -74,6 +68,7 @@ files:
74
68
  - db/migrate/20200411160747_create_xendit_recurrings.rb
75
69
  - lib/tasks/xendit/rails_tasks.rake
76
70
  - lib/xendit-rails.rb
71
+ - lib/xendit.rb
77
72
  - lib/xendit/invoice/payment_receiver.rb
78
73
  - lib/xendit/rails/engine.rb
79
74
  - lib/xendit/rails/version.rb