paymentrails 0.2.9 → 0.2.11

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: 57b1a2026b6e8965b49501ac1742aece5914a1ed4b28c2dc10a1919df9f77523
4
- data.tar.gz: '04910c8e5f5555c43e3af1866e6ca9365eed0dc5ba9184dd0ac6209466a8a6a2'
3
+ metadata.gz: 59d9150dfe0a7a84e065382411e1292d84f1cb38849030cb5c0092b14140b446
4
+ data.tar.gz: 194760ae4ab55031b06e7a128dfb07b43daf23a2e05c197b110250c3e19b31b8
5
5
  SHA512:
6
- metadata.gz: c36e9ea9b5a1ecb4e8e2aeeaa0795267349a310b502c63cb5fd3acd7eb62ac67fa776520244fe15a6f3327c600126f7e22becd15b03e7267aae24a58057cc87c
7
- data.tar.gz: 41b91895e01d72f475f503b62ae834d7c979749dd1ccc53825fab01bd2d186324e0090a096673faaf488bc8a17b2c221ec8a745bba3d9e40d663b722b084f457
6
+ metadata.gz: 10d565665437161d12562b22d9d6dc1a8b20318e10451b6d28f5cb4ce537a60471a60a0df764799127285aaf2517d2c6cfdb1232d6d84506debe804cb120216c
7
+ data.tar.gz: a826f2f439e18f091a6a1459065d8151ebaeb928986b5f708ae09f3b2c2f3948988685a318cf681a99c9543e153ef77f6200a3236354845dd40ed099c96bc088
@@ -25,6 +25,7 @@ module PaymentRails
25
25
  attr_writer :offline_payment
26
26
 
27
27
  attr_accessor :invoice
28
+ attr_accessor :invoice_payment
28
29
 
29
30
  def initialize(config)
30
31
  @config = config
@@ -36,6 +37,7 @@ module PaymentRails
36
37
  @balance = BalanceGateway.new(client)
37
38
  @offline_payment = OfflinePaymentGateway.new(client)
38
39
  @invoice = InvoiceGateway.new(client)
40
+ @invoice_payment = InvoicePaymentGateway.new(client)
39
41
  end
40
42
  end
41
43
  end
@@ -0,0 +1,13 @@
1
+ module PaymentRails
2
+ class InvoicePayment
3
+ attr_accessor(
4
+ :id,
5
+ :batchId,
6
+ :paymentId,
7
+ :invoiceId,
8
+ :invoiceLineId,
9
+ :amount,
10
+ :invoicePayments
11
+ )
12
+ end
13
+ end
@@ -0,0 +1,56 @@
1
+ require_relative '../Client.rb'
2
+ require_relative 'GatewayHelper'
3
+
4
+ module PaymentRails
5
+ class InvoicePaymentGateway
6
+ include GatewayHelper
7
+
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def create(body)
13
+ response = @client.post('/v1/invoices/payment/create', body)
14
+ invoice_payment_builder(response)
15
+ end
16
+
17
+ def update(body)
18
+ @client.post('/v1/invoices/payment/update', body)
19
+ true
20
+ end
21
+
22
+ def delete(body)
23
+ @client.post('/v1/invoices/payment/delete', body)
24
+ true
25
+ end
26
+
27
+ def search(body)
28
+ response = @client.post('/v1/invoices/payment/search', body)
29
+ invoice_payments_list_builder(response)
30
+ end
31
+
32
+ def invoice_payment_builder(response)
33
+ invoice_payment = InvoicePayment.new
34
+ data = JSON.parse(response)
35
+ data.each do |key, value|
36
+ next unless key === 'invoicePayment'
37
+ loosely_hydrate_model(invoice_payment, value)
38
+ end
39
+ invoice_payment
40
+ end
41
+
42
+ def invoice_payments_list_builder(response)
43
+ invoice_payments = []
44
+ data = JSON.parse(response)
45
+
46
+ data.each do |key, value|
47
+ next unless key === 'invoicePayments'
48
+ value.each do |newKey, _newValue|
49
+ invoice_payment = loosely_hydrate_model(InvoicePayment.new, newKey)
50
+ invoice_payments.push(invoice_payment)
51
+ end
52
+ end
53
+ invoice_payments
54
+ end
55
+ end
56
+ end
data/lib/paymentrails.rb CHANGED
@@ -8,6 +8,7 @@ require 'paymentrails/gateways/RecipientGateway'
8
8
  require 'paymentrails/gateways/RecipientAccountGateway'
9
9
  require 'paymentrails/gateways/OfflinePaymentGateway'
10
10
  require 'paymentrails/gateways/InvoiceGateway'
11
+ require 'paymentrails/gateways/InvoicePaymentGateway'
11
12
 
12
13
  require 'paymentrails/Balance'
13
14
  require 'paymentrails/Batch'
@@ -18,9 +19,10 @@ require 'paymentrails/Recipient'
18
19
  require 'paymentrails/RecipientAccount'
19
20
  require 'paymentrails/OfflinePayment'
20
21
  require 'paymentrails/Invoice'
22
+ require 'paymentrails/InvoicePayment'
21
23
 
22
24
  module PaymentRails
23
25
  def self.client(key, secret, environment = 'production', **optionals)
24
- Gateway.new(Configuration.new(key, secret, environment, optionals))
26
+ Gateway.new(Configuration.new(key, secret, environment, **optionals))
25
27
  end
26
28
  end
data/paymentrails.gemspec CHANGED
@@ -2,11 +2,11 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "paymentrails"
5
- s.summary = "PaymentRails Ruby SDK"
6
- s.description = "Ruby SDK for interacting with the PaymentRails API"
7
- s.version = '0.2.9'
8
- s.homepage = 'https://www.paymentrails.com/'
9
- s.email = ['joshua@paymentrails.com']
5
+ s.summary = "Trolley Ruby SDK"
6
+ s.description = "Ruby SDK for interacting with the Trolley API"
7
+ s.version = '0.2.11'
8
+ s.homepage = 'https://trolley.com/'
9
+ s.email = ['developer-tools@trolley.com']
10
10
  s.license = "MIT"
11
11
  s.author = "PaymentRails"
12
12
  s.files = Dir.glob ["README.rdoc", "LICENSE", "lib/**/*.{rb,crt}", "spec/**/*", "*.gemspec"]
@@ -0,0 +1,99 @@
1
+ require_relative 'helper'
2
+
3
+ class InvoicePaymentTest < Test::Unit::TestCase
4
+ def setup
5
+ @client = PaymentRails.client(
6
+ ENV.fetch('SANDBOX_API_KEY'),
7
+ ENV.fetch('SANDBOX_SECRET_KEY'),
8
+ 'production',
9
+ proxy_uri: ENV['PROXY_URI']
10
+ )
11
+ end
12
+
13
+ def create_recipient
14
+ uuid = SecureRandom.uuid.to_s
15
+ recipient = @client.recipient.create(
16
+ type: 'individual',
17
+ firstName: 'Tom',
18
+ lastName: 'Jones',
19
+ email: 'test.batch' + uuid + '@example.com',
20
+ address: {
21
+ street1: '123 Wolfstrasse',
22
+ city: 'Berlin',
23
+ country: 'DE',
24
+ postalCode: '123123'
25
+ }
26
+ )
27
+ @client.recipient_account.create(recipient.id, type: 'bank-transfer', currency: 'EUR', country: 'DE', iban: 'DE89 3704 0044 0532 0130 00')
28
+ recipient
29
+ end
30
+
31
+ def test_create
32
+ recipient = create_recipient
33
+ invoice = @client.invoice.create(recipientId: recipient.id, description: 'Integration Test Invoice Create')
34
+ assert_not_nil(invoice)
35
+ assert_not_nil(invoice.id)
36
+ assert_equal('open', invoice.status)
37
+
38
+ invoice_line = @client.invoice.create_line(invoiceId: invoice.id, lines: [{ unitAmount: { value: '2000', currency: 'USD' } }])
39
+ assert_not_nil(invoice_line.lines)
40
+ assert_not_nil(invoice_line.lines.first['id'])
41
+
42
+ @client.invoice_payment.create(ids: [invoiceId: invoice.id])
43
+ invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
44
+ assert_true(invoice_payments.count > 0)
45
+
46
+ findInvoice = @client.invoice.find(invoiceId: invoice.id)
47
+ assert_equal('paid', findInvoice.status)
48
+ end
49
+
50
+ def test_update
51
+ recipient = create_recipient
52
+
53
+ invoice = @client.invoice.create(recipientId: recipient.id, description: 'Integration Test Invoice Create')
54
+ assert_not_nil(invoice)
55
+ assert_not_nil(invoice.id)
56
+
57
+ invoices = @client.invoice.search({})
58
+ assert_true(invoices.count > 0)
59
+
60
+ invoice_line = @client.invoice.create_line(invoiceId: invoice.id, lines: [{ unitAmount: { value: '2000', currency: 'USD' } }])
61
+ assert_not_nil(invoice_line.lines)
62
+ assert_not_nil(invoice_line.lines.first['id'])
63
+
64
+ invoice_payment = @client.invoice_payment.create(ids: [invoiceId: invoice.id])
65
+ invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
66
+ assert_true(invoice_payments.count > 0)
67
+ assert_equal('2000.00', invoice_payments.first.amount['value'])
68
+
69
+ response = @client.invoice_payment.update(paymentId: invoice_payment.paymentId, invoiceLineId: invoice_payment.invoicePayments.first['invoiceLineId'], amount: { value: '5000', currency: 'USD' })
70
+ assert_true(response)
71
+ invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
72
+ assert_true(invoice_payments.count > 0)
73
+ assert_equal('5000.00', invoice_payments.first.amount['value'])
74
+ end
75
+
76
+ def test_delete
77
+ recipient = create_recipient
78
+
79
+ invoice = @client.invoice.create(recipientId: recipient.id, description: 'Integration Test Invoice Create')
80
+ assert_not_nil(invoice)
81
+ assert_not_nil(invoice.id)
82
+
83
+ invoices = @client.invoice.search({})
84
+ assert_true(invoices.count > 0)
85
+
86
+ invoice_line = @client.invoice.create_line(invoiceId: invoice.id, lines: [{ unitAmount: { value: '2000', currency: 'USD' } }])
87
+ assert_not_nil(invoice_line.lines)
88
+ assert_not_nil(invoice_line.lines.first['id'])
89
+
90
+ invoice_payment = @client.invoice_payment.create(ids: [invoiceId: invoice.id])
91
+ invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
92
+ assert_true(invoice_payments.count > 0)
93
+
94
+ response = @client.invoice_payment.delete(paymentId: invoice_payment.paymentId, invoiceLineIds: [invoice_payment.invoicePayments.first['invoiceLineId']])
95
+ assert_true(response)
96
+ invoice_payments = @client.invoice_payment.search(invoiceIds: [invoice.id])
97
+ assert_true(invoice_payments.count == 0)
98
+ end
99
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paymentrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - PaymentRails
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-03 00:00:00.000000000 Z
11
+ date: 2022-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -66,9 +66,9 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3'
69
- description: Ruby SDK for interacting with the PaymentRails API
69
+ description: Ruby SDK for interacting with the Trolley API
70
70
  email:
71
- - joshua@paymentrails.com
71
+ - developer-tools@trolley.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -83,6 +83,7 @@ files:
83
83
  - lib/paymentrails/Exceptions.rb
84
84
  - lib/paymentrails/Gateway.rb
85
85
  - lib/paymentrails/Invoice.rb
86
+ - lib/paymentrails/InvoicePayment.rb
86
87
  - lib/paymentrails/OfflinePayment.rb
87
88
  - lib/paymentrails/Payment.rb
88
89
  - lib/paymentrails/Recipient.rb
@@ -91,18 +92,20 @@ files:
91
92
  - lib/paymentrails/gateways/BatchGateway.rb
92
93
  - lib/paymentrails/gateways/GatewayHelper.rb
93
94
  - lib/paymentrails/gateways/InvoiceGateway.rb
95
+ - lib/paymentrails/gateways/InvoicePaymentGateway.rb
94
96
  - lib/paymentrails/gateways/OfflinePaymentGateway.rb
95
97
  - lib/paymentrails/gateways/PaymentGateway.rb
96
98
  - lib/paymentrails/gateways/RecipientAccountGateway.rb
97
99
  - lib/paymentrails/gateways/RecipientGateway.rb
98
100
  - paymentrails.gemspec
99
101
  - spec/integration/BatchTest.rb
102
+ - spec/integration/InvoicePaymentTest.rb
100
103
  - spec/integration/InvoiceTest.rb
101
104
  - spec/integration/RecipientTest.rb
102
105
  - spec/integration/helper.rb
103
106
  - spec/unit/ConfigurationTest.rb
104
107
  - spec/unit/PaymentRailsTest.rb
105
- homepage: https://www.paymentrails.com/
108
+ homepage: https://trolley.com/
106
109
  licenses:
107
110
  - MIT
108
111
  metadata: {}
@@ -124,5 +127,5 @@ requirements: []
124
127
  rubygems_version: 3.1.2
125
128
  signing_key:
126
129
  specification_version: 4
127
- summary: PaymentRails Ruby SDK
130
+ summary: Trolley Ruby SDK
128
131
  test_files: []