naspay_rails 0.0.4 → 0.0.5

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: 478a05f6f91efcfede7a11ce362906d4f9e0f1692243e153ae12e3f6f582b30f
4
- data.tar.gz: 5563b1ddeb666e25d41cb5078603369cde658a861d455f6eb429570076aadedf
3
+ metadata.gz: 9a556b9d99b35cb2d1b9715db80a94794c5beb5cf7558bab5dd22f093953893c
4
+ data.tar.gz: 8d2f30446762c6dd096cdcc7828fac3e0e15ad38e7e2f4cd013dc8047d601ff2
5
5
  SHA512:
6
- metadata.gz: f1cded9dbacd4cfa57340a33d257710dbd43ab2c2d1cf0ae143e305a56e381dd9952d406af76664a545dd21d22972a088284980a797676c9cec15f43b78cbebf
7
- data.tar.gz: adb9847a70d6f49ed9445d8d2195b6e972e045a5c6d32e0d7c5c78a3f2e9767d3787ac3ff7c22e0d9be5c36ded01a589ea819c6e00cfc4595963d12152ea5cca
6
+ metadata.gz: 4e4cf4ab3a4cd8d6a078807dd12224fc84724194f2c618732e9a59610b6d66789897e3208b94cf69a078e4930bd4a3cfa07f8279323d199d0a7c1f44859c0570
7
+ data.tar.gz: 42e501961e803dbcbc09210b454e8826a9efd099ccfb5ce30070b8dc3ffff0e269e51378bc7c55053e6bacd6aba8a27dd5b990b787ec0093006f24f8d63f628a
@@ -3,6 +3,7 @@ require 'naspay_rails/configuration'
3
3
  require 'naspay_rails/auth'
4
4
  require 'naspay_rails/transactions'
5
5
  require 'naspay_rails/payouts'
6
+ require 'naspay_rails/naspay_sender'
6
7
 
7
8
  module NaspayRails
8
9
 
@@ -0,0 +1,51 @@
1
+ module NaspaySender
2
+ class SenderBase
3
+ def self.call(*args)
4
+ new(*args).call
5
+ end
6
+ end
7
+
8
+ class Transaction < SenderBase
9
+ def initialize(intent, amount, currency, id, description, customer = nil, shipping_address = nil)
10
+ secrets = NaspayRails.configuration.secrets
11
+ @api_endpoint = secrets[:api_endpoint]
12
+ @auth_token = NaspayRails::Auth.get_token(secrets)
13
+ @params = {
14
+ intent: intent,
15
+ amount: amount,
16
+ currency: currency,
17
+ transaction_id: id,
18
+ description: description
19
+ }
20
+ if customer.present?
21
+ @params.store(:customer, customer)
22
+ end
23
+ if shipping_address.present?
24
+ @params.store(:shipping_address, shipping_address)
25
+ end
26
+ end
27
+
28
+ def call
29
+ NaspayRails::Transactions.create_new(@api_endpoint, @params, @auth_token)
30
+ end
31
+ end
32
+
33
+ class Payout < SenderBase
34
+ def initialize(amount, currency, id, description, card)
35
+ secrets = NaspayRails.configuration.secrets
36
+ @api_endpoint = secrets[:api_endpoint]
37
+ @auth_token = NaspayRails::Auth.get_token(secrets)
38
+ @params = {
39
+ amount: amount,
40
+ currency: currency,
41
+ transaction_id: id,
42
+ description: description,
43
+ card: card
44
+ }
45
+ end
46
+
47
+ def call
48
+ NaspayRails::Payouts.create_new(@api_endpoint, @params, @auth_token)
49
+ end
50
+ end
51
+ end
@@ -1,3 +1,3 @@
1
1
  module NaspayRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naspay_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - antonror
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-30 00:00:00.000000000 Z
11
+ date: 2018-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,6 +79,7 @@ files:
79
79
  - lib/naspay_rails.rb
80
80
  - lib/naspay_rails/auth.rb
81
81
  - lib/naspay_rails/configuration.rb
82
+ - lib/naspay_rails/naspay_sender.rb
82
83
  - lib/naspay_rails/payouts.rb
83
84
  - lib/naspay_rails/transactions.rb
84
85
  - lib/naspay_rails/version.rb