add store invoice specs. update readme.
This commit is contained in:
parent
75ff50d2b3
commit
1dc622eac0
|
@ -96,6 +96,15 @@ All endpoints are accessed via namespaced Api resource. Example: `client.users.c
|
|||
1. `DELETE #delete(store_id)`
|
||||
1. `PUT #update(store_id, payload)`
|
||||
|
||||
- ##### Invoices:
|
||||
|
||||
1. `GET #all(store_id)`
|
||||
1. `POST #create(store_id, payload)`
|
||||
1. `GET #get(store_id, invoice_id)`
|
||||
1. `DELETE #delete(store_id, invoice_id)`
|
||||
1. `POST #update_status(store_id, invoice_id, payload, status)`
|
||||
1. `POST #unarchive(store_id, invoice_id)`
|
||||
|
||||
- ##### Payment Requests:
|
||||
|
||||
1. `GET #all(store_id)`
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
RSpec.describe BtcPay do
|
||||
it 'has a version number' do
|
||||
expect(BtcPay::VERSION).to eq('0.1.1')
|
||||
expect(BtcPay::VERSION).to eq('0.1.2')
|
||||
end
|
||||
|
||||
describe '.new' do
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: delete
|
||||
uri: http://localhost:49392/api/v1/stores/Ej6iMSnPKNyh9mEnTE7FmP4CH8pQ689CnNeQouNDShzh/invoices/PA1t8RJWYq78rTAeGBZmkJ
|
||||
body:
|
||||
encoding: US-ASCII
|
||||
string: ''
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- btcpay_ruby/0.1.2
|
||||
Content-Type:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- deflate, gzip
|
||||
Authorization:
|
||||
- token 8662bc1847a02b460e71d20d8408da73a877a127
|
||||
Host:
|
||||
- localhost:49392
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Date:
|
||||
- Sat, 21 Nov 2020 21:37:43 GMT
|
||||
Server:
|
||||
- Kestrel
|
||||
Content-Length:
|
||||
- '0'
|
||||
Referrer-Policy:
|
||||
- same-origin
|
||||
X-Xss-Protection:
|
||||
- 1; mode=block
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- DENY
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: ''
|
||||
recorded_at: Sat, 21 Nov 2020 21:37:44 GMT
|
||||
recorded_with: VCR 6.0.0
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: get
|
||||
uri: http://localhost:49392/api/v1/stores/Ej6iMSnPKNyh9mEnTE7FmP4CH8pQ689CnNeQouNDShzh/invoices
|
||||
body:
|
||||
encoding: US-ASCII
|
||||
string: ''
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- btcpay_ruby/0.1.2
|
||||
Content-Type:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- deflate, gzip
|
||||
Authorization:
|
||||
- token 8662bc1847a02b460e71d20d8408da73a877a127
|
||||
Host:
|
||||
- localhost:49392
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Date:
|
||||
- Sat, 07 Nov 2020 23:05:00 GMT
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Server:
|
||||
- Kestrel
|
||||
Content-Length:
|
||||
- '2'
|
||||
Referrer-Policy:
|
||||
- same-origin
|
||||
X-Xss-Protection:
|
||||
- 1; mode=block
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- DENY
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: "[]"
|
||||
recorded_at: Sat, 07 Nov 2020 23:05:00 GMT
|
||||
recorded_with: VCR 6.0.0
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: get
|
||||
uri: http://localhost:49392/api/v1/stores/Ej6iMSnPKNyh9mEnTE7FmP4CH8pQ689CnNeQouNDShzh/invoices/PA1t8RJWYq78rTAeGBZmkJ
|
||||
body:
|
||||
encoding: US-ASCII
|
||||
string: ''
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- btcpay_ruby/0.1.2
|
||||
Content-Type:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- deflate, gzip
|
||||
Authorization:
|
||||
- token 8662bc1847a02b460e71d20d8408da73a877a127
|
||||
Host:
|
||||
- localhost:49392
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Date:
|
||||
- Sat, 21 Nov 2020 21:09:12 GMT
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Server:
|
||||
- Kestrel
|
||||
Content-Length:
|
||||
- '374'
|
||||
Referrer-Policy:
|
||||
- same-origin
|
||||
X-Xss-Protection:
|
||||
- 1; mode=block
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- DENY
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: '{"id":"PA1t8RJWYq78rTAeGBZmkJ","status":"New","additionalStatus":"None","monitoringExpiration":1606079998,"expirationTime":1605993598,"createdTime":1605992698,"amount":0.00005848597885459439,"currency":"btc","metadata":{"orderId":"12345"},"checkout":{"speedPolicy":"HighSpeed","paymentMethods":["BTC"],"expirationMinutes":15,"monitoringMinutes":1440,"paymentTolerance":0.0}}'
|
||||
recorded_at: Sat, 21 Nov 2020 21:09:13 GMT
|
||||
recorded_with: VCR 6.0.0
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: post
|
||||
uri: http://localhost:49392/api/v1/stores/Ej6iMSnPKNyh9mEnTE7FmP4CH8pQ689CnNeQouNDShzh/invoices
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: '{"amount":0.014421449041276548,"currency":"btc","metadata":{"orderId":12345},"checkout":{"speedPolicy":"HighSpeed","paymentMethods":["BTC"],"expirationMinutes":15,"monitoringMinutes":1440,"paymentTolerance":0}}'
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- btcpay_ruby/0.1.2
|
||||
Content-Type:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- deflate, gzip
|
||||
Authorization:
|
||||
- token 8662bc1847a02b460e71d20d8408da73a877a127
|
||||
Content-Length:
|
||||
- '210'
|
||||
Host:
|
||||
- localhost:49392
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Date:
|
||||
- Sat, 21 Nov 2020 21:08:49 GMT
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Server:
|
||||
- Kestrel
|
||||
Content-Length:
|
||||
- '372'
|
||||
Referrer-Policy:
|
||||
- same-origin
|
||||
X-Xss-Protection:
|
||||
- 1; mode=block
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- DENY
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: '{"id":"XbAeqLEdarysaPZVfLkNvG","status":"New","additionalStatus":"None","monitoringExpiration":1606080230,"expirationTime":1605993830,"createdTime":1605992930,"amount":0.014421449041276548,"currency":"btc","metadata":{"orderId":"12345"},"checkout":{"speedPolicy":"HighSpeed","paymentMethods":["BTC"],"expirationMinutes":15,"monitoringMinutes":1440,"paymentTolerance":0.0}}'
|
||||
recorded_at: Sat, 21 Nov 2020 21:08:50 GMT
|
||||
recorded_with: VCR 6.0.0
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: post
|
||||
uri: http://localhost:49392/api/v1/stores/Ej6iMSnPKNyh9mEnTE7FmP4CH8pQ689CnNeQouNDShzh/invoices/PA1t8RJWYq78rTAeGBZmkJ/unarchive
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: "{}"
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- btcpay_ruby/0.1.2
|
||||
Content-Type:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- deflate, gzip
|
||||
Authorization:
|
||||
- token 8662bc1847a02b460e71d20d8408da73a877a127
|
||||
Content-Length:
|
||||
- '2'
|
||||
Host:
|
||||
- localhost:49392
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Date:
|
||||
- Sat, 21 Nov 2020 21:37:18 GMT
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Server:
|
||||
- Kestrel
|
||||
Content-Length:
|
||||
- '380'
|
||||
Referrer-Policy:
|
||||
- same-origin
|
||||
X-Xss-Protection:
|
||||
- 1; mode=block
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- DENY
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: '{"id":"PA1t8RJWYq78rTAeGBZmkJ","status":"Invalid","additionalStatus":"Marked","monitoringExpiration":1606079998,"expirationTime":1605993598,"createdTime":1605992698,"amount":0.00005848597885459439,"currency":"btc","metadata":{"orderId":"12345"},"checkout":{"speedPolicy":"HighSpeed","paymentMethods":["BTC"],"expirationMinutes":15,"monitoringMinutes":1440,"paymentTolerance":0.0}}'
|
||||
recorded_at: Sat, 21 Nov 2020 21:37:19 GMT
|
||||
recorded_with: VCR 6.0.0
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
http_interactions:
|
||||
- request:
|
||||
method: post
|
||||
uri: http://localhost:49392/api/v1/stores/Ej6iMSnPKNyh9mEnTE7FmP4CH8pQ689CnNeQouNDShzh/invoices/PA1t8RJWYq78rTAeGBZmkJ/status
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: '{"status":"Invalid"}'
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
User-Agent:
|
||||
- btcpay_ruby/0.1.2
|
||||
Content-Type:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- deflate, gzip
|
||||
Authorization:
|
||||
- token 8662bc1847a02b460e71d20d8408da73a877a127
|
||||
Content-Length:
|
||||
- '20'
|
||||
Host:
|
||||
- localhost:49392
|
||||
response:
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
headers:
|
||||
Date:
|
||||
- Sat, 21 Nov 2020 21:23:02 GMT
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Server:
|
||||
- Kestrel
|
||||
Content-Length:
|
||||
- '380'
|
||||
Referrer-Policy:
|
||||
- same-origin
|
||||
X-Xss-Protection:
|
||||
- 1; mode=block
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Frame-Options:
|
||||
- DENY
|
||||
body:
|
||||
encoding: UTF-8
|
||||
string: '{"id":"PA1t8RJWYq78rTAeGBZmkJ","status":"Invalid","additionalStatus":"Marked","monitoringExpiration":1606079998,"expirationTime":1605993598,"createdTime":1605992698,"amount":0.00005848597885459439,"currency":"btc","metadata":{"orderId":"12345"},"checkout":{"speedPolicy":"HighSpeed","paymentMethods":["BTC"],"expirationMinutes":15,"monitoringMinutes":1440,"paymentTolerance":0.0}}'
|
||||
recorded_at: Sat, 21 Nov 2020 21:23:02 GMT
|
||||
recorded_with: VCR 6.0.0
|
|
@ -0,0 +1,51 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe BtcPay::Client::Api::StoreInvoices, :vcr do
|
||||
let(:store_id) { 'Ej6iMSnPKNyh9mEnTE7FmP4CH8pQ689CnNeQouNDShzh' }
|
||||
let(:invoice_id) { 'PA1t8RJWYq78rTAeGBZmkJ' }
|
||||
let(:client) do
|
||||
config = build(:config, auth_token: '8662bc1847a02b460e71d20d8408da73a877a127')
|
||||
build(:client, config: config)
|
||||
end
|
||||
|
||||
subject { described_class.new(client: client) }
|
||||
|
||||
describe 'GET #all' do
|
||||
let(:response) { subject.all(store_id) }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
let(:payload) { build(:store_invoices_payload) }
|
||||
let(:response) { subject.create(store_id, payload) }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
|
||||
describe 'GET #get' do
|
||||
let(:response) { subject.get(store_id, invoice_id) }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
|
||||
describe 'DELETE #delete' do
|
||||
let(:response) { subject.delete(store_id, invoice_id) }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
|
||||
describe 'POST #update_status' do
|
||||
let(:response) { subject.update_status(store_id, invoice_id, 'Invalid') }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
|
||||
describe 'POST #unarchive' do
|
||||
let(:response) { subject.unarchive(store_id, invoice_id) }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
end
|
|
@ -14,6 +14,7 @@ RSpec.describe BtcPay::Client::Base do
|
|||
it { expect(subject.pull_payments).to be_a(BtcPay::Client::Api::PullPayments) }
|
||||
it { expect(subject.server).to be_a(BtcPay::Client::Api::Server) }
|
||||
it { expect(subject.store).to be_a(BtcPay::Client::Api::Store) }
|
||||
it { expect(subject.store.invoices).to be_a(BtcPay::Client::Api::StoreInvoices) }
|
||||
it { expect(subject.store.payment_requests).to be_a(BtcPay::Client::Api::StorePaymentRequests) }
|
||||
it { expect(subject.store.payouts).to be_a(BtcPay::Client::Api::StorePayouts) }
|
||||
it { expect(subject.store.pull_payments).to be_a(BtcPay::Client::Api::StorePullPayments) }
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :store_invoices_payload, class: Hash do
|
||||
amount { SecureRandom.rand(0.0000..0.10000) }
|
||||
currency { 'btc' }
|
||||
metadata { { orderId: 12_345 } }
|
||||
checkout do
|
||||
{
|
||||
speedPolicy: 'HighSpeed',
|
||||
paymentMethods: ['BTC'],
|
||||
expirationMinutes: 15,
|
||||
monitoringMinutes: 1440,
|
||||
paymentTolerance: 0
|
||||
}
|
||||
end
|
||||
|
||||
initialize_with { attributes }
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue