viva_wallet 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a79710c0a7a265874d12040481be2bac040e71463a076c9b602c684797bf5a2f
4
- data.tar.gz: 5dca15441487811d6ecbd1c80559d42ef59f46d90ff26923d145e77a4169d10c
3
+ metadata.gz: 533ff6b37d93fac693b84a252202a8c6efc31d0b72270b090ad71edf0606ffe3
4
+ data.tar.gz: 294b8ce48c01c7d1ccea7d4c9fb2f00d034ab1b62b8ecc5fd1e7300958be9600
5
5
  SHA512:
6
- metadata.gz: a1ffe9b7b48c09320ce0412420607c9b48606b5d57c5bbbff65f49b669dbf756c00862b9bf2be307afd0747e9f04e49b7feda2742173bf1d98abfeca5beef3cd
7
- data.tar.gz: 32f105ec5f95c2bbef068c250244616aba74e7831ae9647679f1662ed38f38fae82c4568ab4935c1aa022a617a6b8ef3bee172e1b2f399329a27ab3e7b4c0302
6
+ metadata.gz: 23e7e836f4fc2b6f48cccb057e20d9694facd1ff46b507a1a12ecc81c901392d795818c5cf80c531acb5f6c79e5b458fad4ede2df9335c425126cbb46d593090
7
+ data.tar.gz: d3b7b8f89d33c643ca085e0682df724c9cb398b54b6df59540ab4b8d85572c1899ee2685e4cd389b5c1174e24662b3b0231c26a547fcd2695a8071e3df3e1822
data/README.md CHANGED
@@ -23,6 +23,7 @@ Set up an initializer file with your Viva Wallet Smart Checkout client keys:
23
23
  ```ruby
24
24
  VivaWallet.client_id = 'viva_client_id'
25
25
  VivaWallet.client_secret = 'viva_client_secret'
26
+ VivaWallet.source_code = 'website_app_source_code'
26
27
  VivaWallet.test_mode = true/false
27
28
  ```
28
29
  e.g. *config/initializers/viva_wallet.rb*
@@ -7,11 +7,11 @@ module VivaWallet
7
7
  def oauth
8
8
  RestClient::Request.new({
9
9
  method: :post,
10
- url: VivaWallet.account_api_base + 'connect/token?grant_type=client_credentials',
10
+ url: VivaWallet.account_api_base + 'connect/token',
11
+ payload: {grant_type: 'client_credentials'},
11
12
  headers: {
12
- accept: :json,
13
- content_type: :json,
14
- 'Authorization': "Bearer #{VivaWallet.client_base64}"
13
+ content_type: 'application/x-www-form-urlencoded',
14
+ Authorization: "Basic #{VivaWallet.client_base64}"
15
15
  }
16
16
  }).execute do |response, request, result|
17
17
  str_response = response.to_str
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VivaWallet
4
- VERSION = "0.1.3"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/viva_wallet.rb CHANGED
@@ -14,7 +14,8 @@ module VivaWallet
14
14
  class ConfigurationError < VivaWalletError; end
15
15
 
16
16
  class << self
17
- attr_writer :client_id, :client_secret, :test_mode, :api_base, :account_api_base, :client_base64
17
+ attr_writer :client_id, :client_secret, :source_code, :test_mode,
18
+ :api_base, :account_api_base, :client_base64
18
19
 
19
20
  def client_id
20
21
  defined? @client_id and @client_id or raise(
@@ -28,6 +29,12 @@ module VivaWallet
28
29
  )
29
30
  end
30
31
 
32
+ def source_code
33
+ defined? @source_code and @source_code or raise(
34
+ ConfigurationError, "VivaWallet source_code not configured"
35
+ )
36
+ end
37
+
31
38
  def test_mode
32
39
  @test_mode.nil? ? false : @test_mode
33
40
  end
@@ -41,7 +48,7 @@ module VivaWallet
41
48
  end
42
49
 
43
50
  def client_base64
44
- Base64.encode64("#{VivaWallet.client_id}:#{VivaWallet.client_secret}".gsub("\n", ""))
51
+ Base64.encode64("#{VivaWallet.client_id}:#{VivaWallet.client_secret}").gsub("\n", "")
45
52
  end
46
53
 
47
54
  def request(method, resource, params = {}, access_token = nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viva_wallet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Dallimore