payload-api 0.3.5 → 0.4.0

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: 6bed3adff70e34efe92779759df9927317d76572899140174f026fc0317bf558
4
- data.tar.gz: a30f7763d405886d6b2f05ae2ac3e762f0c90b20bc7ee01722d73fe10fee423f
3
+ metadata.gz: c6a65380dc908d716ddb1642ecb6bab391061c469ffa9951b80d3db94e84b08d
4
+ data.tar.gz: 77978473db8ca858d60db59155625b3133e5d8470fa69ff6a76ec497c086c17a
5
5
  SHA512:
6
- metadata.gz: 43504c2dd38496043e2c9200cc2d92acc207ad9c39581a1a528ff7c2f469b037c582e7fc1f0c9ae83c4af284bd59e02d7c5c5e946ada48400bfcb1757402ad43
7
- data.tar.gz: 3c87796896fce58f76f34acc2f3579c9251d5e13a3860f57c6d5531112507b02a5cf00a8e627c56189272ecfb484f4a95b49dbcf6e0d88755262240155f0fd0f
6
+ metadata.gz: '09dce62dabb4cd5d51432adec32190ffb4b0f9a924c3794c0cef3d009c6e0d73897d9d58ca1d8417a85709ca903581fbb444ad66dab3951b27b8bf2ed0e0198d'
7
+ data.tar.gz: e2d546eef549863a7c3da77c9c6e4ddb5446fa19cc93d854de7109530cff8645a51af2bc46f6a9095bd7b629fe99f464a30848262c459d3899d91d2eddc3ff7a
@@ -85,7 +85,7 @@ module Payload
85
85
 
86
86
  class PaymentItem < ARMObject
87
87
  @spec = { 'object' => 'line_item' }
88
- @poly = { 'type' => 'payment' }
88
+ @poly = { 'entry_type' => 'payment' }
89
89
  end
90
90
 
91
91
  class PaymentActivation < ARMObject
@@ -1,3 +1,3 @@
1
1
  module Payload
2
- VERSION = '0.3.5'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -0,0 +1,62 @@
1
+ require "payload"
2
+ require "payload/arm/object"
3
+ require 'base64'
4
+
5
+
6
+ RSpec.describe Payload::ARMRequest do
7
+
8
+ describe "#create" do
9
+
10
+ let(:instance) { described_class.new }
11
+
12
+ context "when a payment is created for an invoice" do
13
+ it "executes the appropriate request and returns the appropriate object" do
14
+
15
+ $test_id = 'txn_' + rand(9000000...9999999).to_s
16
+
17
+ Payload::api_key = 'test_key'
18
+ instance.instance_variable_set(:@cls, Payload::Payment)
19
+
20
+ expect(instance).to receive(:_execute_request) do |http, request|
21
+ expect(request.method).to eq("POST")
22
+ expect(http.address).to eq("api.payload.com")
23
+ expect(Base64.decode64(request['authorization'].split(' ')[1]).split(':')[0]).to eq('test_key')
24
+ expect(request.path).to eq("/transactions?")
25
+ expect(request.body).to eq("{\"amount\":129.0,\"customer_id\":\"acct_3bW9JMoGYQul5fCIa9f8q\",\"allocations\":[{\"entry_type\":\"payment\",\"invoice_id\":\"inv_3eNP6uf94xHTXr0rMyvZJ\"}],\"type\":\"payment\"}")
26
+
27
+ class MockResponse
28
+ def initialize
29
+ end
30
+
31
+ def code
32
+ '200'
33
+ end
34
+
35
+ def body
36
+ '{
37
+ "id": "' + $test_id + '",
38
+ "object": "transaction"
39
+ }'
40
+ end
41
+ end
42
+
43
+ MockResponse.new
44
+ end
45
+
46
+ payment = instance.create(
47
+ amount: 129.0,
48
+ customer_id: 'acct_3bW9JMoGYQul5fCIa9f8q',
49
+ allocations: [
50
+ Payload::PaymentItem.new(
51
+ invoice_id: 'inv_3eNP6uf94xHTXr0rMyvZJ'
52
+ )
53
+ ],
54
+ )
55
+
56
+ expect(payment.id).to eq($test_id)
57
+ expect(payment.object).to eq("transaction")
58
+ expect(payment.session).to eq(instance.instance_variable_get(:@session))
59
+ end
60
+ end
61
+ end
62
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payload-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Payload
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-09 00:00:00.000000000 Z
11
+ date: 2024-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple library to interface with the Payload API. See https://docs.payload.com
14
14
  for details.
@@ -18,7 +18,7 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - ".github/workflows/publish.yml"
21
- - ".github/workflows/ruby-app.yml"
21
+ - ".github/workflows/test.yml"
22
22
  - LICENSE
23
23
  - README.md
24
24
  - lib/payload.rb
@@ -30,6 +30,7 @@ files:
30
30
  - lib/payload/utils.rb
31
31
  - lib/payload/version.rb
32
32
  - payload.gemspec
33
+ - spec/objects/payment_spec.rb
33
34
  - spec/payload/arm/request_spec.rb
34
35
  - spec/payload/arm/session_spec.rb
35
36
  homepage: https://docs.payload.com
File without changes