subfi_pay 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +101 -0
  4. data/README.md +188 -0
  5. data/Rakefile +10 -0
  6. data/bin/console +11 -0
  7. data/docs/AccessKey.md +32 -0
  8. data/docs/AccessKeysApi.md +228 -0
  9. data/docs/AccountAttributes.md +20 -0
  10. data/docs/AccountAttributesAccount.md +20 -0
  11. data/docs/AccountCreateRequest.md +18 -0
  12. data/docs/AccountResponse.md +26 -0
  13. data/docs/AccountsApi.md +227 -0
  14. data/docs/BalanceTransactionAttributes.md +30 -0
  15. data/docs/BalanceTransactionResponse.md +38 -0
  16. data/docs/BalanceTransactionsApi.md +87 -0
  17. data/docs/BankAccountProfile.md +28 -0
  18. data/docs/BillingAddress.md +36 -0
  19. data/docs/CardProfile.md +42 -0
  20. data/docs/ChargeAttributes.md +26 -0
  21. data/docs/ChargeResponse.md +42 -0
  22. data/docs/ChargesApi.md +167 -0
  23. data/docs/ConnectedAccountAttributes.md +20 -0
  24. data/docs/ConnectedAccountResponse.md +26 -0
  25. data/docs/CreateAccountRequest.md +18 -0
  26. data/docs/CreateAccountRequestAccount.md +20 -0
  27. data/docs/CreateCustomerRequest.md +24 -0
  28. data/docs/CreateWebhookEndpointRequest.md +18 -0
  29. data/docs/CreateWebhookEndpointRequestWebhookEndpoint.md +28 -0
  30. data/docs/Customer.md +26 -0
  31. data/docs/CustomerAttributes.md +24 -0
  32. data/docs/CustomerAttributesCustomer.md +24 -0
  33. data/docs/CustomerCreateRequest.md +18 -0
  34. data/docs/CustomerUpdateAttributes.md +20 -0
  35. data/docs/CustomerUpdateAttributesCustomer.md +20 -0
  36. data/docs/CustomerUpdateRequest.md +18 -0
  37. data/docs/CustomersApi.md +307 -0
  38. data/docs/Event.md +30 -0
  39. data/docs/EventsApi.md +159 -0
  40. data/docs/ListAccessKeysResponse.md +20 -0
  41. data/docs/ListAccountsResponse.md +20 -0
  42. data/docs/ListBalanceTransactionsResponse.md +20 -0
  43. data/docs/ListChargesResponse.md +20 -0
  44. data/docs/ListCustomersResponse.md +20 -0
  45. data/docs/ListEventsResponse.md +20 -0
  46. data/docs/ListPaymentIntentsResponse.md +20 -0
  47. data/docs/ListPaymentMethodsResponse.md +20 -0
  48. data/docs/ListRefundsResponse.md +20 -0
  49. data/docs/ListWebhookEndpointsResponse.md +20 -0
  50. data/docs/ListWebhookRequestsResponse.md +20 -0
  51. data/docs/Meta.md +28 -0
  52. data/docs/PaymentIntentAttributes.md +26 -0
  53. data/docs/PaymentIntentAttributesPaymentIntent.md +26 -0
  54. data/docs/PaymentIntentCreateRequest.md +18 -0
  55. data/docs/PaymentIntentResponse.md +30 -0
  56. data/docs/PaymentIntentUpdateAttributes.md +18 -0
  57. data/docs/PaymentIntentUpdateAttributesPaymentIntent.md +18 -0
  58. data/docs/PaymentIntentsApi.md +533 -0
  59. data/docs/PaymentMethodAttributes.md +24 -0
  60. data/docs/PaymentMethodResponse.md +36 -0
  61. data/docs/PaymentMethodsApi.md +239 -0
  62. data/docs/RefundAttributes.md +20 -0
  63. data/docs/RefundResponse.md +30 -0
  64. data/docs/RefundsApi.md +311 -0
  65. data/docs/RollAccessKeyAttributes.md +18 -0
  66. data/docs/RollAccessKeyAttributesAccessKey.md +18 -0
  67. data/docs/RollAccessKeyRequest.md +18 -0
  68. data/docs/RollAccessKeyRequestAccessKey.md +18 -0
  69. data/docs/SubscriptionAttributes.md +30 -0
  70. data/docs/SubscriptionAttributesSubscription.md +30 -0
  71. data/docs/SubscriptionCreateRequest.md +18 -0
  72. data/docs/SubscriptionCreateRequestSubscription.md +30 -0
  73. data/docs/SubscriptionResponse.md +36 -0
  74. data/docs/SubscriptionsApi.md +155 -0
  75. data/docs/WebhookEndpoint.md +34 -0
  76. data/docs/WebhookEndpointsApi.md +380 -0
  77. data/docs/WebhookRequest.md +38 -0
  78. data/docs/WebhookRequestsApi.md +85 -0
  79. data/git_push.sh +57 -0
  80. data/lib/subfi_pay/api/access_keys_api.rb +235 -0
  81. data/lib/subfi_pay/api/accounts_api.rb +231 -0
  82. data/lib/subfi_pay/api/balance_transactions_api.rb +100 -0
  83. data/lib/subfi_pay/api/charges_api.rb +181 -0
  84. data/lib/subfi_pay/api/customers_api.rb +331 -0
  85. data/lib/subfi_pay/api/events_api.rb +172 -0
  86. data/lib/subfi_pay/api/payment_intents_api.rb +566 -0
  87. data/lib/subfi_pay/api/payment_methods_api.rb +262 -0
  88. data/lib/subfi_pay/api/refunds_api.rb +334 -0
  89. data/lib/subfi_pay/api/subscriptions_api.rb +177 -0
  90. data/lib/subfi_pay/api/webhook_endpoints_api.rb +404 -0
  91. data/lib/subfi_pay/api/webhook_requests_api.rb +97 -0
  92. data/lib/subfi_pay/api_client.rb +394 -0
  93. data/lib/subfi_pay/api_error.rb +58 -0
  94. data/lib/subfi_pay/configuration.rb +305 -0
  95. data/lib/subfi_pay/models/access_key.rb +275 -0
  96. data/lib/subfi_pay/models/account_attributes.rb +221 -0
  97. data/lib/subfi_pay/models/account_attributes_account.rb +221 -0
  98. data/lib/subfi_pay/models/account_create_request.rb +212 -0
  99. data/lib/subfi_pay/models/account_response.rb +248 -0
  100. data/lib/subfi_pay/models/balance_transaction_attributes.rb +266 -0
  101. data/lib/subfi_pay/models/balance_transaction_response.rb +303 -0
  102. data/lib/subfi_pay/models/bank_account_profile.rb +257 -0
  103. data/lib/subfi_pay/models/billing_address.rb +294 -0
  104. data/lib/subfi_pay/models/card_profile.rb +324 -0
  105. data/lib/subfi_pay/models/charge_attributes.rb +265 -0
  106. data/lib/subfi_pay/models/charge_response.rb +326 -0
  107. data/lib/subfi_pay/models/connected_account_attributes.rb +235 -0
  108. data/lib/subfi_pay/models/connected_account_response.rb +248 -0
  109. data/lib/subfi_pay/models/create_account_request.rb +219 -0
  110. data/lib/subfi_pay/models/create_account_request_account.rb +221 -0
  111. data/lib/subfi_pay/models/create_customer_request.rb +239 -0
  112. data/lib/subfi_pay/models/create_webhook_endpoint_request.rb +212 -0
  113. data/lib/subfi_pay/models/create_webhook_endpoint_request_webhook_endpoint.rb +257 -0
  114. data/lib/subfi_pay/models/customer.rb +248 -0
  115. data/lib/subfi_pay/models/customer_attributes.rb +239 -0
  116. data/lib/subfi_pay/models/customer_attributes_customer.rb +239 -0
  117. data/lib/subfi_pay/models/customer_create_request.rb +212 -0
  118. data/lib/subfi_pay/models/customer_update_attributes.rb +221 -0
  119. data/lib/subfi_pay/models/customer_update_attributes_customer.rb +221 -0
  120. data/lib/subfi_pay/models/customer_update_request.rb +212 -0
  121. data/lib/subfi_pay/models/event.rb +266 -0
  122. data/lib/subfi_pay/models/list_access_keys_response.rb +223 -0
  123. data/lib/subfi_pay/models/list_accounts_response.rb +223 -0
  124. data/lib/subfi_pay/models/list_balance_transactions_response.rb +223 -0
  125. data/lib/subfi_pay/models/list_charges_response.rb +223 -0
  126. data/lib/subfi_pay/models/list_customers_response.rb +223 -0
  127. data/lib/subfi_pay/models/list_events_response.rb +223 -0
  128. data/lib/subfi_pay/models/list_payment_intents_response.rb +223 -0
  129. data/lib/subfi_pay/models/list_payment_methods_response.rb +223 -0
  130. data/lib/subfi_pay/models/list_refunds_response.rb +223 -0
  131. data/lib/subfi_pay/models/list_webhook_endpoints_response.rb +223 -0
  132. data/lib/subfi_pay/models/list_webhook_requests_response.rb +223 -0
  133. data/lib/subfi_pay/models/meta.rb +259 -0
  134. data/lib/subfi_pay/models/payment_intent_attributes.rb +257 -0
  135. data/lib/subfi_pay/models/payment_intent_attributes_payment_intent.rb +257 -0
  136. data/lib/subfi_pay/models/payment_intent_create_request.rb +212 -0
  137. data/lib/subfi_pay/models/payment_intent_response.rb +268 -0
  138. data/lib/subfi_pay/models/payment_intent_update_attributes.rb +212 -0
  139. data/lib/subfi_pay/models/payment_intent_update_attributes_payment_intent.rb +214 -0
  140. data/lib/subfi_pay/models/payment_method_attributes.rb +246 -0
  141. data/lib/subfi_pay/models/payment_method_response.rb +296 -0
  142. data/lib/subfi_pay/models/refund_attributes.rb +228 -0
  143. data/lib/subfi_pay/models/refund_response.rb +268 -0
  144. data/lib/subfi_pay/models/roll_access_key_attributes.rb +212 -0
  145. data/lib/subfi_pay/models/roll_access_key_attributes_access_key.rb +219 -0
  146. data/lib/subfi_pay/models/roll_access_key_request.rb +212 -0
  147. data/lib/subfi_pay/models/roll_access_key_request_access_key.rb +219 -0
  148. data/lib/subfi_pay/models/subscription_attributes.rb +266 -0
  149. data/lib/subfi_pay/models/subscription_attributes_subscription.rb +266 -0
  150. data/lib/subfi_pay/models/subscription_create_request.rb +212 -0
  151. data/lib/subfi_pay/models/subscription_create_request_subscription.rb +266 -0
  152. data/lib/subfi_pay/models/subscription_response.rb +293 -0
  153. data/lib/subfi_pay/models/webhook_endpoint.rb +284 -0
  154. data/lib/subfi_pay/models/webhook_request.rb +302 -0
  155. data/lib/subfi_pay/version.rb +15 -0
  156. data/lib/subfi_pay.rb +99 -0
  157. data/run_fix_gemfile.sh +11 -0
  158. data/spec/api/access_keys_api_spec.rb +138 -0
  159. data/spec/api/accounts_api_spec.rb +145 -0
  160. data/spec/api/balance_transactions_api_spec.rb +86 -0
  161. data/spec/api/charges_api_spec.rb +121 -0
  162. data/spec/api/customers_api_spec.rb +134 -0
  163. data/spec/api/events_api_spec.rb +105 -0
  164. data/spec/api/payment_intents_api_spec.rb +250 -0
  165. data/spec/api/payment_methods_api_spec.rb +226 -0
  166. data/spec/api/refunds_api_spec.rb +158 -0
  167. data/spec/api/subscriptions_api_spec.rb +113 -0
  168. data/spec/api/webhook_endpoints_api_spec.rb +198 -0
  169. data/spec/api/webhook_requests_api_spec.rb +79 -0
  170. data/spec/configuration_spec.rb +23 -0
  171. data/spec/fixtures/access_keys/list_200.json +1 -0
  172. data/spec/fixtures/access_keys/roll_200.json +1 -0
  173. data/spec/fixtures/accounts/create_201.json +1 -0
  174. data/spec/fixtures/accounts/list_200.json +1 -0
  175. data/spec/fixtures/accounts/show_200.json +1 -0
  176. data/spec/fixtures/balance_transactions/list_200.json +69 -0
  177. data/spec/fixtures/charges/create_201.json +39 -0
  178. data/spec/fixtures/charges/list_200.json +1 -0
  179. data/spec/fixtures/charges/retrieve_200.json +1 -0
  180. data/spec/fixtures/customers/create_201.json +1 -0
  181. data/spec/fixtures/customers/list_200.json +1 -0
  182. data/spec/fixtures/customers/show_200.json +1 -0
  183. data/spec/fixtures/events/list_200.json +1 -0
  184. data/spec/fixtures/events/show_200.json +1 -0
  185. data/spec/fixtures/payment_intents/cancel_200.json +1 -0
  186. data/spec/fixtures/payment_intents/capture_200.json +1 -0
  187. data/spec/fixtures/payment_intents/confirm_200.json +1 -0
  188. data/spec/fixtures/payment_intents/create_201.json +1 -0
  189. data/spec/fixtures/payment_intents/fetch_200.json +1 -0
  190. data/spec/fixtures/payment_intents/list_200.json +1 -0
  191. data/spec/fixtures/payment_intents/update_200.json +1 -0
  192. data/spec/fixtures/payment_methods/create_bank_account_201.json +1 -0
  193. data/spec/fixtures/payment_methods/create_card_201.json +1 -0
  194. data/spec/fixtures/payment_methods/get_bank_account_200.json +29 -0
  195. data/spec/fixtures/payment_methods/get_card_200.json +1 -0
  196. data/spec/fixtures/payment_methods/list_200.json +1 -0
  197. data/spec/fixtures/refunds/create_201.json +1 -0
  198. data/spec/fixtures/refunds/list_200.json +1 -0
  199. data/spec/fixtures/refunds/show_200.json +1 -0
  200. data/spec/fixtures/subscriptions/create_201.json +1 -0
  201. data/spec/fixtures/subscriptions/show_200.json +1 -0
  202. data/spec/fixtures/webhook_endpoints/create_201.json +11 -0
  203. data/spec/fixtures/webhook_endpoints/list_200.json +1 -0
  204. data/spec/fixtures/webhook_endpoints/show_200.json +1 -0
  205. data/spec/fixtures/webhook_endpoints/update_200.json +13 -0
  206. data/spec/fixtures/webhook_requests/list_200.json +1 -0
  207. data/spec/models/access_key_spec.rb +39 -0
  208. data/spec/models/account_attributes_spec.rb +40 -0
  209. data/spec/models/account_create_request_spec.rb +38 -0
  210. data/spec/models/account_response_spec.rb +39 -0
  211. data/spec/models/balance_transaction_response_spec.rb +38 -0
  212. data/spec/models/bank_account_profile_spec.rb +38 -0
  213. data/spec/models/billing_address_spec.rb +38 -0
  214. data/spec/models/card_profile_spec.rb +38 -0
  215. data/spec/models/charge_attributes_spec.rb +45 -0
  216. data/spec/models/charge_response_spec.rb +45 -0
  217. data/spec/models/connected_account_attributes_spec.rb +38 -0
  218. data/spec/models/connected_account_response_spec.rb +39 -0
  219. data/spec/models/create_account_request_account_spec.rb +39 -0
  220. data/spec/models/create_account_request_spec.rb +39 -0
  221. data/spec/models/create_webhook_endpoint_request_spec.rb +38 -0
  222. data/spec/models/create_webhook_endpoint_request_webhook_endpoint_spec.rb +38 -0
  223. data/spec/models/customer_attributes_spec.rb +40 -0
  224. data/spec/models/customer_create_request_spec.rb +38 -0
  225. data/spec/models/customer_spec.rb +39 -0
  226. data/spec/models/customer_update_attributes_spec.rb +39 -0
  227. data/spec/models/customer_update_request_spec.rb +39 -0
  228. data/spec/models/event_spec.rb +39 -0
  229. data/spec/models/list_access_keys_response_spec.rb +38 -0
  230. data/spec/models/list_accounts_response_spec.rb +38 -0
  231. data/spec/models/list_balance_transactions_response_spec.rb +38 -0
  232. data/spec/models/list_charges_response_spec.rb +38 -0
  233. data/spec/models/list_customers_response_spec.rb +39 -0
  234. data/spec/models/list_events_response_spec.rb +38 -0
  235. data/spec/models/list_payment_intents_response_spec.rb +45 -0
  236. data/spec/models/list_payment_methods_response_spec.rb +39 -0
  237. data/spec/models/list_refunds_response_spec.rb +38 -0
  238. data/spec/models/list_webhook_endpoints_response_spec.rb +38 -0
  239. data/spec/models/list_webhook_requests_response_spec.rb +39 -0
  240. data/spec/models/meta_spec.rb +38 -0
  241. data/spec/models/payment_intent_attributes_spec.rb +44 -0
  242. data/spec/models/payment_intent_create_request_spec.rb +38 -0
  243. data/spec/models/payment_intent_response_spec.rb +45 -0
  244. data/spec/models/payment_intent_update_attributes_payment_intent_spec.rb +38 -0
  245. data/spec/models/payment_intent_update_attributes_spec.rb +37 -0
  246. data/spec/models/payment_method_attributes_spec.rb +38 -0
  247. data/spec/models/payment_method_response_spec.rb +38 -0
  248. data/spec/models/refund_attributes_spec.rb +39 -0
  249. data/spec/models/refund_response_spec.rb +38 -0
  250. data/spec/models/roll_access_key_attributes_access_key_spec.rb +39 -0
  251. data/spec/models/roll_access_key_attributes_spec.rb +40 -0
  252. data/spec/models/roll_access_key_request_access_key_spec.rb +38 -0
  253. data/spec/models/roll_access_key_request_spec.rb +37 -0
  254. data/spec/models/subscription_attributes_spec.rb +38 -0
  255. data/spec/models/subscription_create_request_spec.rb +40 -0
  256. data/spec/models/subscription_response_spec.rb +38 -0
  257. data/spec/models/webhook_endpoint_spec.rb +40 -0
  258. data/spec/models/webhook_request_spec.rb +40 -0
  259. data/spec/spec_helper.rb +123 -0
  260. data/subfi_pay.gemspec +39 -0
  261. metadata +444 -0
@@ -0,0 +1,250 @@
1
+ =begin
2
+ #SubFi Pay API
3
+
4
+ #API for SubFi Pay services
5
+
6
+ The version of the OpenAPI document: 0.1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.7.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for SubFiPay::PaymentIntentsApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'PaymentIntentsApi' do
20
+ let(:api_instance) { SubFiPay::PaymentIntentsApi.new }
21
+ let(:api_key) { Faker::Alphanumeric.alphanumeric(number: 32) }
22
+ let(:api_version) { "0.1.0" }
23
+ let(:account_id) { Faker::Alphanumeric.alphanumeric(number: 32) }
24
+ let(:config) do
25
+ api_instance.api_client.config.tap do |c|
26
+ c.api_key['ApiKeyAuth'] = api_key
27
+ c.host = "localhost:3000"
28
+ c.scheme = "http"
29
+ end
30
+ end
31
+ let(:path) { "/payment_intents" }
32
+ let(:request_headers) do
33
+ {
34
+ 'Accept' => 'application/json',
35
+ "Content-Type" => "application/json",
36
+ 'X-Api-Version' => api_version,
37
+ 'X-Api-Key' => api_key
38
+ }
39
+ end
40
+ let(:response_headers) do
41
+ {
42
+ 'Accept' => 'application/json',
43
+ "Content-Type" => "application/json"
44
+ }
45
+ end
46
+
47
+ describe 'test an instance of PaymentIntentsApi' do
48
+ it 'should create an instance of PaymentIntentsApi' do
49
+ expect(api_instance).to be_instance_of(SubFiPay::PaymentIntentsApi)
50
+ end
51
+ end
52
+
53
+ # unit tests for confirm_payment_intent
54
+ # Confirm a payment intent
55
+ # @param x_api_version
56
+ # @param id The ID of the payment intent to confirm
57
+ # @param [Hash] opts the optional parameters
58
+ # @return [PaymentIntentResponse]
59
+ describe 'confirm_payment_intent test' do
60
+ let(:payment_intent_id) { Faker::Alphanumeric.alphanumeric(number: 32) }
61
+
62
+ before do
63
+ stub_request(:post, [config.host, "#{path}/#{payment_intent_id}/confirm"].join)
64
+ .with(headers: request_headers)
65
+ .to_return(
66
+ status: 200,
67
+ body: fixture("payment_intents/confirm_200.json"),
68
+ headers: response_headers
69
+ )
70
+ end
71
+
72
+ it 'should work' do
73
+ res = api_instance.confirm_payment_intent(api_version, account_id, payment_intent_id)
74
+
75
+ expect(res).to be_instance_of(SubFiPay::PaymentIntentResponse)
76
+ end
77
+ end
78
+
79
+ # unit tests for capture_payment_intent
80
+ # Capture a payment intent
81
+ # @param x_api_version
82
+ # @param id The ID of the payment intent to capture
83
+ # @param [Hash] opts the optional parameters
84
+ # @return [PaymentIntentResponse]
85
+ describe 'capture_payment_intent test' do
86
+ let(:payment_intent_id) { Faker::Alphanumeric.alphanumeric(number: 32) }
87
+
88
+ before do
89
+ stub_request(:post, [config.host, "#{path}/#{payment_intent_id}/capture"].join)
90
+ .with(headers: request_headers)
91
+ .to_return(
92
+ status: 200,
93
+ body: fixture("payment_intents/capture_200.json"),
94
+ headers: response_headers
95
+ )
96
+ end
97
+
98
+ it 'should work' do
99
+ res = api_instance.capture_payment_intent(api_version, account_id, payment_intent_id)
100
+
101
+ expect(res).to be_instance_of(SubFiPay::PaymentIntentResponse)
102
+ end
103
+ end
104
+
105
+ # unit tests for cancel_payment_intent
106
+ # Cancel a payment intent
107
+ # @param x_api_version
108
+ # @param id The ID of the payment intent to cancel
109
+ # @param [Hash] opts the optional parameters
110
+ # @return [PaymentIntentResponse]
111
+ describe 'cancel_payment_intent test' do
112
+ let(:payment_intent_id) { Faker::Alphanumeric.alphanumeric(number: 32) }
113
+
114
+ before do
115
+ stub_request(:post, [config.host, "#{path}/#{payment_intent_id}/cancel"].join)
116
+ .with(headers: request_headers)
117
+ .to_return(
118
+ status: 200,
119
+ body: fixture("payment_intents/cancel_200.json"),
120
+ headers: response_headers
121
+ )
122
+ end
123
+
124
+ it 'should work' do
125
+ res = api_instance.cancel_payment_intent(api_version, account_id, payment_intent_id)
126
+
127
+ expect(res).to be_instance_of(SubFiPay::PaymentIntentResponse)
128
+ end
129
+ end
130
+
131
+ # unit tests for create_payment_intent
132
+ # Create a new payment intent
133
+ # @param x_api_version
134
+ # @param payment_intent_attributes
135
+ # @param [Hash] opts the optional parameters
136
+ # @return [PaymentIntentResponse]
137
+ describe 'create_payment_intent test' do
138
+ let(:body) do
139
+ {
140
+ payment_intent: {
141
+ amount: Faker::Number.number(digits: 4),
142
+ capture_async: false
143
+ }
144
+ }
145
+ end
146
+
147
+ before do
148
+ stub_request(:post, [config.host, path].join)
149
+ .with(headers: request_headers)
150
+ .to_return(
151
+ status: 200,
152
+ body: fixture("payment_intents/create_201.json"),
153
+ headers: response_headers
154
+ )
155
+ end
156
+
157
+ it 'should work' do
158
+ res = api_instance.create_payment_intent(api_version, account_id, body)
159
+
160
+ expect(res).to be_instance_of(SubFiPay::PaymentIntentResponse)
161
+ end
162
+ end
163
+
164
+ # unit tests for get_payment_intent
165
+ # Retrieve a payment intent by ID
166
+ # @param x_api_version
167
+ # @param id The ID of the payment intent to retrieve
168
+ # @param [Hash] opts the optional parameters
169
+ # @return [PaymentIntentResponse]
170
+ describe 'get_payment_intent test' do
171
+ let(:payment_intent_id) { Faker::Alphanumeric.alphanumeric(number: 32) }
172
+
173
+ before do
174
+ stub_request(:get, [config.host, "#{path}/#{payment_intent_id}"].join)
175
+ .with(headers: request_headers)
176
+ .to_return(
177
+ status: 200,
178
+ body: fixture("payment_intents/fetch_200.json"),
179
+ headers: response_headers
180
+ )
181
+ end
182
+
183
+ it 'should work' do
184
+ res = api_instance.get_payment_intent(api_version, account_id, payment_intent_id)
185
+
186
+ expect(res).to be_instance_of(SubFiPay::PaymentIntentResponse)
187
+ end
188
+ end
189
+
190
+ # unit tests for list_payment_intents
191
+ # List payment intents
192
+ # @param x_api_version
193
+ # @param [Hash] opts the optional parameters
194
+ # @option opts [Integer] :page The page of results to retrieve.
195
+ # @option opts [Integer] :per_page Number of results per page.
196
+ # @option opts [String] :connected_account_id Filter results by connected_account ID.
197
+ # @return [ListPaymentIntentsResponse]
198
+ describe 'list_payment_intents test' do
199
+ before do
200
+ stub_request(:get, [config.host, path].join)
201
+ .with(headers: request_headers)
202
+ .to_return(
203
+ status: 200,
204
+ body: fixture("payment_intents/list_200.json"),
205
+ headers: response_headers
206
+ )
207
+ end
208
+
209
+ it 'should work' do
210
+ res = api_instance.list_payment_intents(api_version, account_id)
211
+
212
+ expect(res).to be_instance_of(SubFiPay::ListPaymentIntentsResponse)
213
+ end
214
+ end
215
+
216
+ # unit tests for update_payment_intent
217
+ # Update a payment intent
218
+ # @param x_api_version
219
+ # @param id The ID of the payment intent to update
220
+ # @param update_payment_intent_request
221
+ # @param [Hash] opts the optional parameters
222
+ # @return [PaymentIntentResponse]
223
+ describe 'update_payment_intent test' do
224
+ let(:payment_intent_id) { Faker::Alphanumeric.alphanumeric(number: 32) }
225
+
226
+ let(:body) do
227
+ {
228
+ payment_intent: {
229
+ payment_method_ids: %w(1 2 3)
230
+ }
231
+ }
232
+ end
233
+
234
+ before do
235
+ stub_request(:patch, [config.host, "#{path}/#{payment_intent_id}"].join)
236
+ .with(headers: request_headers, body:)
237
+ .to_return(
238
+ status: 200,
239
+ body: fixture("payment_intents/update_200.json"),
240
+ headers: response_headers
241
+ )
242
+ end
243
+
244
+ it 'should work' do
245
+ res = api_instance.update_payment_intent(api_version, account_id, payment_intent_id, body)
246
+
247
+ expect(res).to be_instance_of(SubFiPay::PaymentIntentResponse)
248
+ end
249
+ end
250
+ end
@@ -0,0 +1,226 @@
1
+ =begin
2
+ #SubFi Pay API
3
+
4
+ #API for SubFi Pay services
5
+
6
+ The version of the OpenAPI document: 0.3.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.7.0
10
+
11
+ =end
12
+
13
+ require "spec_helper"
14
+ require "json"
15
+
16
+ # Unit tests for SubFiPay::PaymentMethodsApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe "PaymentMethodsApi" do
20
+ let(:api_instance) { SubFiPay::PaymentMethodsApi.new }
21
+ let(:api_key) { Faker::Alphanumeric.alphanumeric(number: 32) }
22
+ let(:api_version) { "0.1.0" }
23
+ let(:account_id) { Faker::Alphanumeric.alphanumeric(number: 32) }
24
+ let(:config) do
25
+ api_instance.api_client.config.tap do |c|
26
+ c.api_key['ApiKeyAuth'] = api_key
27
+ c.host = "localhost:3000"
28
+ c.scheme = "http"
29
+ end
30
+ end
31
+ let(:access_token) { Faker::Lorem.word }
32
+ let(:path) { "/payment_methods" }
33
+ let(:url) { [config.host, path].join }
34
+ let(:request_headers) do
35
+ {
36
+ 'Accept' => 'application/json',
37
+ "Content-Type" => "application/json",
38
+ 'X-Api-Version' => api_version,
39
+ 'X-Api-Key' => api_key
40
+ }
41
+ end
42
+ let(:response_headers) do
43
+ {
44
+ "Accept" => "application/json",
45
+ "Content-Type" => "application/json"
46
+ }
47
+ end
48
+
49
+ before do
50
+ SubFiPay.configure do |c|
51
+ c.access_token = access_token
52
+ c.host = "localhost:3000"
53
+ c.scheme = "http"
54
+ end
55
+ end
56
+
57
+ describe "test an instance of PaymentMethodsApi" do
58
+ it "should create an instance of PaymentMethodsApi" do
59
+ expect(api_instance).to be_instance_of(SubFiPay::PaymentMethodsApi)
60
+ end
61
+ end
62
+
63
+ # unit tests for payment_methods_id_get
64
+ # Retrieve a payment method
65
+ # @param x_api_version
66
+ # @param content_type
67
+ # @param id
68
+ # @param [Hash] opts the optional parameters
69
+ # @return [PaymentMethod]
70
+ describe "payment_methods_id_get test" do
71
+ let(:id) { SecureRandom.uuid }
72
+
73
+ before do
74
+ stub_request(:get, url + "/#{id}")
75
+ .with(headers: request_headers.merge({ 'X-Account-Id' => account_id }))
76
+ .to_return(
77
+ body: fixture("payment_methods/get_#{type}_200.json"),
78
+ headers: response_headers,
79
+ status: 200
80
+ )
81
+ end
82
+
83
+ context "with card" do
84
+ let(:type) { "card" }
85
+
86
+ it "should work" do
87
+ res = api_instance.get_payment_method(api_version, account_id, id)
88
+
89
+ expect(res).to be_a(SubFiPay::PaymentMethodResponse)
90
+ expect(a_request(:get, url + "/#{id}").with(headers: request_headers)).to have_been_made.once
91
+
92
+ expect(res.billing_address).to be_truthy
93
+ expect(res.card_profile).to be_truthy
94
+ end
95
+ end
96
+
97
+ context "with bank account" do
98
+ let(:type) { "bank_account" }
99
+
100
+ it "should work" do
101
+ res = api_instance.get_payment_method(api_version, account_id, id)
102
+
103
+ expect(res).to be_a(SubFiPay::PaymentMethodResponse)
104
+ expect(a_request(:get, url + "/#{id}").with(headers: request_headers)).to have_been_made.once
105
+
106
+ expect(res.billing_address).to be_truthy
107
+ expect(res.bank_account_profile).to be_truthy
108
+ end
109
+ end
110
+ end
111
+
112
+ # unit tests for list_payment_methods
113
+ # List all payment methods
114
+ # @param x_api_version
115
+ # @param customer_id
116
+ # @param [Hash] opts the optional parameters
117
+ # @return [ListPaymentMethodsResponse]
118
+ describe "#list_payment_methods" do
119
+ let(:customer_id) { SecureRandom.uuid }
120
+ let(:page) { 1 }
121
+ let(:per_page) { 10 }
122
+
123
+ before do
124
+ stub_request(:get, url)
125
+ .with(headers: request_headers, query: { customer_id: customer_id, page: page, per_page: per_page })
126
+ .to_return(
127
+ body: fixture("payment_methods/list_200.json"),
128
+ headers: response_headers.merge({ 'X-Account-Id' => account_id }),
129
+ status: 200
130
+ )
131
+ end
132
+
133
+ it "should work" do
134
+ res = api_instance.list_payment_methods(api_version, account_id, customer_id, { page: page, per_page: per_page })
135
+
136
+ expect(res).to be_a(SubFiPay::ListPaymentMethodsResponse)
137
+ expect(a_request(:get, url).with(query: { customer_id: customer_id, page: page, per_page: per_page }, headers: request_headers)).to have_been_made.once
138
+ end
139
+ end
140
+
141
+ # unit tests for create_payment_method
142
+ # Create a payment method
143
+ # @param x_api_version
144
+ # @param content_type
145
+ # @param payment_methods_post_request
146
+ # @param [Hash] opts the optional parameters
147
+ # @return [PaymentMethod]
148
+ describe "#create_payment_method" do
149
+ context "with card" do
150
+ let(:body) do
151
+ {
152
+ payment_method: {
153
+ type: "Card",
154
+ billing_address_attributes: {
155
+ country: "US",
156
+ postal_code: "78704"
157
+ },
158
+ card_profile_attributes: {
159
+ encrypted_card_number: "3333333333333333",
160
+ exp_month: 1,
161
+ exp_year: 2027,
162
+ cvc: 123
163
+ }
164
+ }
165
+ }
166
+ end
167
+
168
+ before do
169
+ stub_request(:post, url)
170
+ .with(headers: request_headers, body: body.to_json)
171
+ .to_return(
172
+ body: fixture("payment_methods/create_card_201.json"),
173
+ headers: response_headers.merge({ 'X-Account-Id' => account_id }),
174
+ status: 201
175
+ )
176
+ end
177
+
178
+ it "should work" do
179
+ pm = SubFiPay::PaymentMethodAttributes.new(body[:payment_method])
180
+ res = api_instance.create_payment_method(api_version, account_id, { payment_method: pm.to_hash })
181
+
182
+ expect(res).to be_a(SubFiPay::PaymentMethodResponse)
183
+ expect(a_request(:post, url).with(body: body.to_json, headers: request_headers)).to have_been_made.once
184
+ end
185
+ end
186
+
187
+ context "with bank_account" do
188
+ let(:body) do
189
+ {
190
+ payment_method: {
191
+ type: "BankAccount",
192
+ billing_address_attributes: {
193
+ country: "US",
194
+ postal_code: "78704"
195
+ },
196
+ bank_account_profile_attributes: {
197
+ encrypted_account_number: "3333333333333333",
198
+ account_holder_name: "John Doe",
199
+ account_type: "checking",
200
+ routing_number: "012345678",
201
+ bank_name: "Chase"
202
+ }
203
+ }
204
+ }
205
+ end
206
+
207
+ before do
208
+ stub_request(:post, url)
209
+ .with(headers: request_headers, body: body.to_json)
210
+ .to_return(
211
+ body: fixture("payment_methods/create_card_201.json"),
212
+ headers: response_headers,
213
+ status: 201
214
+ )
215
+ end
216
+
217
+ it "should work" do
218
+ pm = SubFiPay::PaymentMethodAttributes.new(body[:payment_method])
219
+ res = api_instance.create_payment_method(api_version, account_id, { payment_method: pm.to_hash })
220
+
221
+ expect(res).to be_a(SubFiPay::PaymentMethodResponse)
222
+ expect(a_request(:post, url).with(body: body.to_json, headers: request_headers)).to have_been_made.once
223
+ end
224
+ end
225
+ end
226
+ end
@@ -0,0 +1,158 @@
1
+ =begin
2
+ #SubFi Pay API
3
+
4
+ #API for SubFi Pay services
5
+
6
+ The version of the OpenAPI document: 0.3.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.7.0
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for SubFiPay::RefundsApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'RefundsApi' do
20
+ let(:api_instance) { SubFiPay::RefundsApi.new }
21
+ let(:account_id) { Faker::Alphanumeric.alphanumeric(number: 32) }
22
+ let(:api_key) { Faker::Alphanumeric.alphanumeric(number: 32) }
23
+ let(:api_version) { "0.1.0" }
24
+ let(:account_id) { Faker::Alphanumeric.alphanumeric(number: 32) }
25
+ let(:config) do
26
+ api_instance.api_client.config.tap do |c|
27
+ c.api_key['ApiKeyAuth'] = api_key
28
+ c.host = "localhost:3000"
29
+ c.scheme = "http"
30
+ end
31
+ end
32
+ let(:path) { "/refunds" }
33
+ let(:request_headers) do
34
+ {
35
+ 'Accept' => 'application/json',
36
+ "Content-Type" => "application/json",
37
+ 'X-Api-Version' => api_version,
38
+ 'X-Api-Key' => api_key
39
+ }
40
+ end
41
+ let(:response_headers) do
42
+ {
43
+ 'Accept' => 'application/json',
44
+ "Content-Type" => "application/json"
45
+ }
46
+ end
47
+
48
+ describe 'test an instance of RefundsApi' do
49
+ it 'should create an instance of RefundsApi' do
50
+ expect(api_instance).to be_instance_of(SubFiPay::RefundsApi)
51
+ end
52
+ end
53
+
54
+ # unit tests for refunds_post
55
+ # Create a refund
56
+ # @param x_api_version
57
+ # @param content_type
58
+ # @param refunds_post_request
59
+ # @param [Hash] opts the optional parameters
60
+ # @return [Refund]
61
+ describe 'refunds_post test' do
62
+ let(:body) do
63
+ {
64
+ refund: {
65
+ amount: 14500,
66
+ charge_id: SecureRandom.uuid
67
+ }
68
+ }
69
+ end
70
+
71
+ before do
72
+ stub_request(:post, [config.host, path].join)
73
+ .with(headers: request_headers, body: body.to_json)
74
+ .to_return(
75
+ body: fixture("refunds/create_201.json"),
76
+ headers: response_headers,
77
+ status: 201
78
+ )
79
+ end
80
+
81
+ it 'should work' do
82
+ res = api_instance.create_refund(api_version, account_id, body)
83
+
84
+ expect(res).to be_a(SubFiPay::RefundResponse)
85
+ expect(a_request(:post, [config.host, path].join).with(headers: request_headers, body: body.to_json)).to have_been_made.once
86
+ end
87
+ end
88
+
89
+ # unit tests for cancel_refund
90
+ # Cancel a refund
91
+ # @param x_api_version
92
+ # @return [Refund]
93
+ describe "cancel_refund" do
94
+ let(:id) { SecureRandom.uuid }
95
+ let(:path) { "/refunds/#{id}/cancel" }
96
+
97
+ before do
98
+ stub_request(:put, [config.host, path].join)
99
+ .with(headers: request_headers)
100
+ .to_return(
101
+ # re-using the same create response since it is the same object.
102
+ body: fixture("refunds/create_201.json"),
103
+ headers: response_headers,
104
+ status: 202
105
+ )
106
+ end
107
+
108
+ it 'should work' do
109
+ res = api_instance.cancel_refund(api_version, account_id, id)
110
+
111
+ expect(res).to be_a(SubFiPay::RefundResponse)
112
+ end
113
+ end
114
+
115
+ describe "list refunds" do
116
+ let(:charge_id) { SecureRandom.uuid }
117
+ let(:path) { "/refunds?charge_id=#{charge_id}" }
118
+
119
+ before do
120
+ stub_request(:get, [config.host, path].join)
121
+ .with(headers: request_headers)
122
+ .to_return(
123
+ body: fixture("refunds/list_200.json"),
124
+ headers: response_headers,
125
+ status: 200
126
+ )
127
+ end
128
+
129
+ it 'should work' do
130
+ res = api_instance.list_refunds(api_version, account_id, charge_id)
131
+
132
+ expect(res).to be_a(SubFiPay::ListRefundsResponse)
133
+ end
134
+
135
+ end
136
+
137
+ describe "get refund" do
138
+ let(:id) { SecureRandom.uuid }
139
+ let(:path) { "/refunds/#{id}" }
140
+
141
+ before do
142
+ stub_request(:get, [config.host, path].join)
143
+ .with(headers: request_headers)
144
+ .to_return(
145
+ # re-using the same create response since it is the same object.
146
+ body: fixture("refunds/create_201.json"),
147
+ headers: response_headers,
148
+ status: 200
149
+ )
150
+ end
151
+
152
+ it 'should work' do
153
+ res = api_instance.get_refund(api_version, account_id, id)
154
+
155
+ expect(res).to be_a(SubFiPay::RefundResponse)
156
+ end
157
+ end
158
+ end