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 +4 -4
- data/lib/payload/objects.rb +1 -1
- data/lib/payload/version.rb +1 -1
- data/spec/objects/payment_spec.rb +62 -0
- metadata +4 -3
- /data/.github/workflows/{ruby-app.yml → test.yml} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6a65380dc908d716ddb1642ecb6bab391061c469ffa9951b80d3db94e84b08d
|
4
|
+
data.tar.gz: 77978473db8ca858d60db59155625b3133e5d8470fa69ff6a76ec497c086c17a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09dce62dabb4cd5d51432adec32190ffb4b0f9a924c3794c0cef3d009c6e0d73897d9d58ca1d8417a85709ca903581fbb444ad66dab3951b27b8bf2ed0e0198d'
|
7
|
+
data.tar.gz: e2d546eef549863a7c3da77c9c6e4ddb5446fa19cc93d854de7109530cff8645a51af2bc46f6a9095bd7b629fe99f464a30848262c459d3899d91d2eddc3ff7a
|
data/lib/payload/objects.rb
CHANGED
data/lib/payload/version.rb
CHANGED
@@ -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.
|
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-
|
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/
|
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
|