From d3c5e2a2e7ea03d8eb0ea8f4cec532fdbdd2a1ca Mon Sep 17 00:00:00 2001 From: snogrammer Date: Sat, 21 Nov 2020 14:51:14 -0700 Subject: [PATCH] v0.1.2 (#1) add store invoice specs. update readme. add store invoice endpoints. update repo info, docker images. add store_id to config. Co-authored-by: snogrammer Reviewed-on: https://code.snogrammer.com/snogrammer/btcpay/pulls/1 --- Gemfile.lock | 2 +- README.md | 9 ++++ btcpay.gemspec | 6 +-- docker-compose.btcpay.yml | 8 +-- lib/btcpay/client/api/base.rb | 1 + lib/btcpay/client/api/store.rb | 4 ++ lib/btcpay/client/api/store_invoices.rb | 54 +++++++++++++++++++ lib/btcpay/client/config.rb | 6 ++- lib/btcpay/version.rb | 2 +- spec/btcpay_spec.rb | 2 +- .../DELETE_delete/1_4_1.yml | 45 ++++++++++++++++ .../GET_all/1_1_1.yml | 47 ++++++++++++++++ .../GET_get/1_3_1.yml | 47 ++++++++++++++++ .../POST_create/1_2_1.yml | 49 +++++++++++++++++ .../POST_unarchive/1_6_1.yml | 49 +++++++++++++++++ .../POST_update_status/1_5_1.yml | 49 +++++++++++++++++ spec/client/api/store_invoices_spec.rb | 51 ++++++++++++++++++ spec/client/base_spec.rb | 1 + spec/factories/api/store_invoices.rb | 20 +++++++ 19 files changed, 440 insertions(+), 12 deletions(-) create mode 100644 lib/btcpay/client/api/store_invoices.rb create mode 100644 spec/cassettes/BtcPay_Client_Api_StoreInvoices/DELETE_delete/1_4_1.yml create mode 100644 spec/cassettes/BtcPay_Client_Api_StoreInvoices/GET_all/1_1_1.yml create mode 100644 spec/cassettes/BtcPay_Client_Api_StoreInvoices/GET_get/1_3_1.yml create mode 100644 spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_create/1_2_1.yml create mode 100644 spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_unarchive/1_6_1.yml create mode 100644 spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_update_status/1_5_1.yml create mode 100644 spec/client/api/store_invoices_spec.rb create mode 100644 spec/factories/api/store_invoices.rb diff --git a/Gemfile.lock b/Gemfile.lock index a3ee642..8a8696f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - btcpay (0.1.0) + btcpay (0.1.2) activesupport (> 5) multi_json (~> 1.15) rest-client (~> 2.1) diff --git a/README.md b/README.md index 779d359..cdb8b5e 100644 --- a/README.md +++ b/README.md @@ -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)` diff --git a/btcpay.gemspec b/btcpay.gemspec index 3cd1d5c..41dfffd 100644 --- a/btcpay.gemspec +++ b/btcpay.gemspec @@ -2,7 +2,7 @@ require_relative 'lib/btcpay/version' -Gem::Specification.new do |spec| +Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength spec.name = 'btcpay' spec.version = BtcPay::VERSION spec.authors = ['snogrammer'] @@ -14,8 +14,8 @@ Gem::Specification.new do |spec| spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0') spec.metadata['homepage_uri'] = spec.homepage - spec.metadata['source_code_uri'] = 'https://gitlab.com/snogrammer/btcpay' - spec.metadata['changelog_uri'] = 'https://gitlab.com/snogrammer/btcpay/CHANGELOG.md' + spec.metadata['source_code_uri'] = 'https://code.snogrammer.com/snogrammer/btcpay' + spec.metadata['changelog_uri'] = "#{spec.metadata['source_code_uri']}/CHANGELOG.md" # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. diff --git a/docker-compose.btcpay.yml b/docker-compose.btcpay.yml index 53de336..7355d2c 100644 --- a/docker-compose.btcpay.yml +++ b/docker-compose.btcpay.yml @@ -5,7 +5,7 @@ services: bitcoind: container_name: bitcoind restart: unless-stopped - image: btcpayserver/bitcoin:0.19.0.1 + image: btcpayserver/bitcoin:0.20.1 environment: BITCOIN_NETWORK: regtest BITCOIN_EXTRA_ARGS: | @@ -31,7 +31,7 @@ services: nbxplorer: container_name: nbxplorer restart: unless-stopped - image: nicolasdorier/nbxplorer:2.1.34 + image: nicolasdorier/nbxplorer:2.1.46 ports: - "32838:32838" environment: @@ -53,7 +53,7 @@ services: btcpay: container_name: btcpay restart: unless-stopped - image: btcpayserver/btcpayserver:1.0.5.2 + image: btcpayserver/btcpayserver:1.0.5.9 ports: - "49392:49392" environment: @@ -118,7 +118,7 @@ services: btcpay_db: container_name: btcpay_db restart: unless-stopped - image: postgres:11.5-alpine + image: postgres:13-alpine environment: POSTGRES_USER: user POSTGRES_PASSWORD: password diff --git a/lib/btcpay/client/api/base.rb b/lib/btcpay/client/api/base.rb index 6f383e4..557bd12 100644 --- a/lib/btcpay/client/api/base.rb +++ b/lib/btcpay/client/api/base.rb @@ -12,6 +12,7 @@ module BtcPay require_relative './pull_payments' require_relative './server' require_relative './store' + require_relative './store_invoices' require_relative './store_payment_requests' require_relative './store_payouts' require_relative './store_pull_payments' diff --git a/lib/btcpay/client/api/store.rb b/lib/btcpay/client/api/store.rb index cdf5661..ff63eeb 100644 --- a/lib/btcpay/client/api/store.rb +++ b/lib/btcpay/client/api/store.rb @@ -39,6 +39,10 @@ module BtcPay ## # services ## + def invoices + @invoices ||= Api::StoreInvoices.new(client: client) + end + def payment_requests @payment_requests ||= Api::StorePaymentRequests.new(client: client) end diff --git a/lib/btcpay/client/api/store_invoices.rb b/lib/btcpay/client/api/store_invoices.rb new file mode 100644 index 0000000..9de5589 --- /dev/null +++ b/lib/btcpay/client/api/store_invoices.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module BtcPay + module Client + module Api + class StoreInvoices < Base + PATH = '/stores/:store_id/invoices' + + # @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_GetInvoices + def all(store_id, **opts) + client.get(store_path(store_id), options: opts) + end + + alias index all + + # @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_CreateInvoice + def create(store_id, payload, **opts) + client.post(store_path(store_id), payload: payload, options: opts) + end + + # @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_GetInvoice + def get(store_id, invoice_id, **opts) + client.get(store_path(store_id, invoice_id), options: opts) + end + + alias find get + + # @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_ArchiveInvoice + def delete(store_id, invoice_id, **opts) + client.delete(store_path(store_id, invoice_id), options: opts) + end + + alias archive delete + + # @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_MarkInvoiceStatus + # @see https://github.com/btcpayserver/btcpayserver/blob/master/BTCPayServer.Client/Models/InvoiceStatus.cs + def update_status(store_id, invoice_id, status = 'Complete', **opts) + client.post(store_path(store_id, invoice_id, 'status'), payload: { status: status }, options: opts) + end + + # @see https://docs.btcpayserver.org/API/Greenfield/v1/#operation/Invoices_UnarchiveInvoice + def unarchive(store_id, invoice_id, **opts) + client.post(store_path(store_id, invoice_id, 'unarchive'), payload: {}, options: opts) + end + + protected + + def set_base_path + @base_path = PATH.dup + end + end + end + end +end diff --git a/lib/btcpay/client/config.rb b/lib/btcpay/client/config.rb index 707a431..6cf5bfe 100644 --- a/lib/btcpay/client/config.rb +++ b/lib/btcpay/client/config.rb @@ -6,11 +6,12 @@ module BtcPay AUTH_TOKEN_TYPE = 'token' BASIC_TOKEN_TYPE = 'Basic' - attr_reader :authorization, :auth_token, :basic_auth_token, :base_url, :user_agent + attr_reader :authorization, :auth_token, :basic_auth_token, :base_url, :user_agent, :store_id def initialize(**kwargs) @base_url = load_url(kwargs[:base_url]) @user_agent = kwargs[:user_agent] || "btcpay_ruby/#{BtcPay::VERSION}" + @store_id = kwargs[:store_id] load_auth_token(kwargs) set_authorization @@ -21,7 +22,8 @@ module BtcPay auth_token: auth_token, basic_auth_token: basic_auth_token, base_url: base_url, - user_agent: user_agent + user_agent: user_agent, + store_id: store_id }.compact end diff --git a/lib/btcpay/version.rb b/lib/btcpay/version.rb index bbe83c5..02a22ea 100644 --- a/lib/btcpay/version.rb +++ b/lib/btcpay/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module BtcPay - VERSION = '0.1.1' + VERSION = '0.1.2' end diff --git a/spec/btcpay_spec.rb b/spec/btcpay_spec.rb index 2e55dfb..717968f 100644 --- a/spec/btcpay_spec.rb +++ b/spec/btcpay_spec.rb @@ -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 diff --git a/spec/cassettes/BtcPay_Client_Api_StoreInvoices/DELETE_delete/1_4_1.yml b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/DELETE_delete/1_4_1.yml new file mode 100644 index 0000000..8d6577b --- /dev/null +++ b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/DELETE_delete/1_4_1.yml @@ -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 diff --git a/spec/cassettes/BtcPay_Client_Api_StoreInvoices/GET_all/1_1_1.yml b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/GET_all/1_1_1.yml new file mode 100644 index 0000000..3bc15f9 --- /dev/null +++ b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/GET_all/1_1_1.yml @@ -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 diff --git a/spec/cassettes/BtcPay_Client_Api_StoreInvoices/GET_get/1_3_1.yml b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/GET_get/1_3_1.yml new file mode 100644 index 0000000..a69024d --- /dev/null +++ b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/GET_get/1_3_1.yml @@ -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 diff --git a/spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_create/1_2_1.yml b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_create/1_2_1.yml new file mode 100644 index 0000000..8b2676b --- /dev/null +++ b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_create/1_2_1.yml @@ -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 diff --git a/spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_unarchive/1_6_1.yml b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_unarchive/1_6_1.yml new file mode 100644 index 0000000..1edf1a9 --- /dev/null +++ b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_unarchive/1_6_1.yml @@ -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 diff --git a/spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_update_status/1_5_1.yml b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_update_status/1_5_1.yml new file mode 100644 index 0000000..777d092 --- /dev/null +++ b/spec/cassettes/BtcPay_Client_Api_StoreInvoices/POST_update_status/1_5_1.yml @@ -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 diff --git a/spec/client/api/store_invoices_spec.rb b/spec/client/api/store_invoices_spec.rb new file mode 100644 index 0000000..41a8eee --- /dev/null +++ b/spec/client/api/store_invoices_spec.rb @@ -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 diff --git a/spec/client/base_spec.rb b/spec/client/base_spec.rb index 073dff7..e43fe3c 100644 --- a/spec/client/base_spec.rb +++ b/spec/client/base_spec.rb @@ -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) } diff --git a/spec/factories/api/store_invoices.rb b/spec/factories/api/store_invoices.rb new file mode 100644 index 0000000..e01ae44 --- /dev/null +++ b/spec/factories/api/store_invoices.rb @@ -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