Compare commits

...

1800 Commits

Author SHA1 Message Date
helenye-stripe
da9f0e07e4
Disable flaky test in jruby/truffleruby (#1621)
* Disable flaky test for now

* ticket
2025-06-17 10:10:01 -07:00
Mike Chlipala
4367ac9511
Fix raw_request example in readme (#1620) 2025-06-16 07:10:55 -07:00
Helen Ye
d911399f81 Bump version to 15.2.1 2025-06-04 15:26:07 -04:00
helenye-stripe
51e8e3264f
Fix event refresh (#1617) 2025-06-04 12:21:33 -07:00
Ramya Rao
655385565f Bump version to 15.2.0 2025-05-29 00:28:57 +05:30
stripe-openapi[bot]
c3f9f45509
Update generated code (#1605)
* Update generated code for v1758

* Update generated code for v1770

* Update generated code for v1770

* Update generated code for v1772

* Update generated code for v1773

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2025-05-27 13:34:38 -07:00
Ramya Rao
6a2a9dca26
Simplify public preview SDK instructions (#1604) 2025-05-09 07:31:13 -07:00
Ramya Rao
a89df859de
Rename beta SDKs to public preview SDKs in readme (#1603)
* Rename beta SDKs to public preview SDKs in readme

* More details in installation steps

* simplify text
2025-05-08 07:02:05 -07:00
jar-stripe
74a5d1d5b9
adds CONTRIBUTING.md (#1601) 2025-05-02 14:47:14 -07:00
jar-stripe
ff7e4451a4
Require merge commit for merge PR (+ new rules.yml file) (#1600) 2025-05-02 13:51:33 -07:00
Michael Broshi
22ba74e4a6 Bump version to 15.1.0 2025-04-30 15:18:57 -04:00
stripe-openapi[bot]
6c90c710d8
Update generated code (#1597)
* Update generated code for v1719

* Update generated code for v1719

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2025-04-28 15:02:27 -07:00
stripe-openapi[bot]
cdce6c3f56
Update generated code for v1719 (#1595)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
2025-04-24 19:53:00 +00:00
helenye-stripe
1a0c78f112
Add resource pattern deprecation plan to README (#1592) 2025-04-24 12:43:28 -07:00
helenye-stripe
88c8720712
Fix endpoints being hit since requests are stubbed (#1591)
* Fix endpoints being hit since requests are stubbed

* Use a fake endpoint
2025-04-24 08:08:17 -07:00
stripe-openapi[bot]
b9d00e2ffa
Update generated code (#1566)
* Update generated code for v1655

* Update generated code for v1668

* Update generated code for v1691

* Update generated code for v1713

* Update generated code for v1718

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: prathmesh-stripe <165320323+prathmesh-stripe@users.noreply.github.com>
2025-04-23 23:40:10 -07:00
prathmesh-stripe
ca00b676f0
Updated rubocop (#1585) 2025-04-16 12:35:28 -04:00
helenye-stripe
36547afd0f
Fix mismatched indentations (#1584) 2025-04-15 16:52:56 -07:00
prathmesh-stripe
b8587ac65a
Include new Ruby 3.4 in CI (#1583) 2025-04-15 09:22:14 -07:00
prathmesh-stripe
25b6974852
Added rubocop exclusion for generated tests (#1581) 2025-04-11 21:19:56 +00:00
Helen Ye
10006bf668 Bump version to 15.0.0 2025-04-09 13:04:28 -04:00
helenye-stripe
6d34376960
Explicitly pass through custom headers in retrieve (#1576)
* Fix options passing in execute_request_initialize_from

* fix comments

* bug with combine then extract

* rubocop

* more thorough testing

* fix extra call

* pr feedback
2025-04-09 10:02:13 -07:00
helenye-stripe
5b68a44889
Rename object_id parameter (#1574) 2025-04-09 07:59:24 -07:00
Ramya Rao
fdb39ed488
Remove unused youtube playlist link (#1575)
* Remove link for stale youtube video playlist

* Remove unused youtube playlist link
2025-04-08 15:17:57 -07:00
helenye-stripe
04f8d1b43a
Validate all instance variable keys returned from the API (#1571)
* Normalize all keys

* instead reject invalid keys

* rubocop

* more easy to read constants
2025-04-08 13:43:23 -07:00
Ramya Rao
182d4dc838
Remove link for stale youtube video playlist (#1573) 2025-04-08 16:11:34 -04:00
Ramya Rao
5ce725ae22 Bump version to 14.0.0 2025-04-01 13:58:33 -07:00
stripe-openapi[bot]
72476176b1
Update generated code (#1561)
* Update generated code for v1642

* Update generated code for v1642

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2025-03-31 16:33:45 -07:00
helenye-stripe
dc5174725f
Add RBI annotations for fields and params (#1559)
* Introduce types to ruby

* rubocop

* forgot these files

* other request methods

* more tests, fix for raw request

* Add README entry for types

* rebase and regen
2025-03-31 14:29:41 -07:00
stripe-openapi[bot]
91626d37e8
Support for APIs in the new API version 2025-03-31.basil (#1543)
* Update generated code for v1559

* Update generated code for v1566

* Update generated code for v1572

* Update generated code for v1618

* Update generated code for v1635

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: prathmesh-stripe <165320323+prathmesh-stripe@users.noreply.github.com>
Co-authored-by: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com>
2025-03-31 11:09:09 -07:00
helenye-stripe
80fb92246d
Remove tests for endpoints that were removed (#1554) 2025-03-26 10:14:48 -07:00
helenye-stripe
cdbade3e57
Remove public idempotent_replayed message (#1553) 2025-03-25 07:18:28 -07:00
helenye-stripe
72c36f9500
lock rbi version in jruby (#1549) 2025-03-14 13:15:02 -07:00
prathmesh-stripe
a27751d19f
Fixed broken test caused by removing overrides for invoice/upcoming (#1544) 2025-03-13 18:47:13 -04:00
David Brownman
0c4238708f
adjust lint rules (#1542) 2025-03-13 06:52:23 -07:00
Prathmesh Ranaut
88f3e698e3 Bump version to 13.5.0 2025-02-24 17:35:14 -05:00
stripe-openapi[bot]
2a81d44236
Update generated code (#1534)
* Update generated code for v1494

* Update generated code for v1495

* Update generated code for v1501

* Update generated code for v1505

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: prathmesh-stripe <165320323+prathmesh-stripe@users.noreply.github.com>
2025-02-24 22:24:01 +00:00
helenye-stripe
d7e4457373
Fix InvoiceLineItem parent class (#1536) 2025-02-21 08:47:47 -08:00
David Brownman
43bbf6f528
add codeowners file (#1533) 2025-02-12 19:47:32 -05:00
Helen Ye
9d2bacd8d2 Bump version to 13.4.1 2025-01-28 10:59:29 -05:00
stripe-openapi[bot]
f2b4c22804
Update generated code for v1463 (#1528)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com>
2025-01-28 07:57:12 -08:00
Helen Ye
d146769ae5 Bump version to 13.4.0 2025-01-27 15:20:07 -05:00
stripe-openapi[bot]
0cb23f6540
Update generated code (#1510)
* Update generated code for v1421

* Update generated code for v1441

* Update generated code for v1455

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com>
2025-01-27 19:41:17 +00:00
David Brownman
5304640303
pipe rubocop output to devnull (#1521) 2025-01-17 10:30:37 -08:00
jar-stripe
b03b022d70
Fixed typos in CONTRIBUTING.MD (#1519) 2025-01-17 01:17:34 +00:00
David Brownman
08020d3207
add justfile (#1513)
* add justfile

* add just to ci and split out commands

* Fix justfile

* update readme and CI

* update justfile

* update CI

* update justfile import

* remove unused block
2025-01-16 14:54:59 -08:00
jar-stripe
ef7e6ee51e
added CONTRIBUTING.md file (#1515) 2025-01-15 19:30:40 +00:00
Helen Ye
57dd25a8d7 Bump version to 13.3.1 2025-01-13 17:28:34 -05:00
helenye-stripe
6e3950536a
Import global configuration for options not available on StripeClient options (#1512)
* Fix client options not importing global config

* update tests and fix bugs

* lint

* catch NotImplementedError and map for older Ruby

* rubocop todo
2025-01-13 14:23:32 -08:00
jar-stripe
36b1c7c8f0
ThinEvent reason and livemode (#1516)
* added test for parsing v2 thin events with livemode and reason

* added attr_reader to ThinEvent for livemode and reason

* added EventReason and EventReasonRequest type to thin_event.rb
2025-01-13 14:04:14 -08:00
jar-stripe
da19166173
pinned the ubuntu version in the Test action, to ensure support for jruby 9.4.0.0 (#1518) 2025-01-13 13:36:48 -08:00
jar-stripe
7227c8873b
Added pull request template (#1508) 2024-12-18 16:47:39 -08:00
Jesse Rosalia
332e009a57 Bump version to 13.3.0 2024-12-18 15:40:14 -08:00
stripe-openapi[bot]
d2c09c3b50
Update generated code (#1500)
* Update generated code for v1399

* Update generated code for v1409

* Update generated code for v1412

* Update generated code for v1412

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: jar-stripe <jar@stripe.com>
2024-12-18 23:27:41 +00:00
helenye-stripe
8aec85f636
Pass requestor to all deserialized objects including lists (#1507)
* Make sure to pass requestor through to all deserializes

* additional test
2024-12-17 08:59:08 -08:00
Ramya Rao
68f806e454 Bump version to 13.2.0 2024-11-20 15:31:31 -08:00
stripe-openapi[bot]
7c7f431838
Update generated code (#1486)
* Update generated code for v1341

* Update generated code for v1347

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
2024-11-20 23:25:25 +00:00
Helen Ye
7ddf16d170 Bump version to 13.1.2 2024-11-15 10:26:46 -05:00
helenye-stripe
56b9950250
Fix incorrect key in param encoding (#1488) 2024-11-14 18:28:00 -08:00
helenye-stripe
c4d0746d87
Update to use solargraph instead of ruby lsp (#1487) 2024-11-12 12:02:23 -08:00
Helen Ye
75c8c3835c Bump version to 13.1.1 2024-11-06 17:38:41 -05:00
helenye-stripe
aa880437dc
Fix APIResource#retrieve not sending stripe_version (#1483)
* Fix retrieve stripe version

* better test
2024-11-06 14:33:20 -08:00
Ramya Rao
91c68e4165
Update changelog with a note on 2024-10-28.acacia API version (#1478) 2024-10-30 16:42:03 -07:00
Ramya Rao
e4233f0dbb Bump version to 13.1.0 2024-10-29 14:16:39 -07:00
stripe-openapi[bot]
484f9741c5
Update generated code (#1472)
* Update generated code for v1317

* Update generated code for v1318

* Update generated code for v1318

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: prathmesh-stripe <165320323+prathmesh-stripe@users.noreply.github.com>
2024-10-29 10:12:19 -07:00
helenye-stripe
fb11d83248
Fix APIResource#retrieve bug not returning instance of custom resources (#1476)
* Fix refresh bug not returning specific instance type for custom resources

* tests
2024-10-28 10:29:13 -07:00
Jesse Rosalia
4c3593e62e Bump version to 13.0.2 2024-10-23 11:03:31 -07:00
Jonathan Smith
042918c5f8
Always return the result of APIResource#refresh in APIResource.retrieve (#1473)
* Always return the result of .refresh in .retrieve

With the refactor of v13, there are now cases where `self` is not
mutated in the call to refresh and instead a new object is returned.
This change ensures that the new object is always returned by returning
the result of refresh instead.

* Update install instructions for stripe-mock
2024-10-23 08:45:51 -07:00
David Brownman
a2e2881c7c Bump version to 13.0.1 2024-10-18 11:42:37 -07:00
David Brownman
95f4c9d231
update object tags for meter-related classes (#1471)
* update object tags for meter-related classes

* fix tests
2024-10-18 11:16:58 -07:00
jar-stripe
79ebfa5c1a
Cleaned up examples and added documentation (#1470) 2024-10-10 11:08:45 -07:00
Ramya Rao
540c7f7d88 Bump version to 13.0.0 2024-10-01 11:34:15 -07:00
helenye-stripe
2a9407b085
remove parseSnapshotEvent (#1463) 2024-10-01 09:54:13 -07:00
Ramya Rao
39d8736525
Support for APIs in the new API version 2024-09-30.acacia (#1458) 2024-10-01 09:35:59 -07:00
Ramya Rao
07ee576036
Stop using to be deprecated version of actions dependencies (#1445) 2024-09-13 10:13:01 -07:00
Helen Ye
37f30b85b2 Bump version to 12.6.0 2024-09-12 18:06:30 -04:00
stripe-openapi[bot]
37b9771584
Update generated code (#1442)
* Update generated code for v1196

* Update generated code for v1199

* Update generated code for v1202

* Update generated code for v1204

* Update generated code for v1211

* Update generated code for v1214

* Update generated code for v1230

* Update generated code for v1232

* Update generated code for v1235

* Update generated code for v1255

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
2024-09-12 14:53:20 -07:00
prathmesh-stripe
27d87e91ae
Removed v1/files override (#1443) 2024-08-29 19:26:49 -04:00
David Brownman
8fc981be69 Bump version to 12.5.0 2024-08-08 16:56:33 -07:00
stripe-openapi[bot]
9c2a7b2f44
Update generated code for v1187 (#1440)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2024-08-08 16:50:38 -07:00
Helen Ye
431140523d Bump version to 12.4.0 2024-07-25 14:00:08 -07:00
stripe-openapi[bot]
b40dc1f264
Update generated code (#1437)
* Update generated code for v1137

* Update generated code for v1154

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2024-07-25 13:34:26 -07:00
Prathmesh Ranaut
0dfd04c6f2 Bump version to 12.3.0 2024-07-18 16:08:51 -04:00
prathmesh-stripe
cc23e71c72
Fixed changelog for major release 12.0.0 (#1436) 2024-07-17 11:30:55 -04:00
helenye-stripe
ec36441d3d
Deprecate regular request on API resource (#1435) 2024-07-16 10:55:31 -07:00
Helen Ye
6225d34f82 Bump version to 12.2.0 2024-07-12 09:29:21 -07:00
stripe-openapi[bot]
5424da3fff
Update generated code (#1430)
* Update generated code for v1121

* Update generated code for v1126

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com>
2024-07-12 16:23:14 +00:00
helenye-stripe
aa49a46b82
Add usage to raw request call (#1433) 2024-07-11 14:56:33 -07:00
helenye-stripe
816fe0d0c7
Add raw_request (#1431)
* Add raw request

* Copy readme from beta

* fix readme
2024-07-10 21:34:52 +00:00
Prathmesh Ranaut
9cbc4632df Bump version to 12.1.0 2024-07-05 14:51:34 -04:00
stripe-openapi[bot]
bab5393d6a
Update generated code (#1425)
* Update generated code for v1095

* Update generated code for v1105

* Update generated code for v1111

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
2024-07-05 14:29:21 -04:00
Ramya Rao
fa2baeba7a
Static methods for delete/list on BankAccount/Card cannot be implemented. Use the onces on Customer instead. (#1420) 2024-06-27 14:17:28 -07:00
helenye-stripe
f0c40e0f79
Regenerate rbis (#1427) 2024-06-26 14:23:11 -07:00
prathmesh-stripe
8a5fca9998
Added jruby back and removed coveralls (#1426) 2024-06-26 14:57:08 -04:00
Ramya Rao
856693e948 Bump version to 12.0.0 2024-06-24 16:08:43 -07:00
stripe-openapi[bot]
a0542ff720
Update generated code (#1419)
* Update generated code for v1087

* Update generated code for v1088

* Update generated code for v1092

* Update generated code for v1093

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
2024-06-24 22:49:12 +00:00
prathmesh-stripe
ad4d29b4aa
Temporarily remove jruby from test matrix (#1424) 2024-06-24 15:44:37 -04:00
Ramya Rao
6dadabe005
Add missing static method for verify on BankAccount (#1418) 2024-06-17 17:03:55 -07:00
stripe-openapi[bot]
da8d64c580
Update generated code (#1411)
* Update generated code for v1060

* Update generated code for v1062

* Update generated code for v1063

* Update generated code for v1071

* Update generated code for v1079

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: prathmesh-stripe <165320323+prathmesh-stripe@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
2024-06-17 16:10:33 +00:00
Alexander Stone
102b9da798
Fix typo in documentation of stripe client (#1401)
This fixes the typo of `mangers` to be `managers` in the documentation
for the `default_connection_managers` method on the `ThreadContext`
class in `lib/stripe/stripe_client.rb`.

Co-authored-by: prathmesh-stripe <165320323+prathmesh-stripe@users.noreply.github.com>
2024-06-17 09:42:23 -04:00
Ramya Rao
1994d24765 Bump version to 11.7.0 2024-06-13 23:52:57 -07:00
anniel-stripe
4bdc4e27d4
Deprecate StripeClient#request (#1415)
* Deprecate StripeClient#request

* Remove useless variable assignment
2024-06-12 15:47:02 -07:00
David Brownman
29d8128963
update recommended extensions and settings (#1414) 2024-06-07 18:23:29 -04:00
kliang-stripe
64ec8947d5
use updated rubocop (#1413) 2024-06-04 14:21:43 -07:00
Ramya Rao
acdcecf8c5 Bump version to 11.6.0 2024-05-30 12:40:46 -07:00
Ramya Rao
03a7b9e12c
Add a note that 11.5.0 has no changes (#1408) 2024-05-29 12:19:43 -07:00
Ramya Rao
f774da66a7
Add method to list invoice line items (#1404) 2024-05-24 10:42:33 -07:00
Prathmesh Ranaut
076a685685 Bump version to 11.5.0 2024-05-23 16:24:09 -04:00
Ramya Rao
996b7eab0e Bump version to 11.4.0 2024-05-09 12:38:48 -07:00
stripe-openapi[bot]
a42ab44a36
Update generated code for v1011 (#1397)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
2024-05-09 19:17:56 +00:00
prathmesh-stripe
7f2bdfa718
Pass params to transfer reversal (#1399)
* Pass params to transfer reversal

* Add tests

* Add test for header check
2024-05-08 17:44:14 -04:00
anniel-stripe
f538d421d2
Add more tests for request opts flow (#1398)
* Add more tests for request opts flow

* spurious change

* fix return url
2024-05-06 16:05:56 -07:00
prathmesh-stripe
6e4f40f2a3
Removed jaro_winkler as a dependency (#1389) 2024-05-06 14:38:38 -04:00
anniel-stripe
a7aadfad4d
Start tracking StripeClient#request usage (#1396)
* Pass stripe_client_request for subsequent request

* codegen-format

* fix test
2024-05-03 10:27:42 -07:00
Helen Ye
13ee3322ff Bump version to 11.3.0 2024-05-02 13:56:26 -07:00
stripe-openapi[bot]
da6422f0a0
Update generated code (#1387)
* Update generated code for v979

* Update generated code for v985

* Update generated code for v989

* Update generated code for v997

* Update generated code for v1002

* Update generated code for v1003

* Update generated code for v1005

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: prathmesh-stripe <165320323+prathmesh-stripe@users.noreply.github.com>
2024-05-02 16:31:03 -04:00
prathmesh-stripe
46cc83fc8a
Deprecate Ruby methods based on OpenAPI spec (#1392) 2024-05-02 16:10:03 -04:00
Blake Williams
1177f60ece
Add Ruby 3.3 to CI test matrix (#1391) 2024-04-30 17:04:53 -07:00
Ramya Rao
47db6b0adf Bump version to 11.2.0 2024-04-18 14:24:25 -07:00
stripe-openapi[bot]
ad22bab02f
Update generated code for v969 (#1385)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2024-04-18 14:12:53 -07:00
Ramya Rao
3d7b450e5a
Remove entries from CHANGELOG.md that are not user facing (#1384) 2024-04-16 11:49:26 -07:00
Ramya Rao
75d238c563 Bump version to 11.1.0 2024-04-16 08:58:06 -07:00
stripe-openapi[bot]
4287976384
Update generated code (#1379)
* Update generated code for v940

* Update generated code for v945

* Update generated code for v947

* Update generated code for v961

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
2024-04-15 23:25:27 -07:00
helenye-stripe
ca318ab00a
Revert Makefile change to allow autoformatting in codegen (#1382) 2024-04-11 16:19:26 -07:00
helenye-stripe
5eccf34816
Rename section for object types (#1380) 2024-04-11 21:27:23 +00:00
Ramya Rao
c75081f22a Bump version to 11.0.0 2024-04-10 16:01:22 -07:00
Ramya Rao
93267e38ab
Sdk release/next major (#1374) 2024-04-10 16:00:43 -07:00
helenye-stripe
2a45f50bd6
Send codegen output to stdout (#1381) 2024-04-10 15:46:20 -07:00
Ramya Rao
ec5152c82e Bump version to 10.15.0 2024-04-09 14:12:17 -07:00
stripe-openapi[bot]
dfea3bdac5
Update generated code (#1372)
* Update generated code for v914

* Update generated code for v918

* Update generated code for v919

* Update generated code for v923

* Update generated code for v935

* Update generated code for v938

* Revert "Update generated code for v935"

This reverts commit 5316ec6e0310a94b496213de077090b03a0fac34.

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <ramya@stripe.com>
2024-04-09 13:36:37 -07:00
helenye-stripe
a12ff9cdb8
Add last_response to StripeObject (#1377)
* Add last_response to StripeObject

* Add more data to test and fix README
2024-04-09 10:52:43 -07:00
helenye-stripe
5eb028cac0
Warm up ca_store in gc tests to make sure they pass in isolation (#1375) 2024-04-08 12:57:21 -07:00
Ufuk Kayserilioglu
45a650036e
Move executables to exe folder (#1366)
Conventionally `bin` folder is home to scripts that are meant to be run by developers working on the project, whereas the `exe` folder is used for executables that are meant to be exported by the gem.

The guidance from the Bundler team around this has been live since 2015: https://bundler.io/blog/2015/03/20/moving-bins-to-exe.html

This PR simplifies the gemspec and updates the `bin` folder to `exe` in the gemspec and removes some of the unnecessarily cleanup that was introduced previously.
2024-04-05 14:30:23 -07:00
Ramya Rao
357337301c Bump version to 10.14.0 2024-03-28 12:16:54 -07:00
stripe-openapi[bot]
d478ba6679
Update generated code (#1369)
* Update generated code for v897

* Update generated code for v898

* Update generated code for v901

* Update generated code for v905

* Update generated code for v908

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2024-03-28 11:51:59 -07:00
Ramya Rao
d2c24ca682 Bump version to 10.13.0 2024-03-21 14:04:12 -07:00
stripe-openapi[bot]
59d3a34000
Update generated code (#1367)
* Update generated code for v888

* Update generated code for v889

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2024-03-21 13:50:11 -07:00
helenye-stripe
faa5d4546f
Exclude sorbet directory and tapioca script when packing gem (#1362) 2024-03-15 10:44:24 -07:00
Ramya Rao
3a51dfaba7 Bump version to 10.12.0 2024-03-14 12:31:59 -07:00
stripe-openapi[bot]
ad00c3e621
Update generated code (#1359)
* Update generated code for v872

* Update generated code for v878
2024-03-14 11:58:37 -07:00
helenye-stripe
4705a5f5f9
Refactor after SDK based generation pattern (#1354)
* Refactor after SDK based generation pattern

* update for object types & reorder
2024-03-11 13:10:30 -07:00
helenye-stripe
e2893a274e
Reorder methods (#1347) 2024-03-07 23:11:29 +00:00
anniel-stripe
74294666a2
Disable Metrics/ClassLength (#1355) 2024-03-01 20:01:34 +00:00
anniel-stripe
bfb4e9fff5
Update CHANGELOG.md (#1351) 2024-02-29 22:57:37 +00:00
Annie Li
0ad6440f44 Bump version to 10.11.0 2024-02-29 17:49:29 -05:00
Annie Li
0e77795607 Bump version to 10.11.0 2024-02-29 17:46:58 -05:00
Annie Li
cb15e14962 Bump version to 10.11.0 2024-02-29 17:45:25 -05:00
Annie Li
8654aa9065 Bump version to 10.11.0 2024-02-29 16:57:26 -05:00
helenye-stripe
00f2c02ca6
Use sorbet gem instead, required for srb (#1348) 2024-02-29 21:11:07 +00:00
Annie Li
521ab2f97c Bump version to 10.11.0 2024-02-29 15:22:00 -05:00
stripe-openapi[bot]
3b507b4647
Update generated code for v841 (#1342)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com>
2024-02-29 20:10:26 +00:00
helenye-stripe
6458ba68f4
Update README to use add_beta_version (#1345) 2024-02-28 12:19:18 -08:00
Pavel Krymets
303d7c3256 Bump version to 10.10.0 2024-02-22 14:19:40 -08:00
stripe-openapi[bot]
425999c80b
Update generated code (#1336)
* Update generated code for v833

* Update generated code for v840

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com>
2024-02-22 22:15:51 +00:00
anniel-stripe
3e18ad6338
Fix TaxId tests to support top-level TaxId methods (#1334) 2024-02-22 17:28:36 +00:00
pakrym-stripe
64afe4a398
Update README.md (#1339) 2024-02-21 12:40:30 -08:00
Helen Ye
6664641da0 Bump version to 10.9.0 2024-02-15 16:21:45 -08:00
stripe-openapi[bot]
e3f1a90e79
Update generated code (#1329)
* Update generated code for v818

* Update generated code for v820

* Update generated code for v828

* Update generated code for v829

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com>
2024-02-15 15:56:05 -08:00
helenye-stripe
06d1bfbc9b
Start running Sorbet in CI (#1324)
* Rebase

* Gemfile, makefile, sorbet
2024-02-12 15:23:36 -08:00
helenye-stripe
ce8d7ca4cc
Add methods for dynamically referenced constants (#1327)
* Update dynamic constant references

* Manual additionsg

* Fix lint

* Use const_Get

* Remove puts
2024-02-09 17:15:39 -08:00
Annie Li
bc375b791e Bump version to 10.8.0 2024-02-08 14:06:01 -08:00
stripe-openapi[bot]
0dc3414645
Update generated code for v810 (#1322)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: helenye-stripe <111009531+helenye-stripe@users.noreply.github.com>
2024-02-08 21:11:54 +00:00
helenye-stripe
d22938897e
Extract other CRUDL methods from mixins (#1323) 2024-02-06 10:19:06 -08:00
helenye-stripe
b56a9b6c76
Update mocha gem to 1.16 (#1314)
* attempt to update mocha to 2.0

* try 1.16 instead
2024-02-05 12:10:11 -08:00
Annie Li
32681000bf Bump version to 10.7.1 2024-02-05 10:30:16 -08:00
anniel-stripe
1bde67fba3
Remove internal usages of _search (#1320) 2024-02-05 10:24:06 -08:00
Richard Marmorstein
ec0e71ddb0 Bump version to 10.7.0 2024-02-01 14:15:29 -08:00
helenye-stripe
d356ef6e96
Remove list in child resources (#1317) 2024-01-30 14:58:17 -08:00
stripe-openapi[bot]
7055e504b1
Update generated code for v793 (#1315)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2024-01-25 09:13:22 -08:00
stripe-openapi[bot]
c7d68d5200
Update generated code (#1312)
* Update generated code for v769

* Update generated code for v771

* Update generated code for v773

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com>
2024-01-25 17:01:12 +00:00
helenye-stripe
37293f6aba
Merge pull request #1311 from stripe/helenye-use-deprecation-gem-search
Use the deprecation gem in search and clean up usage of the gem
2024-01-19 10:16:03 -08:00
Helen Ye
08b00636a5 Add test to warn about search being deprecated 2024-01-18 16:46:51 -08:00
helenye-stripe
37fa3c1228
Merge branch 'master' into helenye-use-deprecation-gem-search 2024-01-18 09:40:42 -08:00
Helen Ye
faa9d58a66 Update search to use the deprecate gem 2024-01-18 09:39:17 -08:00
Helen Ye
2ac9890545 wip 2024-01-16 10:42:38 -08:00
Pavel Krymets
a685a13a67 Bump version to 10.6.0 2024-01-12 10:12:09 -08:00
stripe-openapi[bot]
bc03829f1d
Update generated code (#1310)
* Update generated code for v753

* Update generated code for v755

* Update generated code for v755

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com>
2024-01-12 16:34:38 +00:00
helenye-stripe
871a4c55b0
Merge pull request #1308 from stripe/helenye-demagic-ruby
Extract search api operation into resource from mixin
2024-01-11 06:47:31 -08:00
Helen Ye
97bd5abc61 Fix TODO format 2024-01-10 13:09:47 -05:00
Helen Ye
6ff3a7ad3a Extract search into resource from mixin 2024-01-10 13:07:31 -05:00
Richard Marmorstein
36dc37db5e Bump version to 10.5.0 2024-01-04 13:52:23 -06:00
stripe-openapi[bot]
8875698b96
Update generated code for v742 (#1306)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2024-01-04 11:40:30 -08:00
Pavel Krymets
de4e1d3b23 Bump version to 10.4.0 2023-12-22 07:58:22 -08:00
stripe-openapi[bot]
c51404d7a2
Update generated code (#1303)
* Update generated code for v726

* Update generated code for v733

* Update generated code for v733

* Update generated code for v734

* Update generated code for v734

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com>
2023-12-21 14:55:42 -08:00
pakrym-stripe
c46f4a6af1
Add support for updatable singleton resources (#1304) 2023-12-21 11:44:29 -08:00
Richard Marmorstein
678757fefc Bump version to 10.3.0 2023-12-14 15:41:43 -08:00
Richard Marmorstein
210a1eb8c9
Merge pull request #1294 from stripe/richardm-anniel-singleton-retrieve-parameters
Support sending parameters inside singleton retrieve
2023-12-11 11:54:54 -08:00
Annie Li
9c7a649a93 lint 2023-12-11 11:04:16 -08:00
anniel-stripe
7e23610f83
Merge branch 'master' into richardm-anniel-singleton-retrieve-parameters 2023-12-11 11:01:05 -08:00
Richard Marmorstein
db16cf65c4
Merge pull request #1293 from stripe/richardm-usage
Measure usage of .save
2023-12-01 14:02:11 -08:00
Richard Marmorstein
ca41fd3058
Merge branch 'master' into richardm-usage 2023-12-01 14:01:30 -08:00
Richard Marmorstein
1af9e1a864
Update README.md 2023-12-01 13:28:28 -08:00
Richard Marmorstein
3fdaa23ae4 Format 2023-12-01 12:58:22 -08:00
Richard Marmorstein
b44211190b Omit usage if empty 2023-12-01 12:54:58 -08:00
anniel-stripe
1ea064ad8e
Explicitly disable MFA (#1297) 2023-11-30 10:24:48 -08:00
Annie Li
ac814f7ad3 Bump version to 10.2.0 2023-11-30 10:11:29 -08:00
stripe-openapi[bot]
9b84f256a5
Update generated code for v682 (#1292)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com>
2023-11-30 09:53:41 -08:00
Richard Marmorstein
0455e39169 standard docstring 2023-11-29 12:50:38 -08:00
Richard Marmorstein
580a37755a
Update lib/stripe/stripe_client.rb
Co-authored-by: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com>
2023-11-28 15:29:56 -08:00
Richard Marmorstein
aa26c78455 Format 2023-11-28 13:36:34 -08:00
Richard Marmorstein
f0c4e79241 --auto-correct -> --autocorrect 2023-11-28 13:36:30 -08:00
Richard Marmorstein
fdde37d8f0 README note 2023-11-28 13:30:09 -08:00
Richard Marmorstein
e47dcb8b98 Measure usage of .save 2023-11-28 13:30:09 -08:00
Richard Marmorstein
ddb922b924
Merge pull request #1295 from stripe/richardm-upgrade-rubocop
Upgrade rubocop
2023-11-28 13:29:49 -08:00
Richard Marmorstein
be0abdf7b5 bump 2023-11-28 12:59:58 -08:00
Richard Marmorstein
5cf8e62ef8 Will this fix CI 2023-11-27 17:13:27 -08:00
Richard Marmorstein
4925d05a35 Version restriction for rubocop 2023-11-27 17:08:24 -08:00
Richard Marmorstein
41fcd5edfc Bad NOTE: 2023-11-27 17:03:07 -08:00
Richard Marmorstein
2d6249fbd2 Autocorrect 2023-11-27 17:02:33 -08:00
Richard Marmorstein
633ca27ae7 Upgrade rubocop 2023-11-27 16:52:48 -08:00
Richard Marmorstein
7feef1dd5d New rubocop rules 2023-11-27 16:52:48 -08:00
Richard Marmorstein
4feded59da Upgrade rubocop 2023-11-27 16:52:48 -08:00
Richard Marmorstein
3ecb678e09 Support sending parameters inside singleton retrieve 2023-11-27 16:23:01 -08:00
stripe-openapi[bot]
22e10313b0
Update generated code for v670 (#1291)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-11-21 11:33:19 -08:00
stripe-openapi[bot]
7a81acac44
Update generated code for v669 (#1290)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-11-16 15:44:02 -08:00
stripe-openapi[bot]
fe52fcd1e7
Update generated code for v662 (#1288)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-11-16 10:43:45 -08:00
Richard Marmorstein
625a58661e Bump version to 10.1.0 2023-11-02 15:31:46 -07:00
stripe-openapi[bot]
33eff4d1d3
Update generated code (#1286)
* Update generated code for v629

* Update generated code for v633

* Update generated code for v640

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-11-02 15:11:37 -07:00
Pavel Krymets
9cb048b053 Bump version to 10.0.0 2023-10-16 13:31:32 -07:00
stripe-openapi[bot]
d40be17ff2
Update generated code for v603 (#1283)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-10-16 13:23:14 -07:00
stripe-openapi[bot]
4b425a8fc6
Update generated code (#1281)
* Update generated code for v599

* Update generated code for v601

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-10-16 10:54:27 -07:00
Annie Li
76227029e7 Bump version to 9.4.0 2023-10-05 11:01:21 -07:00
stripe-openapi[bot]
46b57349da
Update generated code (#1277)
* Update generated code for v570

* Update generated code for v573

* Update generated code for v576

* Update generated code for v580

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-10-05 09:39:48 -07:00
stripe-openapi[bot]
e0d068c909
Update generated code (#1275)
* Update generated code for v546

* Update generated code for v548

* Update generated code for v551

* Update generated code for v557

* Update generated code for v563

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-09-28 15:46:39 -07:00
stripe-openapi[bot]
04792b3ddf
Update generated code (#1274)
* Update generated code for v533

* Update generated code for v536

* Update generated code for v540

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-09-21 15:34:58 -07:00
Richard Marmorstein
aad1a320c5 Bump version to 9.3.0 2023-09-14 17:55:35 -07:00
stripe-openapi[bot]
0f0d604ca8
Update generated code (#1272)
* Update generated code for v527

* Update generated code for v530

* Update generated code for v531

* Update generated code for v532

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-09-14 17:49:24 -07:00
stripe-openapi[bot]
a1c164e2d8
Update generated code (#1271)
* Update generated code for v519

* Update generated code for v522

* Update generated code for v522

* Update generated code for v525

* Update generated code for v525

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-09-14 08:28:36 -07:00
Pavel Krymets
f70e9b10d3 Bump version to 9.2.0 2023-09-07 11:02:34 -07:00
stripe-openapi[bot]
405725bf9c
Update generated code (#1267)
* Update generated code for v503

* Update generated code for v507

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-09-07 08:55:57 -07:00
Richard Marmorstein
5a523c07ba Bump version to 9.1.0 2023-08-31 13:21:46 -07:00
stripe-openapi[bot]
a6a02edebb
Update generated code for v495 (#1266)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-08-31 13:09:40 -07:00
Paul Padier
79463b2efa
Explicitly format timestamp in SignatureVerificationError message (#1262)
When interpolating a Time object in a String, Ruby calls `to_s` under the hood.

For Rails applications defining a `default` string format, this triggers deprecation warnings as of v7.0.7: https://github.com/rails/rails/pull/48555

This change fixes that by explicitly formatting the timestamp (using the same `YYYY-MM-DD HH:mm:ss` format currently implicitly used).
2023-08-21 18:14:56 -07:00
Richard Marmorstein
011f3121a5
Update CHANGELOG.md 2023-08-17 03:49:25 -07:00
Richard Marmorstein
4af7ea944c
Update CHANGELOG.md 2023-08-16 16:44:14 -07:00
Richard Marmorstein
31f300c16d Bump version to 9.0.0 2023-08-16 16:08:04 -07:00
stripe-openapi[bot]
d1d4b6e83c
Update generated code for v461 (#1260)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com>
2023-08-16 22:09:20 +00:00
Richard Marmorstein
ee60e66936
stripe-ruby v9 release (#1253)
* wip

* Pin to latest API version

* Empty commit

---------

Co-authored-by: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com>
2023-08-16 15:03:29 -07:00
Richard Marmorstein
e48d410162 Bump version to 8.7.0 2023-08-10 17:35:34 -07:00
stripe-openapi[bot]
83841fddcd
Update generated code (#1256)
* Update generated code for v451

* Update generated code for v457

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-08-10 12:47:18 -07:00
anniel-stripe
8975fc1b3c
Update openapi version (#1255) 2023-08-04 11:16:18 -07:00
stripe-openapi[bot]
deeed0ab79
Add test for Quote.pdf (#1248)
* Update generated code for v426

* Update generated code for v426

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com>
2023-07-27 22:33:49 +00:00
pakrym-stripe
62fb31d578
Suppor testing methods that hit files endpoint (#1250) 2023-07-21 16:47:49 +00:00
stripe-openapi[bot]
33c94cadf5
Update generated code (#1247)
* Update generated code for v423

* Update generated code for v424

* Update generated code for v425

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-07-20 08:27:27 -07:00
Annie Li
ded501370d Bump version to 8.6.0 2023-07-13 15:11:59 -07:00
stripe-openapi[bot]
45d7e30a61
Update generated code for v413 (#1244)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-07-13 14:48:02 -07:00
stripe-openapi[bot]
9d0c0147d7
Update generated code (#1241)
* Update generated code for v405

* Update generated code for v406

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-07-06 12:58:26 -07:00
anniel-stripe
3ba3e10ec8
Update log level error (#1238) 2023-06-23 07:40:34 -07:00
Ivan Marynych
6dce6c1240
remove unnecessary log level from available (#1235)
* remove unnecessary log level from available

* Update stripe_configuration.rb
2023-06-23 06:49:11 -07:00
Justin Hammond
d297fdef7d
fix: variable typo in README for instrumentation (#1231) 2023-06-20 11:47:16 -07:00
stripe-openapi[bot]
f538aee155
Update generated code for v387 (#1234)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-06-15 11:50:43 -07:00
stripe-openapi[bot]
a9d46a306b
Update generated code for v379 (#1230)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-06-13 13:52:26 -07:00
stripe-openapi[bot]
f1b5b73eaf
Update generated code (#1226)
* Update generated code for v358

* Update generated code for v376

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-06-08 11:43:22 -07:00
stripe-openapi[bot]
6d95d56abb
Update generated code for v353 (#1223)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com>
2023-05-25 09:51:25 -07:00
pakrym-stripe
5ad5458bc2
Downgrade jaro_winkler (#1225) 2023-05-23 10:49:17 -07:00
stripe-openapi[bot]
8a996da054
Update generated code (#1219)
* Update generated code for v328

* Update generated code for v330

* Update generated code for v344

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-05-19 08:11:22 -07:00
stripe-openapi[bot]
0890e1fb0f
Update generated code for v309 (#1215)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-04-27 08:41:51 -07:00
Ricardo Trindade
f36db9462a
Update shoulda-context version (#1209)
Should-context was released July 2020 so I believe this dependency can be updated
2023-04-13 10:02:04 -07:00
stripe-openapi[bot]
ff558e713b
Update generated code for v296 (#1208)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-04-13 07:56:46 -07:00
Richard Marmorstein
4441dcbb5e
Merge pull request #1204 from stripe/latest-codegen-master
Update generated code
2023-04-06 12:32:26 -07:00
Stripe OpenAPI
59cf9803b6 Update generated code for v291 2023-04-03 15:23:32 +00:00
Annie Li
5fb10bdfd3 Bump version to 8.5.0 2023-03-30 13:26:51 -07:00
stripe-openapi[bot]
8a7d5aacc7
Update generated code for v285 (#1203)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-03-30 13:19:22 -07:00
anniel-stripe
aa05b84acc
Update save deprecation message (#1201)
* Update save deprecation message

* comma
2023-03-29 11:20:29 -07:00
Pavel Krymets
e33a1da93e Bump version to 8.4.0 2023-03-23 14:41:07 -07:00
stripe-openapi[bot]
e1080cdd1e
Update generated code for v277 (#1198)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-03-23 13:28:04 -07:00
stripe-openapi[bot]
57f61c09ce
Update generated code (new) (#1197)
* Update generated code for v275

* Update generated code for v276

---------

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-03-23 13:16:46 -07:00
pakrym-stripe
980b7b011f
Remove test for a method without stripe-mock support (#1193) 2023-03-17 13:51:38 -07:00
pakrym-stripe
54b103eaeb
Use shared stripe-mock action (#1190) 2023-03-17 12:28:09 -07:00
stripe-openapi[bot]
5e3d38b675
Update generated code for v258 (#1186)
Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
2023-03-15 15:38:11 +00:00
pakrym-stripe
414ca367af
Run bundle install before formatting code (#1185)
* Run bundle install before formatting code

* qq
2023-03-15 15:31:08 +00:00
Richard Marmorstein
e4e6bb54fd
Merge pull request #1181 from stripe/latest-codegen-master
API Updates
2023-02-23 15:11:34 -08:00
Richard Marmorstein
e2e4b77a87 Codegen for openapi v232 2023-02-23 15:03:19 -08:00
Zac Clay
57a2806c18
Symbolize hash keys inside convert_to_stripe_object_with_params (#1152) 2023-02-21 10:45:38 -08:00
Annie Li
7db585f5a4 Bump version to 8.3.0 2023-02-16 15:01:42 -08:00
anniel-stripe
45408e52b7
Merge pull request #1175 from stripe/latest-codegen-master
API Updates
2023-02-16 14:49:32 -08:00
Annie Li
8ee13d0e30 Codegen for openapi v226 2023-02-16 14:09:35 -08:00
Richard Marmorstein
8be00fef4e Bump version to 8.2.0 2023-02-02 15:01:45 -06:00
Richard Marmorstein
6136198da4
Merge pull request #1173 from stripe/latest-codegen-master
API Updates
2023-02-02 12:33:05 -08:00
Richard Marmorstein
0b028811f2 bump CI 2023-02-02 14:27:11 -06:00
Richard Marmorstein
206b707d0c Add test 2023-02-02 14:05:46 -06:00
Richard Marmorstein
a9a687ab61 Codegen for openapi v223 2023-02-02 13:53:12 -06:00
Richard Marmorstein
990792f9c1
Merge pull request #1171 from stripe/richardm-dead-code
Remove unused `partial` param from `initialize_from`
2023-01-23 07:44:31 -08:00
Richard Marmorstein
a42bdeb640 initialize_from(..., partial) is dead code 2023-01-21 19:45:49 -06:00
Peter Goldstein
339d36b0a2
Adds Ruby 3.2 to the CI matrix. Update action versions to v3. (#1159)
Co-authored-by: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com>
2023-01-19 14:33:20 -08:00
pakrym-stripe
e6b167565e
Codegen for openapi v219 (#1169) 2023-01-19 10:19:27 -08:00
anniel-stripe
fcfeac740e
Update README.md with instrumentation changes (#1165) 2023-01-18 15:41:04 -08:00
Richard Marmorstein
e0a50213e7 Bump version to 8.1.0 2023-01-12 11:20:50 -06:00
Leena Hai Ha Nguyen
c1d0ced565
Improve request events instrumentation (#1162)
* Add response field to RequestEndEvent

* Add request body field to RequestEventEnd

* Add request headers field to RequestEventEnd

* Create a RequestContext class

* Create a ResponseContext class

* Update tests
2023-01-11 09:43:23 -08:00
pakrym-stripe
b87cfbec98
Update jruby version (#1154) 2022-12-08 12:04:58 -08:00
anniel-stripe
a96e6f3b42
Add tests for update (#1150)
* Add tests for update

* Apply suggestions from code review

Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com>

* Lint

Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com>
2022-11-23 11:20:04 -08:00
Richard Marmorstein
24312f9f49 Bump version to 8.0.0 2022-11-16 12:04:21 -08:00
pakrym-stripe
a0935c246d
Next major release changes (#1144) 2022-11-16 11:35:51 -08:00
anniel-stripe
6dc009579d
Disable AsciiComments rule (#1142) 2022-11-02 16:31:55 -07:00
Kamil Pajdzik
c2bb4dbceb
Codegen for openapi v204 (#1138) 2022-11-02 13:21:34 -07:00
anniel-stripe
46eca72f79
Do not run Coveralls if secret token is not available (#1137) 2022-10-24 14:34:46 -07:00
Bart de Water
2dec63e6b0
Update request_end instrumentation example (#1095)
* Update request_end instrumentation example in README.md
2022-10-14 16:40:20 -07:00
anniel-stripe
af6fb06cd6
Merge pull request #1126 from stripe/anniel-coveralls
Add test coverage using Coveralls
2022-08-24 11:59:19 -07:00
Annie Li
4d87c3af1e Restart CI due to Github Actions incident 2022-08-24 11:55:55 -07:00
Annie Li
dc93d96cb9 Change check to 3.1. 2022-08-24 11:01:48 -07:00
Annie Li
f647412789 Add comment and change to starts_with 2022-08-24 10:56:47 -07:00
Annie Li
2076cfd42e Add coveralls 2022-08-24 09:56:47 -07:00
pakrym-stripe
78863b4b0f
Update README.md (#1125) 2022-08-24 08:57:58 -07:00
pakrym-stripe
53ab9bf668
Add beta readme.md section (#1121) 2022-08-23 16:34:02 +00:00
Dominic Charley-Roy
cfeaa0ca23
API Updates (#1123) 2022-08-23 08:51:43 -04:00
Kamil Pajdzik
cb53c3b14a Bump version to 7.1.0 2022-08-19 11:55:04 -07:00
Kamil Pajdzik
73324f2ce6
Codegen for openapi v183 (#1116) 2022-08-19 09:19:03 -07:00
anniel-stripe
c5af3ad4f2
Merge pull request #1118 from stripe/anniel-rubocop-allowed-chars
Update AllowedChars in rubocop config
2022-08-19 08:59:01 -07:00
Dominic Charley-Roy
7bb5a3582c
Merge branch 'master' into anniel-rubocop-allowed-chars 2022-08-19 11:52:01 -04:00
Annie Li
77cc0b1554 Update AllowedChars in rubocop config 2022-08-18 15:46:13 -07:00
Dominic Charley-Roy
be2efb7d25
Refresh rubocop config. (#1117) 2022-08-18 17:47:20 -04:00
Ramya Rao
0f04faab6d
Add a support section to the readme (#1115)
We have user feedback on the lack of clarity around whether or not we maintain and improve older major versions of the SDK. This PR adds a support section clarifying this
2022-08-17 14:06:15 -07:00
Pavel Krymets
6081371b89 Bump version to 7.0.0 2022-08-02 08:46:41 -07:00
pakrym-stripe
3171e4cc98
Codegen for openapi v174 (#1106) 2022-08-02 08:05:33 -07:00
Kamil Pajdzik
ec71fd87f2
Next major release changes (#1103)
* chore!: Update CA certifacte bundle (Apr 26). (#1079)

* Generate stripe-ruby with breaking changes (#1102)

* Generate stripe-ruby with breaking changes

* Remove RecipientTest

* Remove AlipayAccount tests

* Regenerate files

* Delete outdated tests

* Fix more tests

* Fix more tests

* Fix example test manually

* Update retrieve_cash_balance method to have params. (#1104)

Co-authored-by: Dominic Charley-Roy <78050200+dcr-stripe@users.noreply.github.com>
2022-08-01 10:33:48 -07:00
pakrym-stripe
a961665452
Codegen for openapi v163 (#1092) 2022-07-07 09:33:48 -07:00
pakrym-stripe
8449c2ea0a
Codegen for openapi v162 (#1090) 2022-07-06 12:30:04 -07:00
Dominic Charley-Roy
0aca5d2cdc Bump version to 6.5.0 2022-06-29 17:59:11 -04:00
Dominic Charley-Roy
0c30d8288d
API Updates (#1084) 2022-06-29 17:58:43 -04:00
Kamil Pajdzik
a447425d68
Add release/* and feature/* to PR CI triggers (#1080)
* Add next-major-release to PR CI triggers

* Update branch names

* Rename release to sdk-release in CI triggers
2022-06-28 15:08:40 -07:00
Dominic Charley-Roy
9092e9dbab
fix: Update logging to coerce ASCII-8BIT into UTF-8. (#1076) 2022-06-21 16:35:46 -04:00
Kamil Pajdzik
33c820096f Bump version to 6.4.0 2022-06-17 12:17:21 -07:00
Kamil Pajdzik
8ec93fb0b7
Codegen for openapi v157 (#1073) 2022-06-17 12:05:31 -07:00
pakrym-stripe
020328bf27
Support updating pre-release versions (#1074)
* Support updating pre-release versions

* Update Makefile
2022-06-15 16:20:22 -07:00
pakrym-stripe
f2e05a20b2
Trigger workflows on beta branches (#1072) 2022-06-15 09:08:22 -07:00
pakrym-stripe
b841931ffe
Use request_stripe_object for all requests (#1071) 2022-06-13 10:21:38 -07:00
pakrym-stripe
001db8bd27
Codegen for openapi v154 (#1070) 2022-06-09 10:39:49 -07:00
Dominic Charley-Roy
ad84b25e8e
chore: Stop special implementation of Account.persons method. (#1069) 2022-06-08 12:27:51 -04:00
Pavel Krymets
d5ec3eab06 Bump version to 6.3.0 2022-06-08 09:12:30 -07:00
pakrym-stripe
f5b49fe4fd
Codegen for openapi v152 (#1067) 2022-06-08 09:08:00 -07:00
Dominic Charley-Roy
6ffacea45f
fix: Update cash balance methods to no longer require nested ID. (#1063) 2022-06-08 11:55:12 -04:00
pakrym-stripe
df255e06b5
Update README.md (#1065) 2022-06-06 09:58:16 -07:00
Pavel Krymets
936641fd83 Bump version to 6.2.0 2022-05-23 12:57:10 -07:00
pakrym-stripe
5f4227f52a
Codegen for openapi v146 (#1060) 2022-05-23 12:49:27 -07:00
Richard Marmorstein
ed991553d3 Bump version to 6.1.0 2022-05-19 17:14:49 -07:00
Kamil Pajdzik
22f9da1565
API Updates (#1057)
Co-authored-by: Richard Marmorstein <richardm@stripe.com>
Co-authored-by: Dominic Charley-Roy <dcr@stripe.com>
2022-05-19 20:11:21 -04:00
Richard Marmorstein
629cd30e76 Bump version to 6.0.0 2022-05-09 11:53:52 -07:00
Richard Marmorstein
2a702cedd7
API Updates (#1056) 2022-05-09 14:14:29 -04:00
Dominic Charley-Roy
4acf43f9da Bump version to 5.55.0 2022-05-05 09:27:27 -04:00
Dominic Charley-Roy
94d050bb13
API Updates (#1055) 2022-05-05 09:23:29 -04:00
Dominic Charley-Roy
f3e270d69b Bump version to 5.54.0 2022-05-03 12:31:17 -04:00
Dominic Charley-Roy
41066a4ed1
API Updates (#1053) 2022-05-03 10:21:23 -04:00
pakrym-stripe
2eb542205e
Enable automated rubygems release (#1052) 2022-05-02 07:51:15 -07:00
pakrym-stripe
e671382a94
Add ruby release action (#1051) 2022-05-02 07:12:32 -07:00
Richard Marmorstein
d064a77ca7 Bump version to 5.53.0 2022-04-21 15:28:19 -07:00
Richard Marmorstein
fad1dcaa7b
API Updates (#1050)
* Codegen for openapi e07f049
2022-04-21 18:19:56 -04:00
Yejia Chen
6b54fdea5f Fix feature request template issue description 2022-04-19 17:19:13 -04:00
Yejia Chen
227bef7bd2 Fix template field ids 2022-04-19 17:18:19 -04:00
Yejia Chen
4c87a7e5a6 Fix config name 2022-04-19 17:11:46 -04:00
Yejia Chen
3b267c4b0b Update issue templates
- Use issue forms
- Remove old template
2022-04-19 17:09:52 -04:00
yejia-stripe
55d05447f5
Add issue templates (#1049)
Add issue templates for bug reports and feature requests, using the default ones on GitHub.
2022-04-19 15:28:39 -04:00
Richard Marmorstein
582da16a7f Bump version to 5.52.0 2022-04-18 15:51:09 -07:00
Richard Marmorstein
2be83cf0cb
Codegen for openapi a8928d0 (#1047)
* Codegen for openapi a8928d0
2022-04-18 17:59:30 -04:00
Pavel Krymets
8e649ec8d3 Bump version to 5.51.0 2022-04-15 13:50:38 -07:00
Richard Marmorstein
3998b689de
API Updates (#1046)
* Codegen for openapi 9e8cdc3
2022-04-15 11:53:56 -04:00
Olivier
1e62ccd968
remove extra space (#980) 2022-04-15 11:53:40 -04:00
Peter Goldstein
e90312a154
Add Ruby 3.1 to the CI matrix (#1028) 2022-04-15 11:53:23 -04:00
Richard Marmorstein
9d8d396327 Bump version to 5.50.0 2022-04-13 16:05:13 -07:00
Richard Marmorstein
721a4b5660
Codegen for openapi e0123a3 (#1045) 2022-04-13 13:11:29 -04:00
pakrym-stripe
3d623c9493
Add a common Makefile (#1044) 2022-04-12 15:54:55 -07:00
Kamil Pajdzik
a06b1477e7 Bump version to 5.49.0 2022-04-08 10:07:08 -07:00
Kamil Pajdzik
89f170c4c9
API Updates (#1043)
* Codegen for openapi fc5a2b9

* Reformat code
2022-04-08 09:43:40 -07:00
Pavel Krymets
ca0ab78388 Bump version to 5.48.0 2022-03-30 08:50:12 -07:00
pakrym-stripe
60d51f2c0a
API Updates (#1041) 2022-03-29 15:37:58 -07:00
Pavel Krymets
1467630a68 Bump version to 5.47.0 2022-03-29 08:46:35 -07:00
pakrym-stripe
90fae49d64
API Updates (#1040) 2022-03-28 12:42:32 -07:00
pakrym-stripe
fc480cdb6c
Add supporting classes for test helper generation (#1034) 2022-03-28 08:00:54 -07:00
Dominic Charley-Roy
be3b75265f Bump version to 5.46.0 2022-03-23 15:03:19 -04:00
Dominic Charley-Roy
208dcf5af8
API Updates (#1039) 2022-03-23 12:45:32 -04:00
Susindaran Elangovan
ba38dc9d24
Add support for Search API (#992) 2022-03-17 09:50:15 -07:00
Richard Marmorstein
8d379bf1a7 Bump version to 5.45.0 2022-03-01 14:17:52 -08:00
Richard Marmorstein
1f8b6bf3e1
Codegen for openapi 1707cb8 (#1035) 2022-03-01 15:01:51 -05:00
Yejia Chen
c6124dbb09 Bump version to 5.44.0 2022-02-16 11:29:26 -05:00
Richard Marmorstein
c641c3ab19
Codegen for openapi a285624 (#1032) 2022-02-15 17:50:41 -05:00
Richard Marmorstein
faeb0cae4e Bump version to 5.43.0 2022-01-20 09:29:15 -08:00
Richard Marmorstein
917e512c10
API Updates (#1031)
* Codegen for openapi 4d2f301
2022-01-20 11:22:53 -05:00
Dominic Charley-Roy
3e476701b4
Update Docs URLs. (#1024) 2021-12-23 15:51:02 -05:00
Ilija Eftimov
9e05b8f8c1
Fix broken URIs in gemspec (#1023) 2021-12-23 13:58:34 -05:00
Dominic Charley-Roy
ced92764ed Bump version to 5.42.0 2021-12-13 13:13:34 -05:00
Dominic Charley-Roy
234a9611a6
Add connection manager logging and include object IDs in logging. (#1022) 2021-12-13 12:55:40 -05:00
Yejia Chen
c1e4e879fb Bump version to 5.41.0 2021-11-16 11:05:02 -05:00
yejia-stripe
d4d282d14d
API Updates (#1017) 2021-11-16 10:04:38 -05:00
Richard Marmorstein
59657673fc Bump version to 5.40.0 2021-11-11 16:13:17 -05:00
Richard Marmorstein
3db855d309
Codegen for openapi 21065d4 (#1015) 2021-11-11 15:55:13 -05:00
Dominic Charley-Roy
9774447859
Add tests for child resources. (#1013) 2021-10-13 11:30:44 -04:00
Dominic Charley-Roy
3e2665fb11
Add tests for namespaced resources. (#1012) 2021-10-12 14:38:30 -04:00
Richard Marmorstein
d0defa6e3f
Codegen methodless resources (#1011) 2021-10-12 09:51:38 -04:00
Richard Marmorstein
30dd671e3e Bump version to 5.39.0 2021-10-11 11:42:35 -04:00
Richard Marmorstein
4c36bacd41
API Updates (#1010) 2021-10-11 10:58:59 -04:00
Dominic Charley-Roy
e534c876b3
Add generated test suite. (#1009) 2021-10-07 18:11:34 -04:00
Richard Marmorstein
b86671acba Bump version to 5.38.0 2021-08-10 07:42:52 -04:00
DJ Patterson
85c7f52c3a
Add request_id to RequestEndEvent (#993)
Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com>
2021-08-09 19:47:46 -04:00
Richard Marmorstein
378c71dec7
Codegen more files (#991) 2021-07-27 12:50:38 -04:00
Dominic Charley-Roy
ad7104adc1
Remove unused API error types from docs. (#989) 2021-07-15 09:56:08 -04:00
Dominic Charley-Roy
c46e8fcaea Bump version to 5.37.0 2021-07-14 13:25:43 -04:00
Richard Marmorstein
cbecb42185
API Updates (#988) 2021-07-14 12:14:41 -04:00
Richard Marmorstein
5cbd8d9af7 Bump version to 5.36.0 2021-07-09 15:55:06 -04:00
Dominic Charley-Roy
d8b3ddf595
API Updates (#987) 2021-07-09 15:36:24 -04:00
Dominic Charley-Roy
01146ac6b0 Bump version to 5.35.0 2021-06-30 09:53:29 -04:00
Dominic Charley-Roy
90223fa06b
Update normalize_opts to use dup instead of clone. (#985) 2021-06-29 17:04:56 -04:00
Richard Marmorstein
19da5510df
Deprecate travis (#982) 2021-06-24 12:01:53 -04:00
Dominic Charley-Roy
59eb8d06cf
Add support for making a request and receiving the response as a stream. (#983) 2021-06-24 10:24:11 -04:00
Richard Marmorstein
28e6d19a90 Bump version to 5.34.0 2021-06-04 13:37:56 -04:00
Richard Marmorstein
faf84198c6
API Updates (#981) 2021-06-04 12:35:25 -04:00
seang-stripe
83b0cb369e
Update CHANGELOG.md 2021-05-19 12:07:28 -07:00
Sean Gottschalk
df7d3f58e5 Bump version to 5.33.0 2021-05-19 12:03:45 -07:00
Richard Marmorstein
0ba9307bdb
API Updates (#979) 2021-05-19 10:13:22 -04:00
Igor Victor
ca8a36769e
Update ci.yml (#975) 2021-04-06 16:40:21 -07:00
Brandur
218292aa15 Bump version to 5.32.1 2021-04-05 15:07:34 -07:00
Brandur
3aad27f6e4 Correct use of match 2021-04-05 15:05:50 -07:00
Brandur
6a9ca59d06 Use Rubocop-preferred regular expression style 2021-04-05 15:03:07 -07:00
Brandur
a415fa8aad Bump version to 5.32.0 2021-04-05 14:58:58 -07:00
Brandur
410fc18fc3 Check start of input on matches 2021-04-05 14:57:51 -07:00
Masafumi Koba
ec31858e07
Reduce packed gem size (#973)
This change aims to reduce the packed gem size by removing needless files from `s.files`.

Also, `s.test_files` is also removed because it is not defined in the gemspec reference.
(see <https://guides.rubygems.org/specification-reference/>)

- Size changed: 215K -> 264K
- Files changed: 221 files -> 120 files
2021-04-05 12:14:35 -07:00
Brandur
75e744f4a2 Bump version to 5.31.0 2021-04-02 13:27:33 -07:00
Brandur Leach
16a094cf34
Rename Stripe.configuration to Stripe.config (#972)
This is just a cosmetic change that renames `Stripe.configuration` to
just `Stripe.config`. We use the shorter "config" in most other places
including `StripeClient#config`, so I feel that this is overall more
consistent.

This change is backwards compatible because the new accessor came in
with #968, and that hasn't been given a formal release yet.

I've left the class name as `StripeConfiguration` which IMO is fine. The
class uses the expanded form of the name while vars and accessors use
the shorter `config`. Also, `StripeConfiguration` has been around a
little bit longer, so renaming it is somewhat backwards incompatible
too.
2021-04-02 13:24:37 -07:00
Brandur
3e26570fcd
On config change, only clear connection managers for changed config (#971)
Follows up #968.

As a relic from when we had global configuration, anytime any config
value is changed on any client, we still clear all connection managers
everywhere on every thread, even though this is not necessary. This
means that we lose all open connections, etc.

Here, we make changes so that if a configuration is changed, we only
clear the configuration managers pertaining to that one particular
configuration, thus conserving resources globally.

Co-authored-by: Brandur <brandur@brandur.org>
2021-04-02 13:13:26 -07:00
Brandur Leach
b9c7afd5fe
Reserve some critical field names when adding StripeObject accessors (#970)
When populating `StripeObject`s, we add accessors to them so that people
can access fields like `obj.currency`.

This was probably only meant to apply to API resources, but through
what might have been an accident of history, we've also traditionally
unmarshaled any hash that comes back from the API as a `StripeObject`,
including `metadata` fields. This allows some convenience because users
can access values like `obj.metadata.my_field`, but is also obviously a
minefield for potential problems.

In issue #969, what's essentially happening is that because there's a
metadata field named `class`, we've overwritten the object's normal
`class` method with our own custom one that accesses the metadata value.
Amazingly, the object can still marshal/unmarshal mostly properly, but
fails on this line as we try to access `obj.class` and that turns out to
be a metadata value instead of a class:

``` ruby
when StripeObject
  obj.class.construct_from(
    ...
```

Here I solve the problem by banning accessors added with the name
`class`. This has a slight risk of backward incompatibility in that
users that previously had metadata named "class" will now have to use
square bracket accessors instead like `obj.metadata[:class]`, but
honestly, I just can't see anything good in allowing "class" to be used
as an accessor.

An alternative solution might be to alias `class` in `StripeObject` and
then make sure we always use that in places like `initialize_from` and
`deep_copy`.

The best long term solution would be to stop add accessors to metadata
objects. This just seems like a bad idea given that there are still
myriads of Ruby built-ins that could potentially be overwritten. This is
definitely a considerably-sized breaking change though, so we'd have to
do it on a major.
2021-04-02 11:08:56 -07:00
Joel Taylor
21643f0716
Allow StripeClient to be configured per instance (#968)
This changes allows for each instance of StripeClient to have its own
configuration object instead of relying on the global config. Each
instance can be configured to override any global config values
previously set.
2021-04-01 14:19:38 -07:00
Richard Marmorstein
f864e68bf7
CI: github actions (#967) 2021-03-10 14:48:48 -05:00
Richard Marmorstein
5c5c0a82ba Bump version to 5.30.0 2021-02-22 09:28:24 -05:00
Richard Marmorstein
f59ba8cae0
Add billing portal configuration (#965) 2021-02-19 20:32:33 -05:00
Brandur
512f5464d0 Bump version to 5.29.1 2021-02-09 09:51:31 -08:00
Brandur
c28ee66a14
Fix return value of Customer#delete_discount (#964)
`Customer#delete_discount` has been broken for some time in that it
tries to re-initialize `self` (which is a customer) with a received
discount response. This is incorrect and leads to various problems.

Here, we redefine the return value of `delete_discount` as a discount,
and have it no longer mutate the object on which is was called. We add a
comment as well just to help flag some of the behavior which could
potentially be confusing.

Fixes #963.
2021-02-09 09:50:07 -08:00
CJ Avilla
de27275ee6
Add playlist links into README (#959)
* Update readme

* Add link to YouTube playlist from README
2021-01-12 16:34:41 -08:00
Brandur
7d460450cc Bump version to 5.29.0 2021-01-05 13:38:23 -08:00
Joel Taylor
06bcc863b0
Allow client_id configuration on instance config (#952)
It's necessary to allow `client_id` to be configured in order to move
towards supporting `StripeClient` instances.
2021-01-05 13:35:46 -08:00
Brandur
9787913b35 Bump version to 5.28.0 2020-10-14 11:44:42 -07:00
Bart de Water
085e08142d
Allow setting write_timeout for connections on Ruby 2.6+ (#950) 2020-10-14 11:43:32 -07:00
Remi Jannel
259cd1ce9c Bump version to 5.27.0 2020-10-14 07:56:33 -07:00
remi-stripe
db24334b9e
Add support for the Payout Reverse API (#951)
* Codegen for openapi 4bd4c01

* Add test
2020-10-14 07:51:16 -07:00
Remi Jannel
f3b83f132e Bump version to 5.26.0 2020-09-29 22:55:27 -07:00
remi-stripe
29f321b224
Add support for the SetupAttempt resource and List API (#949)
* Codegen for openapi 3854362

* Fix and add tests
2020-09-29 22:54:58 -07:00
Olle Jonsson
eb84249205
CI: Drop unused sudo: false Travis directive (#947) 2020-09-24 10:16:41 -07:00
Remi Jannel
0620436d63 Bump version to 5.25.0 2020-09-02 13:57:09 -07:00
remi-stripe
683b10140e
Add support for the Issuing Dispute Submit API (#944)
* Codegen for openapi 474461f

* Add and fix tests for the latest stripe-mock

Some of the tests had to be changed/mocked because stripe-mock has a bug
where the includable sub-lists it returns have the wrong url set.
Because of this, when you call create/list/etc. on one of those sub-lists
the calls fails due to that URL being incorrect.
Moved one test to use charge+refund (auto-expanded) and another used a
mock to have the right URL returned.
2020-09-02 13:56:24 -07:00
CJ Avilla
e1ae307e60
Update readme (#942) 2020-08-31 15:11:13 -07:00
Brandur
5d9039731b Bump version to 5.24.0 2020-08-26 13:01:23 -07:00
Joel Taylor
23a0ee2dbe
Extract configurations into separate object (#939)
Adds a `Stripe::StripeConfiguration` object to manage internal and user
supplied configuration options.

This is primarily motivated by #921 in order to provide a way to set
options on for an instance of `StripeClient`.
2020-08-26 12:58:59 -07:00
brchristian
c517a708d5
Fix typo in documentation of stripe_object.rb (#940) 2020-08-16 16:53:15 -07:00
Brandur
8710fcaddc Bump version to 5.23.1 2020-08-05 16:01:36 -07:00
Brandur
3433130c5d
Rename API resource's request method (#936)
As seen in #928, the `refresh` method doesn't work for an event class.
This is because event has a field called `request`, and it ends up
replacing the `request` method that it inherited from being an API
resource, so when `refresh` tries to make a request, it fails because it
tries to invoke it on the accessor added for the event's property.

Here we give `request` a much more unique name so that it will never
conflict with a property field again, and update all internal references
to use the new name. We use `alias` to make the old name available for
backwards compatibility reasons because its been around for so long that
people are probably calling it.

Fixes #928.
2020-08-05 16:00:37 -07:00
Remi Jannel
5573a73337 Bump version to 5.23.0 2020-08-05 12:36:13 -07:00
remi-stripe
cf8b2c5e84
Add support for the PromotionCode resource and APIs (#937)
* Codegen for openapi f71053e

* Add tests
2020-08-05 12:33:47 -07:00
Joel Taylor
f240405810
Update minimum stripe-mock version to 0.94.0 (#935)
The params for AccountLink changed in `v0.93.0`, which will cause the
test suite to fail unless `stripe-mock` is pinned to an earlier version.

Fixes #934
2020-07-31 16:44:01 -07:00
Christopher
9cf59214f3
Adding comment to show which files are generated (#931) 2020-07-22 14:30:18 -07:00
Remi Jannel
403f9b22f6 Bump version to 5.22.0 2020-05-11 17:11:40 -07:00
remi-stripe
cfac8d7fcc
Add support for the LineItem resource and APIs (#918) 2020-05-11 17:10:41 -07:00
Remi Jannel
4c5b67bce0 Bump version to 5.21.0 2020-04-29 12:45:58 -07:00
remi-stripe
622db9d9e7
Add support for the Price resource and APIs (#917)
* Codegen for openapi f75fd88

* Fix test suite
2020-04-29 12:41:35 -07:00
Brandur
07f58cad01 Bump version to 5.20.0 2020-04-27 14:37:36 -07:00
Brandur
58fdde1289
Add new .generate_header method for webhooks (#916)
Adds a new `generate_header` method for the webhooks module, following
up #915. This method doesn't help in any way with webhook verification,
but may be useful to users in their test suites as it allows them to
easily simulate the contents of a header that Stripe might have sent.

We briefly discussed an alternative design here, but this one seems like
the best fit:
https://github.com/stripe/stripe-ruby/pull/915#issuecomment-620164654
2020-04-27 14:36:53 -07:00
Brandur
325ff57928 Fix version in CHANGELOG 2020-04-24 11:00:46 -07:00
Brandur
49477fa250 Bump version to 5.19.0 2020-04-24 10:59:14 -07:00
Brandur
e117c9fb6d
Expose Stripe::Webhook.compute_signature (#915)
Exposes the `.compute_signature` method, which may be useful when
testing webhook signing in test suites.

I change the API slightly so that a caller isn't forced to do as much
string mangling, and to match the one that we already have in stripe-go:

``` go
func ComputeSignature(t time.Time, payload []byte, secret string) []byte {
```

Add basic documentation and test case. I also change a few things around
so that we send `Time` objects around more often where applicable, and
don't change then to Unix integers until the last moment that we need
to.

The one other alternative API I considered is this one, which would
default the timestamp to the current time to allow the method to be
called with one fewer arg:

``` ruby
def self.compute_signature(payload, secret: timestamp: Time.now)
```

I decided against it in the end though because it does remove some
explicitness, and it's not a big deal to just pass in `Time.now`,
especially given that this is not expected to be a commonly used method.

Fixes #912.
2020-04-24 10:58:42 -07:00
Remi Jannel
1b68611edc Bump version to 5.18.0 2020-04-22 12:10:16 -07:00
remi-stripe
b8c01be32d
Add support for BillingPortal namespace and Session resource and APIs (#911) 2020-04-22 12:09:02 -07:00
Brandur
0508aa92ee
Lock shoulda-context to 2.0.0rc4 (#910)
Minor changes that locks us on the 2.0.0 release candidate for
`shoulda-context`. This makes almost no difference to our test suite
except that it removes a long-standing warning for an assigned but
unused variable (which is our last warning!).

See more context here:
https://github.com/thoughtbot/shoulda-context/issues/57#issuecomment-610702695

Co-authored-by: Brandur <brandur@brandur.org>
2020-04-07 21:03:28 -07:00
Brandur
1a20c2476d Bump version to 5.17.0 2020-02-26 16:53:50 -08:00
Brandur
f7923f7b47
Add StripeError#idempotent_replayed? (#907)
Adds an easy accessor on `StripeError` which indicates whether the error
occurred previously, but was replayed on this request because the user
passed the same idempotency key as that original request.

Fixes #905.
2020-02-26 16:53:02 -08:00
Olivier Bellone
de40bbf232
Bump version to 5.16.0 2020-02-26 12:53:11 -08:00
Olivier Bellone
1bd015ea4a
Codegen for openapi 40a20cd (#906) 2020-02-26 12:51:52 -08:00
Brandur
554f18b850
Upgrade to Rubocop 0.80 (#903)
Just noticed that a new version of Rubocop came out today. The upgrade
seemed relatively painless, so just went for it.
2020-02-18 10:41:55 -08:00
Brandur
69e19fa6bd Correct available fields for request_begin 2020-02-11 13:42:17 -08:00
Brandur
c1520fb208 Bump version to 5.15.0 2020-02-10 14:23:43 -08:00
Brandur
81407b6807
Add request_begin instrumentation callback (#902)
Adds a new instrumentation callback called `request_begin` which, as the
name suggests, is invoked before an HTTP request is dispatched. As
outlined originally in #900, the idea is that this will enable a set of
hooks that can be used for distributed tracing.

The PR also renames the existing `request` callback to `request_end`,
although the old name is still invoked for the time being for backwards
compatibility.

A special `user_data` property is passed to `request_begin` which allows
subscribers to set custom data that will be passed through to
`request_end` for any given request. This allows, for example, a user
assigned ID to be set for the request and recognized on both ends.

I chose the naming `_begin` and `_end` (as opposed to start/finish or
any other combination) based on the naming conventions of Ruby itself.

Fixes #900.
2020-02-10 14:22:58 -08:00
remi-stripe
7182ae0f8b
Move code examples from charge to customer and remove save mention (#899) 2020-01-27 10:09:39 -08:00
Brandur
dcb503dc71
Bump minimum version of webmock to 3.8.0 (#897)
Bumps the minimum version of webmock to 3.8.0 which contains a fix for a
Ruby 2.7 warning. This last change makes the whole project completely
warning-free!

Co-authored-by: Brandur <brandur@brandur.org>
2020-01-15 13:43:02 -08:00
Remi Jannel
c62344a70b Bump version to 5.14.0 2020-01-14 08:20:34 -08:00
remi-stripe
368f534bce
Codegen for openapi d663cdb (#896) 2020-01-14 08:17:44 -08:00
Brandur
fd71c5f50f Clean up test output by capturing $stderr when we expect warnings (#894)
I just noticed while running tests that we produce some accidental
output because both of `Source#source_transactions` and
`SubscriptionItem#usage_record_summaries` are considered deprecated and
have warnings attached.

Here we capture output to `$stderr` and assert on it from the test cases
that call these deprecated methods -- this pattern is already well
established elsewhere in the test suite.
2020-01-09 16:57:39 -08:00
Dennis van der Vliet
9afd73c16f Explicitly pass a parameter as hash to be more ruby 2.7 friendly (#892)
* Tweaks to be ruby 2.7 friendly

* Disable a cop to allow hash passing

* Tidy up rubocop comments and remove .ruby-version

* Use inline disable
2020-01-09 16:29:11 -08:00
Brandur
8777d9d61d Upgrade Rubocop to 0.79 (#893)
Basically went through trying to make the whole stripe-ruby test run
Ruby 2.7 friendly. @dennisvdvliet got most of the internal stuff, but we
still have a couple external dependencies that are producing warning.

Here we upgrade Rubocop to 0.79, which curbs some warnings. A few lints
were moved and/or renamed, so I've modified the `.rubocop.yml`
appropriately, but there's no major changes there.

The last broken dependency is Webmock, and luckily I think it's pretty
easy to fix, so I'll send them a PR and see what happens.
2020-01-09 11:07:58 -08:00
Brandur
2a95b62431 Bump version to 5.13.0 2020-01-08 13:11:42 -08:00
Dennis van der Vliet
9c49df7e7b Ruby 2.7 (#891)
* Build against 2.7

* Fix low hanging fruit warnings

* Get rid of some more warnings
2020-01-08 13:10:02 -08:00
Olivier Bellone
ebbfb54c2d
Bump version to 5.12.1 2020-01-06 15:33:24 -08:00
Olivier Bellone
cddd3db2b2
Override API key with client_secret in OAuth.token (#890) 2020-01-06 15:30:32 -08:00
Olivier Bellone
e23ae43850
Bump version to 5.12.0 2020-01-02 15:12:11 -08:00
Olivier Bellone
c5be2f492b
[codegen] Add support for retrieve source transaction API method (#889)
* Codegen for openapi ba4dcd0

* Add tests
2020-01-02 15:11:08 -08:00
Angel Buzany
28835d69b7 Delete empty file (#886) 2019-11-27 09:12:51 -08:00
Olivier Bellone
824d1f9efe
Bump version to 5.11.0 2019-11-26 13:46:14 -08:00
Olivier Bellone
7aeae42fdc
Add support for CreditNote preview (#885) 2019-11-26 13:44:56 -08:00
Alex Rattray (Stripe)
da06eb2cb3
Fix non-hash comment in README (#883) 2019-11-26 20:52:12 +08:00
Alex Rattray
75b1797771 Bump version to 5.10.0 2019-11-08 16:42:40 -08:00
Alex Rattray (Stripe)
2ded14efe3
Add list_usage_record_summaries and list_source_transactions (#882)
* Add list_usage_record_summaries and list_source_transactions

* Fix lint
2019-11-08 16:24:38 -08:00
Brandur
9b7bd5e9e3 Remove checkboxes and add PR links in CHANGELOG 2019-11-08 10:14:47 -08:00
Brandur
455d1c163c Bump version to 5.9.0 2019-11-07 14:19:36 -08:00
Bart
26a0964e56 Add simple instrumentation callback (#870)
* Add simple instrumentation callback

We used to insert Faraday::Request::Instrumentation into our Faraday middleware
stack to be able to instrument Stripe calls with StatsD. With Faraday being
removed in version 5, this required some rework. This commit implements a simple
callback system that can be used with any kind of instrumentation system.

* Add a topic to Stripe::Instrumentation notifications

... and a :request topic to subscribe to

* Use a RequestEvent value object instead of positional args in callback

This way the RequestLogContext object doesn't get exposed externally. Since the
same value object can be received by multiple subscribers it is frozen to
prevent accidental mutations across threads.

* Relocate tests for instrumentation and add more tests
2019-11-07 14:18:11 -08:00
Viktor Fonic
162e29c979 Add gem version badge (#881) 2019-11-06 09:35:55 -08:00
Remi Jannel
8d72722cc7 Bump version to 5.8.0 2019-11-05 19:41:29 -08:00
remi-stripe
6b4a0343b3
Add support for Mandate (#879) 2019-11-05 19:36:41 -08:00
Joel Taylor
93ea15fb46 Add additional per-request configuration documentation (#876) 2019-11-01 10:09:45 -07:00
Joel Taylor
299e9ea0ab Raise an error when requests params are invalid (#874)
There are two kinds of API operations: collection and element specific.
The signature between the two is slightly different:
  - **collection**: (params, opts)
  - **element specific**: (id, params, opts)

If a user doesn't realize the difference, they may attempt to use the
collection signature when performing an element specific operation like:
```
Stripe::PaymentIntent.cancel('pi_1234', 'sk_test_key')
 # Results in an error: NoMethodError: undefined method `key?' for "sk_test"
```

The resulting error message isn't very useful for debugging.

Instead,this PR adds a message letting the user know what it's expecting:
`request params should be either a Hash or nil (was a String)`
2019-10-31 09:53:19 -07:00
Olivier Bellone
4e564a1945
Contributor Covenant (#873) 2019-10-24 11:03:28 -07:00
Olivier Bellone
16c05468bc
Bump version to 5.7.1 2019-10-15 17:09:44 -07:00
tmaxwell-stripe
c4a0735232 s/connection_base/connect_base/ (#869) 2019-10-15 17:08:42 -07:00
Brandur
00b60afbf5 Add some documentation on ordering direction 2019-10-10 10:36:32 -07:00
Brandur
15f8304e48 Bump version to 5.7.0 2019-10-10 10:11:58 -07:00
Brandur
e3cc91ded2 Support backwards pagination with list's #auto_paging_each (#865)
* Support backwards pagination with list's `#auto_paging_each`

Previously, `#auto_paging_each` would always try to paginate forward,
even if it was clear based on the list's current filters that the user
had been intending to iterate backwards by specifying an `ending_before`
filter exclusively.

Here we implement backwards iteration by detecting this condition,
reversing the current list data, and making new requests for the
previous page (instead of the next one) as needed, which allows the user
to handle elements in reverse logical order.

Reversing the current page's list is intended as a minor user feature,
but may possibly be contentious. For background, when backwards
iterating in the API, results are still returned in "normal" order. So
if I specifying `ending_before=7`, the next page would look like `[4, 5,
6`] instead of `[6, 5, 4]`. In `#auto_paging_each` I reverse it to `[6,
5, 4]` so it feels to the user like they're handling elements in the
order they're iterating, which I think is okay. The reason it might be
contentious though is that it could be a tad confusing to someone who
already understands the normal `ending_before` ordering in the API.

Fixes #864.

* Allow `ending_before` and `starting_after` to remain in hydrated list object
2019-10-10 10:11:12 -07:00
Brandur
c206a3cc09 Bump version to 5.6.0 2019-10-04 13:16:35 -07:00
Brandur
bbb585a7c3 Nicer error when specifying non-nil non-string opt value (#861)
Previously, if you specified a non-nil non-string opt value, like a
symbol for `idempotency_key`, you'd get a pretty user-unfriendly error
from `Net::HTTP`:

```
/Users/brandur/.rbenv/versions/2.4.5/lib/ruby/2.4.0/net/http/header.rb:21:in `block in initialize_http_header': undefined method `strip' for :foo:Symbol (NoMethodError)
```

Here, we introduce a new argument error that makes it a little easier
for someone to read. The impetus for the change is that we had an
internal product quality report where someone ran into this and was
confused.

I'm pretty sure this change is backward compatible because `Net::HTTP`
would call `strip` on anything that was passed in as a value, and
generally just strings would support that. There may be some other less
common data type that was accidentally compatible that someone was
using, but that case should be quite unusual.
2019-10-04 13:16:03 -07:00
Brandur
8fc0f70a2b Exclude ephemeral test scripts from Rubocop linting (#860)
One thing I tend to do a lot is create little test scripts to help debug
or reproduce problems with stripe-ruby. The problem is that they get
picked up by Rubocop, produce a whole bunch of errors, and then make it
more difficult if my changes to actual library files are producing
problems.

Here I exclude these by introducing a convention for having them start
with `example_*`. This isn't particularly great, but will work.
2019-10-04 11:04:01 -07:00
Brandur
7e5698e77d Bump version to 5.5.0 2019-10-03 13:09:57 -07:00
Michael Elfassy
ba7ee5c5f4 User-friendly messages and retries for EOFError and a few more network errors (#859) 2019-10-03 13:08:11 -07:00
Brandur
27718e0e47 Drop Timecop dependency (#858)
If #857 comes in, it turns out that we don't need Timecop anymore (it
doesn't freeze the monotic clock, so I had to find another way) -- here
we remove all mentions of it and drop the dependency.

I don't find it causes too much trouble so I'm not against bringing it
back in the future if we need it again, but it seems good for project
cleanliness to take it out for now.
2019-10-01 10:10:39 -07:00
Olivier Bellone
8bab04e2bc
Bump version to 5.4.1 2019-10-01 10:07:32 -07:00
Brandur
e52bb95995 Bump version to 5.4.0 2019-10-01 09:59:36 -07:00
Brandur
480303c446 Move to monotonic time for duration calculations (#857)
Drops the use of `Time.now` in favor of using the system's monotonic
clock for various operations that calculate and use elapsed duration.
The latter is preferable because in some cases `Time.now` can be
unstable, like if it's set manually by a system administrator or an NTP
daemon.

I don't expect that the previous code would actually have caused trouble
in the vast majority of normal situations, so I'm not going to backport
anything, but this seems like good hygiene.

For better or worse I had to wrap the monotonic time calls in a new
`Util` function because (1) the normal invocation is long enough to have
caused a lot of overruns on our 80 character line lengths, and (2)
Timecop doesn't stub the monotonic clock, so the `Util` method gives us
a nice place that we can stub on where necessary.
2019-10-01 09:58:50 -07:00
Brandur
f2b1fa150c Bump version to 5.3.0 2019-10-01 09:05:49 -07:00
Brandur
0544105fb8 Support Stripe-Should-Retry header (#853)
As seen in stripe-node, adds support for the `Stripe-Should-Retry`
header which is sent by the API when it explicitly would like us to
either retry or _not_ retry.

I'll add `Retry-After` separately at some point, but I punted it on it
for now given that we're not using it yet.

See: https://github.com/stripe/stripe-node/pull/692
2019-10-01 09:05:00 -07:00
Vasu Adari
e61793eea2 Fix warnings and typo in NestedResource (#852)
* Fix typo in NestedResource

* Fix warnings and indentation in NestedResource
2019-09-25 10:03:53 -07:00
Brandur
3cb9ad7fca Bump version to 5.2.0 2019-09-19 23:45:54 -07:00
Brandur
cbf44035b8 Introduce system for garbage collecting connection managers (#851)
Introduces a system for garbage collecting connection managers in an
attempt to solve #850.

Previously, the number of connection managers (and by extension the
number of connections that they were holding) would stay stable if a
program used a stable number of threads. However, if threads were used
disposably, the number of active connection managers out there could
continue to grow unchecked, and each of those could be holding one or
more dead connections which are no longer open, but still holding a file
descriptor waiting to be unlinked in disposed of by Ruby's GC.

This PR introduces a connection manager garbage collector that runs
periodically whenever a new connection manager is created. Connection
managers get a timestamp to indicate when they were last used, and the
GC runs through each one and prunes any that haven't seen use within a
certain threshold (currently, 120 seconds). This should have the effect
of removing connection managers as they're not needed anymore, and thus
resolving the socket leakage seen in #850.

I had to make a couple implementation tweaks to get this working
correctly. Namely:

* The `StripeClient` class now tracks thread contexts instead of
  connection managers. This is so that when we're disposing of a
  connection manager, we can set `default_connection_manager` on its
  parent thread context to `nil` so that it's not still tracking a
  connection manager that we're trying to get rid of.

* `StripeClient` instances can still be instantiated as before, but no
  longer internalize a reference to their own connection manager,
  instead falling back to the one in the current thread context. The
  rationale is that when trying to dispose of a connection manager, we'd
  also have to dispose of its reference in any outstanding
  `StripeClient` instances that might still be tracking it, and that
  starts to get a little unwieldy. I've left `#connection_manager` in
  place for backwards compatibility, but marked it as deprecated.
2019-09-19 23:43:49 -07:00
Brandur
1f80da4b7a Change some error tests to use assert_raises (#847)
Previously, we had quite a few error tests that were written like this:

``` ruby
begin
  client.execute_request(:post, "/v1/charges")
rescue Stripe::InvalidRequestError => e
  assert_equal(404, e.http_status)
  assert_equal(true, e.json_body.is_a?(Hash))
end
```

The trouble with that pattern is that although they'll _usually_ work,
the test will incorrectly pass if no error at all is thrown because the
`rescue` never activates and therefore the assertions never run.

We change them to use `assert_raises` like so:

``` ruby
e = assert_raises Stripe::InvalidRequestError do
  client.execute_request(:post, "/v1/charges")
end
assert_equal(404, e.http_status)
assert_equal(true, e.json_body.is_a?(Hash))
```

The weird part is that many of the tests were already using
`assert_raises`, so here we're just converting them all over to use the
same convention.

I've also made a few whitespace tweaks. None of them are significant,
but they were an attempt to standardize a little on the whitespace
layout of many of these tests which were similar.
2019-09-04 14:50:05 -07:00
Brandur
52f64b2bac Add a test to make sure request IDs make it into error objects (#846)
Follows up #845 to make sure that this sort of regression is much more
difficult in the future by adding a test that makes sure a request ID is
threaded all the way from an HTTP response back through to an error
object. I verified that the test failed before #845 came in.
2019-09-04 14:26:25 -07:00
Brandur
70be52cc2b Bump version to 5.1.1 2019-09-04 14:22:58 -07:00
Alica Moser
b7495eb2e4 Transfer the request_id from the http_headers to error. (#845)
When requesting error#request_id it returned nil although the request id was available in the request headers. With version 5 and switch to Net::HTTP this value is now a string, not a symbol which means that the request_id was not stored on the error correctly.
2019-09-04 14:13:53 -07:00
Brandur
44451725e4 Bump version to 5.1.0 2019-08-27 14:25:25 -07:00
Brandur
3e21fa977a Retry requests on a 429 that's a lock timeout (#841)
Tweaks the retry logic so that 429s which have the special status code
lock_timeout are retried automatically.

Similar to what was recently implemented in Go: stripe/stripe-go#935
2019-08-27 14:22:55 -07:00
Brandur
82b5e510b9 Extract SSL verify none warning to its own method (#837)
A tiny refactor where we extract the warning you get when setting SSL
verify mode to `VERIFY_NONE` into its own method. No real impetus for
this except that it extracts very nicely, and that gets us to a smaller
`create_connection` method.
2019-08-20 14:19:36 -07:00
Brandur
5b975f66ee Bump version to 5.0.1 2019-08-20 13:55:24 -07:00
Brandur
650114abca Increase connection keep alive timeout to 30 seconds (#836)
One thing I forgot to look into was how long Ruby will hold a connection
open by default. It turns out that the language default is very low at
only two seconds. Here we increase it to 30 seconds, which is a more
reasonable default. I took this number from Go's `DefaultTransport`,
which seems to have been working pretty well so far.

I tested with a script that keeps a connection idle to Stripe for a long
period of time before issuing a new request and everything seems to be
working well.
2019-08-20 13:54:34 -07:00
Brandur
1f0a3d3ec8 Tweak comment to call out .clear (new since it was written) 2019-08-20 13:52:03 -07:00
Olivier Bellone
b31632aec9
Bump version to 5.0.0 2019-08-20 12:09:17 -07:00
Olivier Bellone
6fc69414e2
[codegen] Run codegen for stripe-ruby v5 (#835)
* Codegen for openapi 63fe31a

* Fix test
2019-08-20 12:02:20 -07:00
Brandur
44766516d9 stripe-ruby V5 (#815)
* Convert library to use built-in `Net::HTTP`

Moves the library off of Faraday and over onto the standard library's
built-in `Net::HTTP` module. The upside of the transition is that we
break away from a few dependencies that have caused us a fair bit of
trouble in the past, the downside is that we need more of our own code
to do things (although surprisingly, not that much more).

The biggest new pieces are:

* `ConnectionManager`: A per-thread class that manages a connection to
  each Stripe infrastructure URL (like `api.stripe.com`,
  `connect.stripe.com`, etc.) so that we can reuse them between
  requests. It's also responsible for setting up and configuring new
  `Net::HTTP` connections, which is a little more heavyweight
  code-wise compared to other libraries. All of this could have lived in
  `StripeClient`, but I extracted it because that class has gotten so
  big.

* `MultipartEncoder`: A class that does multipart form encoding for file
  uploads. Unfortunately, Ruby doesn't bundle anything like this. I
  built this by referencing the Go implementation because the original
  RFC is not very detailed or well-written. I also made sure that it was
  behaving similarly to our other custom implementations like
  stripe-node, and that it can really upload a file outside the test
  suite.

There's some risk here in that it's easy to miss something across one of
these big transitions. I've tried to test out various error cases
through tests, but also by leaving scripts running as I terminate my
network connection and bring it back. That said, we'd certainly release
on a major version bump because some of the interface (like setting
`Stripe.default_client`) changes.

* Drop support for old versions of Ruby

Drops support for Ruby 2.1 (EOL March 31, 2017) and 2.2 (EOL March 31,
2018). They're removed from `.travis.yml` and the gemspec and RuboCop
configuration have also been updated to the new lower bound.

Most of the diff here are minor updates to styling as required by
RuboCop:

* String literals are frozen by default, so the `.freeze` we had
  everywhere is now considered redundant.

* We can now use Ruby 1.9 style hash syntax with string keys like `{
  "foo": "bar" }`.

* Converted a few heredocs over to use squiggly (leading whitespace
  removed) syntax.

As discussed in Slack, I didn't drop support for Ruby 2.3 (EOL March 31,
2019) as we still have quite a few users on it. As far as I know
dropping it doesn't get us access to any major syntax improvements or
anything, so it's probably not a big deal.

* Make `CardError`'s `code` parameter named instead of positional (#816)

Makes the `code` parameter on `CardError` named instead of positional.
This makes it more consistent with the rest of the constructor's
parameters and makes instantiating `CardError` from `StripeClient`
cleaner.

This is a minor breaking change so we're aiming to release it for the
next major version of stripe-ruby.

* Bump Rubocop to latest version (#818)

* Ruby minimum version increase followup (#819)

* Remove old deprecated methods (#820)

* Remove all alias for list methods (#823)

* Remove UsageRecord.create method (#826)

* Remove IssuerFraudRecord (#827)

* Add ErrorObject to StripeError exceptions (#811)

* Tweak retry logic to be a little more like stripe-node (#828)

Tweaks the retry logic to be a little more like stripe-node's. In
particular, we also retry under these conditions:

* If we receive a 500 on a non-`POST` request.
* If we receive a 503.

I made it slightly different from stripe-node which checks for a 500
with `>= 500`. I don't really like that -- if we want to retry specific
status codes we should be explicit about it.

We're actively re-examining ways on how to make it easier for clients to
figure out when to retry right now, but I figure V5 is a good time to
tweak this because the modifications change the method signature of
`should_retry?` slightly, and it's technically a public method.

* Fix inverted sign for 500 retries (#830)

I messed up in #828 by (1) accidentally flipping the comparison against
`:post` when checking whether to retry on 500, and (2) forgetting to
write new tests for the condition, which is how (1) got through.

This patch fixes both those problems.

* Remove a few more very old deprecated methods (#831)

I noticed that we had a couple of other deprecated methods on `Stripe`
and `StripeObject` that have been around for a long time. May as well
get rid of them too -- luckily they were using `Gem::Deprecate` so
they've been producing annoying deprecated warnings for quite a while
now.

* Remove extraneous slash at the end of the line

* Reset connections when connection-changing configuration changes (#829)

Adds a few basic features around connection and connection manager
management:

* `clear` on connection manager, which calls `finish` on each active
  connection and then disposes of it.

* A centralized cross-thread tracking system for connection managers in
  `StripeClient` and `clear_all_connection_managers` which clears all
  known connection managers across all threads in a thread-safe way.

The addition of these allow us to modify the implementation of some of
our configuration on `Stripe` so that it can reset all currently open
connections when its value changes.

This fixes a currently problem with the library whereby certain
configuration must be set before the first request or it remains fixed
on any open connections. For example, if `Stripe.proxy` is set after a
request is made from the library, it has no effect because the proxy
must have been set when the connection was originally being initialized.

The impetus for getting this out is that I noticed that we will need
this internally in a few places when we're upgrading to stripe-ruby V5.
Those spots used to be able to hack around the unavailability of this
feature by just accessing the Faraday connection directly and resetting
state on it, but in V5 `StripeClient#conn` is gone, and that's no longer
possible.

* Minor cleanup in `StripeClient` (#832)

I ended up having to relax the maximum method line length in a few
previous PRs, so I wanted to try one more cleanup pass in
`execute_request` to see if I could get it back at all.

The answer was "not by much" (without reducing clarity), but I found a
few places that could be tweaked. Unfortunately, ~50 lines is probably
the "right" length for this method in that you _could_ extract it
further, but you'd end up passing huge amounts of state all over the
place in method parameters, and it really wouldn't look that good.

* Do better bookkeeping when tracking state in `Thread.current` (#833)

This is largely just another cleanup patch, but does a couple main
things:

* Hoists the `last_response` value into thread state. This is a very
  minor nicety, but effectively makes `StripeClient` fully thread-safe,
  which seems like a minor nicety. Two calls to `#request` to the same
  `StripeObject` can now be executed on two different threads and their
  results won't interfere with each other.

* Moves state off one-off `Thread.current` keys and into a single one
  for the whole client which stores a new simple type of record called
  `ThreadContext`. Again, this doesn't change much, but adds some minor
  type safety and lets us document each field we expect to have in a
  thread's context.

* Add Invoice.list_upcoming_line_items method (#834)
2019-08-20 11:35:24 -07:00
Brandur
8b45b1d980 Change max retry copy to match up to stripe-python's 2019-08-14 09:21:44 -07:00
Olivier Bellone
2a78934d15
Bump version to 4.24.0 2019-08-12 17:21:14 -07:00
Olivier Bellone
14d470cffc
[codegen] Update API Resources (#825)
* Codegen for openapi c806fa1

* Add tests
2019-08-12 17:15:29 -07:00
Alex Rattray
bc77404518 Bump version to 4.23.0 2019-08-09 17:32:44 -07:00
Alex Rattray (Stripe)
1272a3fc94
[codegen] Remove SubscriptionScheduleRevision (#824)
* Codegen for openapi c806fa1

* Remove tests and standalone resource for SubscriptionScheduleRevision

* Fix rubocop
2019-08-09 15:57:03 -07:00
Alex Rattray
8d4c744b97 Bump version to 4.22.1 2019-08-09 12:25:19 -07:00
Alex Rattray (Stripe)
d369e840b2
Merge pull request #808 from stripe/ralex/unified_requests
Unify request/response handling
2019-08-08 11:32:16 -07:00
Alex Rattray
17d689a9a8 Flesh out tests 2019-08-06 18:19:41 -07:00
Alex Rattray
69b5e6e1c3 Rename to request_stripe_object, use with codegen 2019-08-06 17:23:11 -07:00
Alex Rattray
bd833fe57c sketch out test... 2019-08-02 12:34:53 -07:00
Alex Rattray
5e8faa28ed wip 2019-08-02 12:34:53 -07:00
Alex Rattray
bb55352658 Fix issuing card details, which must have been broken prior to ea736eb 2019-08-02 12:34:53 -07:00
Alex Rattray
43756df814 Revert "Use Util.convert_to_stripe_object instead of initialize_from"
This reverts commit ea736eba1b8f33d8febbf0b1be0957f34f7b04db.
2019-08-02 12:34:40 -07:00
Remi Jannel
86da04c245 Bump version to 4.22.0 2019-07-30 12:17:08 -07:00
remi-stripe
3b99282ea9
Merge pull request #821 from stripe/remi-fix-bt
Move Balance History to /v1/balance_transactions and add tests
2019-07-30 12:15:40 -07:00
Remi Jannel
49f7201052 Move Balance History to /v1/balance_transactions and add tests 2019-07-30 11:54:48 -07:00
Brandur
382ae0b45d Bump version to 4.21.3 2019-07-15 17:07:20 -07:00
Brandur
ec015a26a1
Merge pull request #810 from stripe/brandur-raise-argument-error
Better error message when passing non-string to custom method
2019-07-15 17:06:35 -07:00
Brandur
d71cda7adf Better error message when passing non-string to custom method
Raises a slightly more helpful error message when passing a non-string
to a custom method (currently, it reads "no implicit conversion of Hash
into String", which is terrible).

This a partial remediation for the problem encountered in #809.
2019-07-15 16:38:05 -07:00
Brandur
267eae5e85 Bump version to 4.21.2 2019-07-05 10:48:52 -07:00
Alex Rattray (Stripe)
d1ccff025e Revert back to initialize_from from Util.convert_to_stripe_object (#806)
* Revert "Use Util.convert_to_stripe_object instead of initialize_from"

This reverts commit ea736eba1b8f33d8febbf0b1be0957f34f7b04db.

* Make SetupIntents use initialize_from instead of Util.convert_to_stripe_object

* Fix issuing card details, which must have been broken prior to ea736eb
2019-07-05 10:47:32 -07:00
Olivier Bellone
cb1bd30cf6
Bump version to 4.21.1 2019-07-04 15:48:56 -07:00
Olivier Bellone
50748b1189
Add gem metadata (#807) 2019-07-04 15:47:45 -07:00
Remi Jannel
431124356f Bump version to 4.21.0 2019-06-28 11:09:51 -07:00
remi-stripe
737dd5f593
Merge pull request #803 from stripe/remi-setupintents
Add support for SetupIntent
2019-06-28 11:08:23 -07:00
Brandur
5b5b0f5722 Bump version to 4.20.1 2019-06-28 08:21:24 -07:00
Brandur
f4b874d304
Merge pull request #805 from jcsrb/patch-1
Fix formatting in ConnectionFailed error message
2019-06-28 08:20:40 -07:00
Jakob Cosoroabă
212ca4bb0a
Fix formatting in ConnectionFailed error message
Add space at the end of the second line so the complete message separates the word `not` and `working`

message before
```
Stripe::APIConnectionError: Unexpected error communicating when trying to connect to Stripe. You may be seeing this message because your DNS is notworking.  To check, try running `host stripe.com` from the command line.
```
message after
```
Stripe::APIConnectionError: Unexpected error communicating when trying to connect to Stripe. You may be seeing this message because your DNS is not working.  To check, try running `host stripe.com` from the command line.
```
2019-06-28 13:19:57 +03:00
Remi Jannel
a993e892b3 Add support for the SetupIntent resource and APIs 2019-06-27 12:55:35 -07:00
Olivier Bellone
2cc77147d2
Bump version to 4.20.0 2019-06-24 18:07:50 -07:00
Olivier Bellone
47686d844b
Enable request latency telemetry by default (#800) 2019-06-24 18:07:28 -07:00
Remi Jannel
f25d080e3b Bump version to 4.19.0 2019-06-17 11:50:18 -07:00
remi-stripe
d10b5c84b5
Merge pull request #770 from stripe/remi-add-customer-balance-transactions
Add support for Customer Balance Transaction resource and APIs
2019-06-17 11:49:18 -07:00
Remi Jannel
abef09ef6e Add support for CustomerBalanceTransaction resource and APIs 2019-06-16 10:49:47 -07:00
remi-stripe
b6672807d2
Merge pull request #793 from stripe/remi-fix-readme
Fix examples to not use hash rockets
2019-06-12 14:13:26 -07:00
Remi Jannel
54dcf73d96 Fix examples to not use hash rockets 2019-06-12 10:56:16 -07:00
Alex Rattray (Stripe)
0d7968b97b
Merge pull request #791 from stripe/ralex/codegen-2
Some small changes to object_types for codegen
2019-05-31 18:25:12 -04:00
Alex Rattray
bc9fed3635 Some small changes to object_types for codegen 2019-05-30 17:44:52 -04:00
Alex Rattray (Stripe)
1ed21bcb57
Merge pull request #790 from stripe/ralex/codegen
Formatting changes from codegen
2019-05-30 10:56:11 -04:00
Alex Rattray
d998c3342e Only ignore line-length on resources 2019-05-29 21:07:34 -04:00
Alex Rattray
64571bee75 Move resources to their own folder 2019-05-29 21:03:37 -04:00
Alex Rattray
58d47e96f8 Move resource requires into their own file 2019-05-29 18:45:57 -04:00
Alex Rattray
01c5776b06 Add some private methods back to Order 2019-05-29 18:24:56 -04:00
Alex Rattray
ea736eba1b Use Util.convert_to_stripe_object instead of initialize_from 2019-05-29 18:24:42 -04:00
Alex Rattray
0d465ce91c More reordering and hopefully-safe formatting changes 2019-05-29 18:16:29 -04:00
Alex Rattray
91cfc0f748 Deprecate Transfer#cancel_url 2019-05-29 12:55:24 -04:00
Alex Rattray
9a21c99966 Move object types map to its own file 2019-05-29 11:36:07 -04:00
Alex Rattray
bc2a5e0deb Exclude stripe dir from line length limit 2019-05-29 11:34:35 -04:00
Alex Rattray
eff920662e Some safe transformations from codegen 2019-05-29 11:34:16 -04:00
Olivier Bellone
4c95b992cf
Bump version to 4.18.1 2019-05-27 17:38:19 -07:00
mbianco-stripe
41538b3970 Order#pay without arguments (#789)
* Don't require params in order.pay

* Test for order#pay without arguments
2019-05-27 17:36:43 -07:00
Olivier Bellone
ec91de6849
Upgrade Rubocop and fix a bunch of issues (#786)
* Bump Rubocop to 0.57.2

* Style/StderrPuts: Use warn instead of .puts

* Style/ExpandPathArguments: Use expand_path('../test_helper', __dir__) instead of expand_path('../../test_helper', __FILE__)

* Style/Encoding: Unnecessary utf-8 encoding comment

* Style/StringLiterals: Prefer double-quoted strings

* Style/AccessModifierDeclarations

* Style/FormatStringToken: Prefer annotated tokens

* Naming/UncommunicativeMethodParamName

* Metrics/LineLength: set maximum line length to 100 characters

* Style/IfUnlessModifier: Favor modifier if usage when having a single-line body

* Style/ClassVars

* Metrics/LineLength: set maximum line length to 80 characters (default)

* Style/AccessModifierDeclarations: EnforcedStyle: inline
2019-05-24 10:43:42 -07:00
Olivier Bellone
7fa3585e82
Bump version to 4.18.0 2019-05-23 17:41:31 -07:00
Olivier Bellone
f68fb25b83
Add support for radar.early_fraud_warning resource (#783) 2019-05-23 17:40:54 -07:00
Olivier Bellone
f6d4910877
Test Ruby 2.6 in Travis CI (#785) 2019-05-23 17:32:05 -07:00
Olivier Bellone
6612b5b3c6
Bump stripe-mock to 0.57.0 and fix tests (#784) 2019-05-23 17:27:14 -07:00
Olivier Bellone
ab180e7dfc
Add VSCode and EditorConfig files (#782) 2019-05-23 15:47:37 -07:00
Olivier Bellone
b26d57c90e
Bump version to 4.17.0 2019-05-14 11:52:53 -07:00
remi-stripe
270e88b169 Add support for the Capability resource and APIs (#779) 2019-05-14 11:52:04 -07:00
Pavel Pravosud
793a61ccfb Apply safe transformations from current codegen (#777) 2019-05-08 16:09:53 -07:00
Pavel Pravosud
b13fc8465f Remove explicit Util.normalize_opts calls (#778) 2019-05-07 18:20:07 -07:00
Pavel Pravosud
cd05d363f8 More simplifying inheritance (#775) 2019-05-06 17:34:23 -07:00
Pavel Pravosud
14d6a4e6bf More method sorting for Topup class (#776) 2019-05-06 17:26:51 -07:00
Pavel Pravosud
044aa5286e Sort includes by method name for consistency (#773) 2019-05-06 13:15:58 -07:00
Pavel Pravosud
9832c5354f Simplify inheritance for nested classes (#769) 2019-05-06 11:19:53 -07:00
Michael Bianco
322a8c60be Readme example of expanding parameters and specifying a per-request API version (#642)
These options aren't immediately appartent without digging through
the client source code
2019-04-30 09:53:48 -07:00
Remi Jannel
93deaef626 Bump version to 4.16.0 2019-04-24 14:26:18 -07:00
remi-stripe
27c4d3dc2f
Merge pull request #760 from stripe/remi-add-tax-rates
Add support for TaxRate resource and APIs
2019-04-24 14:23:40 -07:00
Remi Jannel
962538b149 Add support for TaxRate resource and APIs 2019-04-23 09:56:03 -07:00
Remi Jannel
b5b15f390e Bump version to 4.15.0 2019-04-22 16:42:48 -07:00
remi-stripe
959bb706a4
Merge pull request #762 from stripe/remi-add-tax-ids
Add support for TaxId resource and APIs
2019-04-22 16:41:54 -07:00
Remi Jannel
b5cd9e3682 Add support for TaxId resource and APIs 2019-04-19 10:13:57 -07:00
Remi Jannel
5416f020d8 Bump version to 4.14.0 2019-04-18 12:29:34 -07:00
remi-stripe
06498dbe14
Merge pull request #758 from stripe/remi-add-creditnote
Add support for CreditNote
2019-04-18 12:24:05 -07:00
Brandur
d915cd6284 Bump version to 4.13.0 2019-04-16 11:50:37 -07:00
Brandur
c7db5de52f
Merge pull request #766 from stripe/brandur-relax-file-constraints
Relax constraints on objects that we'll accept as a file
2019-04-16 11:49:09 -07:00
Brandur
81b7cb3ca8 Relax constraints on objects that we'll accept as a file
When uploading a file, we previously made a check on whether it
supported both `#read` and `#path` before wrapping it in a
`Faraday::UploadIO` and sending it off. The second check on `#path`
isn't strictly necessary, and as reported in #761 can prevent objects
created by `open-uri` from being compatible with file upload.

Here we remove the check `#path` so that we just require that objects
support `#read`, and in addition error when an object is passed that's
not file-compatible and not a string. This should prevent users from
seeing the very confusing "Invalid hash" error in these situations.

Fixes #761.
2019-04-16 08:33:42 -07:00
remi-stripe
42d475b638
Merge pull request #763 from stripe/remi-bring-nested-tests-up
Move tests for nested resources up to the parent class
2019-04-15 09:47:20 -07:00
Remi Jannel
5aa63d2cc6 Move tests for nested resources up to the parent class 2019-04-12 19:23:52 -07:00
Remi Jannel
0233deb5c6 Add support for CreditNote 2019-04-07 09:47:43 -07:00
remi-stripe
c3e65b2552 Fix our test suite for latest stripe-mock (#757) 2019-04-05 21:11:24 -07:00
Olivier Bellone
81035d401f
Include file_link_data parameter in file creation test (#756) 2019-04-05 14:43:52 -07:00
Olivier Bellone
796f4bd63c
Fix minimum Ruby version in README.md 2019-04-03 10:49:12 -07:00
Olivier Bellone
51d167aa29
Bump version to 4.12.0 2019-04-02 10:28:11 -07:00
Olivier Bellone
0790bb4154
Static methods for delete (#752)
New `.delete` class method on deletable API resources
2019-04-02 10:25:05 -07:00
Olivier Bellone
160028ada1
New custom_method DSL for defining custom API request methods as static methods (#754)
New `custom_method` DSL for defining custom API request methods as static methods
2019-04-02 10:06:40 -07:00
Olivier Bellone
bb25d09052 Bump version to 4.11.0 2019-03-26 09:06:55 -07:00
Olivier Bellone
d98e40697b
Merge pull request #753 from stripe/ob-proxy
Add a global proxy configuration parameter
2019-03-26 09:05:35 -07:00
Olivier Bellone
6e95bf45f9 Add a global proxy configuration parameter 2019-03-25 18:34:12 -07:00
Remi Jannel
287a2e6979 Bump version to 4.10.0 2019-03-18 16:48:39 -07:00
remi-stripe
39d66c00ce
Merge pull request #745 from stripe/remi-add-payment-methods
Add support for the PaymentMethod resource
2019-03-18 16:42:53 -07:00
remi-stripe
7b9b7b6aab
Merge pull request #748 from stripe/remi-add-terminal-delete
Add support for Terminal Location and Reader deletion
2019-03-18 16:41:08 -07:00
remi-stripe
26ac12679c
Merge pull request #747 from stripe/remi-add-checkout-session-retrieve
Add support for retrieving a Checkout Session
2019-03-18 16:41:01 -07:00
Remi Jannel
f93c0075c0 Add support for the PaymentMethod resource 2019-03-18 16:30:51 -07:00
Remi Jannel
de204dda1c Add support for retrieving a Checkout Session 2019-03-18 16:29:04 -07:00
Remi Jannel
031075c954 Add support for Terminal Location and Reader deletion 2019-03-18 16:28:24 -07:00
Brandur
67edf85459 Bump version to 4.9.1 2019-03-18 12:52:10 -07:00
Brandur
c1894e8f3e
Merge pull request #750 from stripe/brandur-warn-on-remove-error
Catch error and warn if unable to remove a method
2019-03-18 12:51:03 -07:00
Brandur
8702e714bc Catch error and warn if unable to remove a method
In some cases there can be a method that's detected with
`method_defined?`, but which cannot be removed with `remove_method`,
even though it's on the same class. The only case so far that we've
noticed this is when a class is reopened for monkey patching like in
issue #749.

We'll still try to discourage this sort of use, but here we swallow the
error and issue a warning so at least the program doesn't crash.

Fixes #749.
2019-03-18 11:52:35 -07:00
remi-stripe
df8c141bb8
Merge pull request #746 from stripe/remi-fix-tests
Fix tests to work on latest stripe-mock for future updates
2019-03-05 10:34:30 -08:00
Remi Jannel
1094e894cc Fix tests to work on latest stripe-mock for future updates 2019-03-05 10:16:49 -08:00
Brandur
c139dc890d Update changelog convention for yanked version 2019-02-20 11:25:30 -08:00
Remi Jannel
ab8704ed34 Bump version to 4.9.0 2019-02-12 08:54:31 -08:00
remi-stripe
7af2826ad1
Merge pull request #739 from stripe/remi-add-subscription-schedules
Add support for Subscription Schedules
2019-02-12 08:51:47 -08:00
Remi Jannel
d784819901 Add support for Subscription Schedules 2019-02-11 22:38:08 -08:00
Brandur
c070c05237 Bump version to 4.8.1 2019-02-11 11:28:47 -08:00
Brandur
65cc699832
Merge pull request #743 from stripe/brandur-remove-file-encoding
Remove attempt to nicen `UploadIO` in logs
2019-02-11 11:22:55 -08:00
Brandur
cf6d79a1ca Remove attempt to nicen UploadIO in logs
In #741 I tried to do something too clever by replacing instances of
`Faraday::UploadIO` found in parameters with a human-readable string to
improve `STRIPE_LOG` logging output.

I thought I'd tested it at the time, but apparently not (or not well
enough), and this change caused the regression detailed in #742.

My findings about how Faraday encodes multipart were apparently wrong
and it does use these parameters, so here we remove the step where we
try to nicen them for logging. The logs look a little worse, but it's
not that big of a deal.

I've tested this patch against the API and confirmed that it addresses
the problem.

Fixes #742.
2019-02-11 11:14:27 -08:00
Brandur
e0438d27a8 Bump version to 4.8.0 2019-02-03 12:26:29 -08:00
Brandur
c1fa537e34
Merge pull request #741 from stripe/brandur-simpler-encoding
Use `FaradayStripeEncoder` to encode all parameter styles
2019-02-03 12:25:14 -08:00
Brandur
9dd5bdb0e6 Use FaradayStripeEncoder to encode all parameter styles
Makes a few tweaks to hopefully simplify clarity things:

* `FaradayStripeEncoder` now becomes the way to encode all of form,
  multipart form, and query parameters.
* Introduce a cache in it so that we don't have to encode everything
  twice (once for logging, and once for the request body).
* Try to sanitize logging a bit by replacing `Faraday::UploadIO`s found
  in incoming parameters with a string representation of the file (note
  that all other styles of file input like `File` or `Tempfile` have
  been converted to `Faraday::UploadIO` by the time they reach the
  encoder).
2019-02-03 12:24:53 -08:00
Brandur
3798cadfcc Fix a few comments 2019-02-01 12:47:36 -08:00
Brandur
58512a90d8 Bump version to 4.7.1 2019-02-01 09:28:47 -08:00
Brandur
42d4f42b12
Merge pull request #740 from stripe/brandur-fix-query-encoding
Fix query encoding for integer-indexed maps
2019-02-01 09:28:00 -08:00
Brandur
07f939b46b Fix query encoding for integer-indexed maps
As reported in #608, integer-indexed maps currently work when passed as
part of the body, but they are reverted to non-indexed maps when passed
in the query.

It turns out that we actually had two problems:

1. We weren't calling our `Util.encode_parameters` on our query
   parameters anywhere, and it's this method will does the integer
   encoding.

2. Even when I fixed (1) by calling `Util.encode_parameters`, Faraday
   would still strip the integer indexes as they were transformed in
   its default `NestedParamsEncoder`.

Here we fix both issues by calling `Util.encode_parameters` and sending
Faraday a custom encoder which bypasses its normal shenanigans.

Unfortunately, this has turned out to be somewhat difficult to test
because the integer-indexed maps also seem to confuse Webmock, which
strips them down to standard maps (I even tried testing against a
string, and it still got it wrong). I did use stripe-mock though to
verify that we are now sending the right payload.

Fixes #608.
2019-02-01 09:14:54 -08:00
Remi Jannel
94bafb451f Bump version to 4.7.0 2019-01-23 15:47:00 -08:00
remi-stripe
3366cacd6a
Merge pull request #735 from stripe/remi-fix-checkout-sessions
Move CheckoutSession to the Checkout namespace and rename to Session
2019-01-23 15:40:26 -08:00
Brandur
41b6968787
Merge pull request #738 from stripe/brandur-port-in-output
Add port in "started stripe-mock" output
2019-01-22 12:25:37 -08:00
Brandur
15af271408 Add port in "started stripe-mock" output
A tiny tweak to add the port chosen by stripe-mock to the "starting
stripe-mock" output. This gives the user a little more information
(which might be handy if something isn't working), and brings it inline
with Go's output format: https://github.com/stripe/stripe-go/pull/780
2019-01-22 12:15:31 -08:00
Brandur
a5472ed04a
Merge pull request #737 from stripe/brandur-select-port
Have stripe-mock select a port number
2019-01-22 09:00:56 -08:00
Olivier Bellone
130704a09a
Bump version to 4.6.0 2019-01-21 13:21:22 +01:00
Olivier Bellone
bc62c80320
Merge pull request #736 from stripe/ob-serialize-individual
Properly serialize `individual` on Account objects
2019-01-21 13:19:13 +01:00
Brandur
ad20248ee3 Have stripe-mock select a port number
When starting a stripe-mock for a custom OpenAPI spec, pass `-http-port
0` on startup, which tells stripe-mock to select a port, then extract
that port from its output.

This is not a total win because we now have to rely on string matching,
but it is better in that (1) it gets a port more efficiently, (2) it
eliminates a race condition where another process could take the port we
found before stripe-mock gets to start, and (3) it starts a little
faster as we take advantage of the fact that we know stripe-mock has
started when we've found a port in its output (in my tests it took ~0.2
to 0.3 seconds compared to a 1 second sleep).
2019-01-18 16:38:52 -08:00
Olivier Bellone
6b89b3b6c1
Properly serialize individual on Account objects 2019-01-18 15:31:47 +01:00
Remi Jannel
359a0c9cdf Move CheckoutSession to the Checkout namespace and rename to Session 2019-01-16 18:50:14 -08:00
Olivier Bellone
7f55cf3a9c
Merge pull request #715 from stripe/ob-openapi-files
Detect custom OpenAPI spec file and start stripe-mock from test suite
2019-01-11 12:08:49 +01:00
Olivier Bellone
dbf8a41244
Embed OpenAPI files and start stripe-mock from test suite 2019-01-10 15:06:01 +01:00
mickjermsurawong-stripe
9776f674f1
Merge pull request #734 from stripe/mickjermsurawong/update-stripe-mock-version
bump strip mock version to 0.40.1
2019-01-09 16:03:34 -08:00
Mick Jermsurawong
652047f130 bump strip mock version to 0.40.1 2019-01-09 15:55:41 -08:00
Olivier Bellone
af1c829a41
Merge pull request #721 from stripe/ob-fix-ci
CI fixes
2019-01-05 20:22:44 +01:00
Olivier Bellone
fe4e21c8db
Remove to_hash method on NilClass after test 2019-01-04 17:34:51 +01:00
Olivier Bellone
0a63716682
Pin bundler to 1.x 2019-01-04 16:02:56 +01:00
Brandur
55b4d78026 Bump version to 4.5.0 2019-01-02 08:00:53 -07:00
Brandur
365759e0b0
Merge pull request #719 from stripe/brandur-support-express-authorize
Generate OAuth authorize URLs for express accounts
2019-01-02 08:00:02 -07:00
Brandur
403be3b106 Generate OAuth authorize URLs for express accounts
Connect with Express accounts uses a slightly different version of the
OAuth authorize URL [1] in that it's prefixed with `/express`.

Here we add a new option to `Stripe::OAuth.authorize_url` which allows
`express: true` to be passed in to generate the Express variant.

Note that the token endpoint has no equivalent so we don't need the
option there.

Fixes #717.

[1] https://stripe.com/docs/connect/oauth-reference#express-account-differences
2018-12-31 13:47:35 -07:00
Brandur
6f81c907e8 Bump version to 4.4.1 2018-12-31 11:09:56 -07:00
Brandur
4d7f15f881
Merge pull request #718 from seratch/typo-misspell
Fix typo/misspell in comments & error messages
2018-12-31 10:07:44 -08:00
Kazuhiro Sera
4081d8c5ed Fix typo/misspell in comments & error messages 2018-12-31 15:26:56 +09:00
Remi Jannel
e2c352de07 Bump version to 4.4.0 2018-12-21 09:43:55 +01:00
remi-stripe
b99ed974d4
Merge pull request #716 from stripe/remi-add-checkout-sessions
Add support for Checkout Sessions
2018-12-21 09:39:19 +01:00
Remi Jannel
0747d59752 Add support for the Checkout Session resource 2018-12-21 09:20:29 +01:00
Olivier Bellone
98851f9ad3
Bump version to 4.3.0 2018-12-10 17:21:21 -08:00
Olivier Bellone
ab17913243
Merge pull request #711 from stripe/remi-add-account-links
Add support for the Account Link resource
2018-12-11 02:20:50 +01:00
Remi Jannel
220bac9397 Add support for the Account Link resource 2018-12-07 16:06:04 -08:00
Remi Jannel
c186e71c92 Revert "Add support for the Account Link resource"
This reverts commit 335c40b4d8cf974c427f34024072272441a5131e.
2018-12-07 16:05:05 -08:00
Remi Jannel
335c40b4d8 Add support for the Account Link resource 2018-12-07 15:54:50 -08:00
Remi Jannel
b34d527f60 Bump version to 4.2.0 2018-11-28 11:42:22 -05:00
remi-stripe
ed10fc811d
Merge pull request #705 from stripe/remi-add-radar-review
Add support for the Review resource
2018-11-28 10:50:06 -05:00
Remi Jannel
0383de9dc2 Add support for the Review resource 2018-11-28 09:50:42 -05:00
Olivier Bellone
3c7995f030
Bump version to 4.1.0 2018-11-27 14:17:38 +01:00
Olivier Bellone
e66705aa84
Merge pull request #695 from stripe/remi-add-radar-lists
Add support for Radar List and ListItem resources
2018-11-27 14:16:35 +01:00
Remi Jannel
ceab2740c1
Add support for Radar List and ListItem resources 2018-11-27 14:10:18 +01:00
Brandur
67c88f3572 Bump version to 4.0.3 2018-11-19 08:29:15 -08:00
Brandur
d54ac0439e
Merge pull request #703 from stripe/ob-fix-windows
Don't use net-http-persistent on Windows
2018-11-19 08:28:02 -08:00
Olivier Bellone
bea6d5dd12
Don't use net-http-persistent on Windows 2018-11-19 12:37:58 +01:00
Olivier Bellone
aa611c268c
Bump version to 4.0.2 2018-11-16 18:07:00 +01:00
Olivier Bellone
42f4c84505
Merge pull request #701 from stripe/ob-bump-faraday
Bump Faraday minimum version to 0.13.0
2018-11-16 18:05:20 +01:00
Olivier Bellone
c80a491e03
Bump Faraday minimum version to 0.13.0 2018-11-16 13:54:26 +01:00
Brandur
63d95e1e34 Bump version to 4.0.1 2018-11-15 14:54:06 -08:00
Brandur
10f235584c
Merge pull request #699 from stripe/brandur-check-request-id
Only send telemetry if request ID was present
2018-11-15 14:53:29 -08:00
Brandur
78df532c8c Only send telemetry if request ID was present
Tweaks telemetry implementation slightly to be inline with the recent
implementation in stripe-php. Telemetry isn't much good if a request ID
wasn't present, so we only send telemetry if it was.
2018-11-15 14:45:45 -08:00
Brandur
8c4813fcbf Bump version to 4.0.0 2018-11-15 10:41:58 -08:00
Brandur
770a97e6f9
Merge pull request #698 from stripe/brandur-net-http-persistent
Use Faraday's `Net::HTTP::Persistent` adapter
2018-11-15 10:38:17 -08:00
Brandur
85013c9770 Use Faraday's Net::HTTP::Persistent adapter
This changes the library's default connection over to use the adapter
for `Net::HTTP::Persistent`, which is a connection pooling library for
Ruby.

In the long run, I think we should probably just drop Faraday ... the
amount of value it's getting us is extremely tenuous and its API is
difficult to work with. I hate to do it at this point though because
technically people could be writing custom middleware for it.
2018-11-15 08:55:28 -08:00
Brandur
7a444d8fb0 Bump version to 3.31.1 2018-11-12 16:42:22 -08:00
Brandur
d2c3a55d4e
Merge pull request #697 from stripe/akropp-telemetry-in-ms
Making stripe telemetry more specific in terms of units
2018-11-12 16:41:34 -08:00
Anton Kropp
5e3c3a9b45
Making stripe telemetry more specific in terms of units 2018-11-12 16:35:21 -08:00
Brandur
ba23aa5e2c Bump version to 3.31.0 2018-11-12 10:44:20 -08:00
Brandur
9bc61c675a
Merge pull request #696 from stripe/akropp-add-client-telemetry
Adding metadata header to client requests
2018-11-12 10:42:32 -08:00
Anton Kropp
ab248ec691
Adding metadata header to client requests 2018-11-12 10:24:06 -08:00
Remi Jannel
e2f4fa23d0 Bump version to 3.30.0 2018-11-08 17:41:11 -08:00
remi-stripe
a53e7d9f68
Merge pull request #693 from stripe/remi-add-invoice-methods
Add new methods to the Invoice resource
2018-11-08 17:36:16 -08:00
Remi Jannel
bbec79ccba Add new methods to the Invoice resource 2018-11-08 17:28:55 -08:00
Remi Jannel
d62f12f277 Bump version to 3.29.0 2018-10-30 10:48:15 -07:00
remi-stripe
4cee6fdb1b
Merge pull request #694 from stripe/remi-add-webhook-endpoint
Add support for the Webhook Endpoint resource
2018-10-30 10:45:17 -07:00
Remi Jannel
da9d15df95 Add support for the Webhook Endpoint resource 2018-10-30 10:36:10 -07:00
remi-stripe
fa3dc321b7
Merge pull request #692 from stripe/remi-add-person
Add support for the Person resource
2018-10-30 10:30:59 -07:00
Remi Jannel
23d94005d3 Add support for the Person resource 2018-10-30 10:25:10 -07:00
Brandur
9bc6ae85a5 Bump version to 3.28.0 2018-09-24 16:14:36 -06:00
Brandur
7b939cb7d8
Merge pull request #690 from stripe/daz-terminal-bindings
Bindings for Terminal endpoints
2018-09-24 16:14:09 -06:00
David Zhu
cd5e3a7077 Linting issues 2018-09-24 13:50:06 -07:00
David Zhu
51f4550c2f Bump StripeMock version 2018-09-24 13:43:49 -07:00
David Zhu
b3055bfd44 Terminal Bindings 2018-09-24 13:43:32 -07:00
Olivier Bellone
6237a28b87
Bump version to 3.27.0 2018-09-24 21:10:29 +02:00
Olivier Bellone
e20b44d5da
Merge pull request #689 from stripe/ob-file-resource
Handle `file` objects like `file_upload`
2018-09-24 21:09:26 +02:00
Olivier Bellone
9d64d31e2a
Upgrade stripe-mock 2018-09-22 16:52:58 +02:00
Olivier Bellone
ea09249e67
Use files.stripe.com only for the file create endpoint 2018-09-20 23:02:00 +02:00
Olivier Bellone
f3dd3ab1bf
Handle file objects like file_upload 2018-09-17 16:53:23 +02:00
Brandur
0b4802cdea Fix minor grammatical mistake 2018-09-14 12:18:15 -06:00
Brandur
b43b83cee1 Add a few more comments around new #eql?/#hash 2018-09-14 09:59:38 -06:00
Olivier Bellone
45e807a41a
Bump version to 3.26.1 2018-09-14 10:12:00 +02:00
Olivier Bellone
8a53098c12
Merge pull request #688 from stripe/brandur-hash
Override `StripeObject#eql?` and `#hash` to produce more optimistic equivalency
2018-09-14 10:10:02 +02:00
Brandur
7c01836135 Override StripeObject#eql? and #hash to produce more optimistic equivalency
Overrides `#eql?` (hash equality) and `#hash` so that Stripe objects can
be used more easily as Hash keys and that certain other frameworks that
rely on these methods will have an easier time (e.g. RSpec's `change`,
see #687).

I think this might be a little controversial if we weren't already
overriding the `#==` implementation, but because we are, I think it
makes sense to extent it to these two methods as well.
2018-09-13 17:39:18 -06:00
Brandur
27f39aed85 Bump version to 3.26.0 2018-09-05 14:54:35 -07:00
Brandur
856201f67e
Merge pull request #681 from stripe/remi-add-reporting-resources
Add support for the Reporting resources
2018-09-05 14:52:48 -07:00
Brandur
68cfe0fd8b
Merge pull request #685 from timcraft/use-keyword-args
Use keyword args for StripeObject#update_attributes
2018-09-05 09:54:22 -07:00
Brandur
8d01c03515
Merge pull request #684 from timcraft/remove-util-titlecase-parts
Remove Util.titlecase_parts method
2018-09-05 09:52:49 -07:00
Brandur
f8fd0d263e
Merge pull request #683 from timcraft/remove-util-file-readable
Remove unused Util.file_readable method
2018-09-05 09:51:38 -07:00
Tim Craft
29fe27d245 Use keyword args for StripeObject#update_attributes 2018-09-05 14:28:50 +01:00
Tim Craft
92775b1358 Remove Util.titlecase_parts method 2018-09-05 14:25:39 +01:00
Tim Craft
a43296d242 Remove unused Util.file_readable method 2018-09-05 14:11:05 +01:00
Remi Jannel
66248ba2aa Add support for the Reporting resources 2018-08-30 20:11:07 -04:00
Brandur
1bbbfd4e66
Merge pull request #680 from stripe/brandur-stripe-mock-030
Upgrade stripe-mock to 0.30.0
2018-08-30 10:30:28 -07:00
Brandur
b19358fb80 Upgrade stripe-mock to 0.30.0
Upgrades to the most recent version of stripe-mock now that we've got a
few more fixes into both its implementation and into stripe-ruby's test
suite.
2018-08-30 10:09:10 -07:00
Brandur
54b012caa0
Merge pull request #679 from stripe/brandur-minor-test-fixes
Minor test fixes
2018-08-30 09:40:49 -07:00
Brandur
6ad182b1eb Minor test fixes
I was testing with a new version of stripe-mock and it caught a few
problems with query parameter validation on. This patch contains some
minor fixes to address them.
2018-08-29 15:57:51 -07:00
Brandur
7331bf33de Bump version to 3.25.0 2018-08-28 13:23:26 -07:00
Brandur
29d9e0d2c5
Merge pull request #678 from stripe/remi-fix-payment-intent
Fix payment intent methods to take extra parameters
2018-08-28 13:21:51 -07:00
Remi Jannel
0632afb5be Fix payment intent methods to take extra parameters and remove delete 2018-08-28 15:55:19 -04:00
Tomer Elmalem
3a8f1d7172 Bump version to 3.24.0 2018-08-27 16:31:56 -07:00
tomer-stripe
0d7315f037
Merge pull request #675 from stripe/tomer-remove-edittable-bitcoin-receivers-actions
Remove ability to perform edit-actions on bitcoin receivers
2018-08-27 16:29:21 -07:00
Olivier Bellone
156145b96b
Merge pull request #677 from stripe/ob-prep-file
Use `::File` instead of `File`
2018-08-27 16:50:57 +02:00
Olivier Bellone
21db64fe0e
Use ::File instead of File 2018-08-27 15:32:10 +02:00
Olivier Bellone
a2f9822de7
Bump version to 3.23.0 2018-08-23 10:09:25 +02:00
Olivier Bellone
97b65985df
Merge pull request #676 from stripe/remi-add-usage-record-summary
Add support for usage record summary
2018-08-23 10:08:50 +02:00
Remi Jannel
f5dc3ab0c3 Add support for usage record summary 2018-08-21 08:56:18 -04:00
Tomer Elmalem
2da53af59b Remove ability to perform edit-actions on bitcoint receivers 2018-08-16 11:00:22 -07:00
Brandur
2b2c2c3cd6 Bump version to 3.22.0 2018-08-15 10:15:17 -07:00
Brandur
59ef4c2758
Merge pull request #674 from stripe/brandur-integer-indexes
Integer-index encode all arrays
2018-08-15 10:14:25 -07:00
Brandur
c1ff8bdc4c Integer-index encode all arrays
Changes all arrays from classic Rack encoding:

``` sh
arr[]=...&arr[]=...&arr[]=...
```

To integer-indexed encoding:

``` sh
arr[0]=...&arr[1]=...&arr[2]=...
```

We think that this should be tractable now that we've fully converted
all endpoints over to the new AbstractAPIMethod infrastructure on the
backend (although we should do a little more testing to make sure that
all endpoints still work).

As part of the conversion, we also remove any places that we were "spot
encoding" to get required integer-indexed syntax. This should now all be
built in.
2018-08-14 14:44:43 -07:00
Olivier Bellone
24143ab7d7
Bump version to 3.21.0 2018-08-03 15:48:21 +02:00
Olivier Bellone
a24b69caab
Merge pull request #671 from stripe/ob-topup-cancel
Add cancel support for topups
2018-08-03 15:47:34 +02:00
Olivier Bellone
d698bd6fc7
Add cancel support for topups 2018-08-03 12:50:39 +02:00
Olivier Bellone
7e914bc9cb
Bump version to 3.20.0 2018-08-03 12:26:19 +02:00
Olivier Bellone
76a8a45eb6
Merge pull request #669 from stripe/ob-file-link
file_link support
2018-08-03 12:25:11 +02:00
Olivier Bellone
9c357c803f
file_link support 2018-08-03 00:07:27 +02:00
Olivier Bellone
704231a4f6
Merge pull request #668 from stripe/remi-scheduled-run-mock
Move Scheduled Query Run and Source Transaction to stripe-mock
2018-07-31 13:47:12 +02:00
Remi Jannel
bec0063d07 Move Scheduled Query Run and Source Transaction to stripe-mock 2018-07-31 07:41:17 -04:00
Olivier Bellone
4916eadafa
Merge pull request #667 from stripe/brandur-disable-lengths
Rubocop: Cap method length at 50 lines + disable module length
2018-07-28 14:53:15 +02:00
Brandur
ebbce668fd Rubocop: Cap method length at 50 lines + disable module length
Remi pointed out in #666 that we basically just have to keep adding more
more onto the `Max` exception for both these rules every time we add a
new API resource.

Here I suggest that we modify the check on method length in two ways:

1. Permanently disable the cop on `Util.object_classes`. This is just
   going to keep growing until we change are approach to it.
2. Choose a more reasonable maximum of 50 lines for elsewhere (IMO, the
   default of 10 is just too short). Most of our methods already come in
   below this, but there's a couple outliers like `#execute_request` in
   `StripeClient`. If we knock over some of those, we could lower this
   number again, but I suspect that we'd probably want somewhere closer
   to 30 (instead of 10) event then.

I also disable the check on module length completely. I'm not convinced
this is a very good heuristic for code quality.
2018-07-27 17:13:07 -07:00
Brandur
4e3f38ec09 Bump version to 3.19.0 2018-07-27 17:01:39 -07:00
Brandur
42839f8c20
Merge pull request #666 from stripe/remi-add-sigma-scheduled-query-run
Add support for ScheduledQueryRun
2018-07-27 17:00:26 -07:00
Remi Jannel
4c39c35fd8 Add support for ScheduledQueryRun 2018-07-27 19:14:37 -04:00
Brandur
ec5c51c3ba Very minor fix for alphabetical ordering 2018-07-26 11:32:35 -07:00
Brandur
3b0c34d53b Bump version to 3.18.0 2018-07-26 11:19:23 -07:00
Brandur
69092da48a
Merge pull request #665 from stripe/remi-add-issuing-resources
Add support for Issuing resources
2018-07-26 11:18:06 -07:00
Remi Jannel
04ae411754 Add support for Issuing resources 2018-07-26 13:35:50 -04:00
Brandur
7c9492b37d Bump version to 3.17.2 2018-07-19 09:56:15 -07:00
Brandur
b3eb5d3e30
Merge pull request #664 from jasonwebster/do_not_colorize_logger_logging
Do not colorize output destined for configured logger
2018-07-19 09:55:30 -07:00
Jason Webster
9d0cd25897 Do not colorize output destined for configured logger
This changes the predicate supplied to the #colorize method to ensure
that if a logger is set, the colorizing ANSI escape codes are not applied.

This definitely appears to have been the intention behind the original
implementation, but the tests didn't reflect how .log_internal was
actually called. In reality, it is always supplied with an `out:`
argument, not nil. This caused all logger bound output to also be
colorized.
2018-07-19 12:28:28 -04:00
Olivier Bellone
74b25a40dd
Bump version to 3.17.1 2018-07-19 16:42:10 +02:00
Olivier Bellone
87b758e3ae
Merge pull request #663 from stripe/ob-better-resource-url
Better `resource_url` method
2018-07-19 16:38:35 +02:00
Olivier Bellone
73eb3fec77
Regenerate .rubocop_todo.yml 2018-07-19 14:23:18 +02:00
Olivier Bellone
b4e57ea981
Better resource_url method 2018-07-19 14:23:07 +02:00
Olivier Bellone
99a1d57c0a
Merge pull request #662 from stripe/remi-move-payment-intent-stripe-mock
Move paymentintent to stripe-mock
2018-07-09 11:03:57 +02:00
Remi Jannel
b206552c60 Move paymentintent to stripe-mock 2018-07-07 15:55:12 -04:00
Olivier Bellone
a097b23a0c
Merge pull request #661 from stripe/brandur-ruby-25
Add Ruby 2.5 to test matrix + use aliases
2018-07-03 08:57:40 +02:00
Brandur
1cb90b87f4 Add Ruby 2.5 to test matrix + use aliases
Adds Ruby 2.5 to the test matrix.

I also switched us over to aliases of each major Ruby version because I
think it makes more sense to be locked to whatever the latest release in
each is.
2018-07-02 14:08:00 -07:00
Brandur
9e35a5e0d9 Bump version to 3.17.0 2018-06-28 08:57:18 -07:00
zach wick
ab3949b8da Adds support for 'partner_id' in 'set_app_info' (#658)
* Adds support for 'partner_id' in 'set_app_info'

Signed-off-by: zach wick <zwick@stripe.com>
2018-06-28 08:55:58 -07:00
Olivier Bellone
32151d5a31
Bump version to 3.16.0 2018-06-28 14:09:58 +02:00
Olivier Bellone
d4bd5aad5a
Merge pull request #657 from stripe/remi-add-payment-intent
Add support for the PaymentIntent resource
2018-06-28 14:07:21 +02:00
Remi Jannel
201f9c29f4 Add support for the PaymentIntent resource
This feature is gated so the tests are stubbed for now
2018-06-27 19:24:23 -04:00
remi-stripe
89d1994f35
Merge pull request #654 from xtrasimplicity/patch-1
Readme: Fixed minor spelling issue.
2018-06-21 16:48:53 -07:00
Andrew
2230ec8b76
Update README.md 2018-06-22 09:46:26 +10:00
Brandur
1f18f24991
Merge pull request #650 from stripe/brandur-fix-tests
Fix some parameters being sent in tests
2018-05-16 10:14:41 -07:00
Brandur
02200e4c96 Add missing magic comment 2018-05-16 16:52:58 +02:00
Brandur
ed2a0f066d Fix some parameters being sent in tests
I found a bug recently in stripe-mock which causes it not to actually be
validating that parameters not in the spec are not being sent (the
actual Stripe API does check for this).

After applying a fix, I found that stripe-ruby's test suite no longer
passes against it, and the reason is that there are some subtle mistakes
throughout. This patch corrects them to be in line with what the API
actually expects.
2018-05-16 15:10:00 +02:00
Brandur
e8b272653e Bump version to 3.15.0 2018-05-10 15:42:50 -07:00
Brandur
ec66c3f0f4
Merge pull request #649 from stripe/brandur-frozen-strings
Add `frozen_string_literal` to every file and enforce Rubocop rule
2018-05-10 15:41:46 -07:00
Brandur
863da48398 Add frozen_string_literal to every file and enforce Rubocop rule
Adds the magic `frozen_string_literal: true` comment to every file and
enables a Rubocop rule to make sure that it's always going to be there
going forward as well.

See here for more background [1], but the basic idea is that unlike many
other languages, static strings in code are mutable by default. This has
since been acknowledged as not a particularly good idea, and the
intention is to rectify the mistake when Ruby 3 comes out, where all
string literals will be frozen. The `frozen_string_literal` magic
comment was introduced in Ruby 2.3 as a way of easing the transition,
and allows libraries and projects to freeze their literals in advance.

I don't think this is breaking in any way: it's possible that users
might've been pulling out one of are literals somehow and mutating it,
but that would probably not have been useful for anything and would
certainly not be recommended, so I'm quite comfortable pushing this
change through as a minor version.

As discussed in #641.

[1] https://stackoverflow.com/a/37799399
2018-05-10 14:56:14 -07:00
Brandur
40e4883ddc Bump version to 3.14.0 2018-05-09 14:56:01 -07:00
Fay Wu
6ce45193d2 Add support for v1/issuer_fraud_records endpoints (#645) 2018-05-09 14:55:10 -07:00
Fay Wu
d07d1d37d6
Merge pull request #648 from stripe/fay/update-version
Upgrade `stripe-mock` to v0.16.0
2018-05-09 09:16:16 -07:00
Fay Wu
188fef5b6e Update minimum version of stripe-mock 2018-05-09 09:10:58 -07:00
Brandur
a44259b8f7 Bump version to 3.13.1 2018-05-07 15:11:56 -07:00
Brandur
357ec528a2
Merge pull request #647 from stripe/brandur-merge-query-params
Merge query parameters coming from path with `params` argument
2018-05-07 15:11:09 -07:00
Brandur
3a2724bfcc Merge query parameters coming from path with params argument
If specifying both query parameters in a path/URL down to Faraday (e.g.,
`/v1/invoices/upcoming?coupon=25OFF`) _and_ query parameters in a hash
(e.g., `{ customer: "cus_123" }`), it will silently overwrite the ones
in the path with the ones in the hash. This can cause problems where
some critical parameters are discarded and causes an error, as seen in
issue #646.

This patch modifies `#execute_request` so that before going out to
Faraday we check whether the incoming path has query parameters. If it
does, we decode them and add them to our `query_params` hash so that
all parameters from either place are preserved.

Fixes #646.
2018-05-07 14:51:25 -07:00
Brandur
b3b0f78c91
Merge pull request #644 from stripe/brandur-stripe-mock-0-15
Move file upload tests over to be handled by `stripe-mock`
2018-05-07 06:52:37 -07:00
Brandur
4518050527
Merge pull request #643 from stripe/brandur-configuring-version
Add a README section for globally configuration an API version
2018-05-04 15:59:55 -07:00
Brandur
76e6383727 Add a README section for globally configuration an API version
I don't remember why I wrote this originally, but found it sitting
locally uncommitted. It seems like a useful example to have in the
README, so add it in.
2018-05-04 14:25:34 -07:00
Brandur
b9a3971df8 Move file upload tests over to be handled by stripe-mock
`stripe-mock` can now respond accurately for file API endpoints thanks
to a few improvements in how it handles `multipart/form-data` payloads
and the OpenAPI spec.

Here we upgrade `stripe-mock` to 0.15.0 and remove the manual stubbing
that we had previously.
2018-05-04 11:31:11 -07:00
Brandur
21b0514d1e Bump version to 3.13.0 2018-04-11 13:51:35 -07:00
Brandur
9594875bbd
Merge pull request #634 from stripe/alexander/flexible-billing
Flexible/Metered Billing API support
2018-04-11 13:50:13 -07:00
Alexander Thiemann
c066c9c5f8 flexible billing primitives and tests 2018-04-11 13:29:24 -07:00
Brandur
0b54bf7ba2
Merge pull request #638 from stripe/brandur-stripe-mock-v0.12.0
Upgrade `stripe-mock` to v0.12.0
2018-04-10 13:38:44 -07:00
Brandur
93503dceb5 Fix one test that was incorrectly expecting a non-deleted object back 2018-04-10 13:03:14 -07:00
Brandur
31ac109b21 Upgrade stripe-mock to v0.12.0
The most important changes here are that deleted objects are now
represented more accurately, and that IDs used in URLs are "reflected"
back into responses so that test suites can treat return objects a
little more realistically than they could before.

This should resolve incompatibilities between `stripe-ruby` and newer
versions of `stripe-mock`.
2018-04-10 12:52:55 -07:00
Brandur
f6e542e6ab Bump version to 3.12.1 2018-04-05 16:18:02 -07:00
Brandur
676670c022
Merge pull request #636 from stripe/brandur-initialize-instance-var
Initialize instance variable on the getter too
2018-04-05 16:12:09 -07:00
Brandur
776d45f116 Initialize instance variable on the getter too
The test suite is currently throwing a bunch of warnings from some
recent changes I made -- although we initialize `@additive_params` when
setting one with `self.additive_object_param`, we don't when we check
one with `self.additive_object_param?`. This often isn't a problem
because every API resource sets `metadata`, but it is from the test
suite and probably for vanilla `StripeObject`s too.
2018-04-05 15:42:46 -07:00
Brandur
2f322cadb4 Bump version to 3.12.0 2018-04-05 07:17:58 -07:00
Brandur
c63081e3c5
Merge pull request #632 from stripe/brandur-only-empty-metadata
Fix replacement of non-`metadata` embedded `StripeObjects`
2018-04-05 07:16:22 -07:00
Brandur
39b80e518b Now that most hashes are non-additive, remove hack on subscription items
See the discussion here: https://github.com/stripe/stripe-ruby/pull/632
2018-04-05 07:10:15 -07:00
Brandur
5cfdf35d20 Introduce additive_object_param for use with metadata 2018-04-05 07:02:36 -07:00
Brandur
256556efa0 Fix replacement of non-metadata embedded StripeObjects
So we have a bit of a problem right now when it comes to replacing a
`StripeObject` that's embedded in an API resource.

Most of the time when someone does this, they want to _replace_ an
object embedded in another object. Take setting a source on a
subscription for example:

``` ruby
subscription.source = {
  object: 'card',
  number: 123,
}
subscription.save
```

In the case above, the serialized parameters should come out as:

```
source[object]=card&source[number]=123
```

That should apply even if the previous source had something else set on
it which we're not going to set this time -- say an optional parameter
like `source[address_state]`. Those should not be present at all in the
final serialized parameters.

(Another example is setting a `payout_schedule` as seen in #631 which is
PR is intended to address.)

There is an exception to this rule in the form of metadata though.
Metadata is a bit of a strange case in that the API will treat it as
additive, so if we send `metadata[foo]`, that will set the `foo` key,
but it won't overwrite any other keys that were already present.

This is a problem because when a user fully sets `metadata` to a new
object in Ruby, what they're probably trying to do is _replace_ it
rather than add to it. For example:

``` ruby
subscription.metadata
=> { old: 'bar' }

subscription.metadata = {
  new: 'baz'
}
subscription.save
```

To accomplish what the user is probably trying to do, we actually need
to send `metadata[old]=&metadata[new]=baz` so that we empty the value of
`old` while simultaneously setting `new` to `baz`.

In summary, metadata behaves different from other embedded objects in a
fairly fundamental way, and because the code is currently only set up to
handle the metadata case, it's not behaving correctly when other types
of objects are being set. A lot of the time emptying values like we do
for `metadata` is benign, but as we've seen in #631, sometimes it's not.

In this patch, I modify serialization to only empty out object values
when we see that parameter is `metadata`.

I'm really not crazy about the implementation here _at all_, but I'm
having trouble thinking of a better way to do it. One possibility is to
introduce a new class annotation like `empty_embedded_object :metadata`,
but that will have to go everywhere and might be error-prone in case
someone forgets it on a new resource type. If anyone has a suggestion
for an alternative (or can let me know if I'm missing something), I'd
love to hear it.

This PR is an alternate to #631.
2018-04-03 16:52:14 -07:00
Olivier Bellone
3bc4256e25
Bump version to 3.11.0 2018-02-26 13:30:29 +01:00
Olivier Bellone
4d965ac5d7
Merge pull request #628 from stripe/ob-error-code
Add support for code attribute on all Stripe exceptions
2018-02-26 13:29:23 +01:00
Olivier Bellone
3805968741
Add support for code attribute on all Stripe exceptions 2018-02-23 19:02:26 +01:00
Brandur
a7ea9cf1e9 Bump version to 3.10.0 2018-02-21 11:36:26 -08:00
Brandur
529b9ec417
Merge pull request #627 from stripe/jkakar/topup-client
Add support for /v1/topups endpoints
2018-02-21 11:35:16 -08:00
Jamu Kakar
0be22683a3 Add support for /v1/topups endpoints. 2018-02-16 15:03:46 -08:00
Jamu Kakar
16704d9563
Merge pull request #626 from stripe/jkakar/fix-product-issues
Upgrade to stripe-mock 0.8.0.
2018-02-15 16:44:29 -08:00
Jamu Kakar
74dfbe57d6 Apply review feedback from @ob-stripe. 2018-02-15 16:10:10 -08:00
Jamu Kakar
0b6a45af2e Fix broken test. 2018-02-15 16:05:02 -08:00
Olivier Bellone
fafd449c5f
Bump version to 3.9.2 2018-02-12 11:32:24 -08:00
Olivier Bellone
1abb8a574b
Merge pull request #625 from stripe/ob-skip-to-hash-for-nil
Skip calling to_hash for nil
2018-02-12 11:31:06 -08:00
Olivier Bellone
5f1ddf2a96
Skip calling to_hash for nil 2018-02-12 11:20:19 -08:00
Brandur
f6484e3240 Bump version to 3.9.1 2017-12-15 00:47:53 -08:00
Brandur
659025c7e7
Merge pull request #616 from stripe/ob-file-duck-typing
Use duck typing to detect File-like objects
2017-12-14 12:11:31 -08:00
Olivier Bellone
b83a0e5583
Use duck typing to detect File-like objects 2017-12-14 19:54:47 +01:00
Brandur
be8e4ff5f4
Merge pull request #614 from stripe/ob-coveralls
Add support for coveralls.io
2017-12-11 17:55:17 -08:00
Olivier Bellone
56430ad405
Add support for coveralls.io 2017-12-08 17:48:40 -08:00
Brandur
bfbc4b7862 Bump version to 3.9.0 2017-12-08 10:48:47 -08:00
Brandur
cf810019d6
Merge pull request #613 from stripe/brandur-idempotency-error
Introduce new `IdempotencyError` type
2017-12-08 10:47:51 -08:00
Brandur
8b73853b6b A block and a class got longer so extend the exceptions for Rubocop 2017-12-07 17:42:39 -08:00
Brandur
3fc5e5b351 Introduce new IdempotencyError type
A few weeks back a new error type `idempotency_error` was introduced in
the API. I put it in to respond to #503, but then forgot to add support
for it in this library. This patch introduces a new exception class that
represents it.
2017-12-07 17:39:14 -08:00
Brandur
c36bf00151 Bump version to 3.8.2 2017-12-07 12:56:27 -08:00
Brandur
e149379b83
Merge pull request #612 from stripe/brandur-fix-array-encoding-in-non-post
Fix encoding of arrays that are sent in query strings
2017-12-07 12:54:54 -08:00
Brandur
2bc471d501 Fix encoding of arrays that are sent in query strings
As discussed in #608, we currently have a problem where Faraday
deconstructs a query string that we encode and strips out any of the
array index numbers that we added. It's not too clear on why it does
this, but it appears to be built in at a pretty low level and hard to
change.

I spent a little time on this and it turns out that we can avoid the bad
code by depending on Faraday's `params` accessor on a request instead of
trying to do the encoding ourselves. Webmock has a pretty hard time
detecting the difference, but you can see some before and after encoding
here.

Before:

```
I, [2017-12-06T17:41:23.083942 #36737]  INFO -- : get
http://localhost:12111/v1/invoices/upcoming?customer=cus_123&subscription_items%5B%5D%5Bplan%5D=gold&subscription_items%5B%5D%5Bquantity%5D=2
```

After:

```
I, [2017-12-06T17:42:12.727752 #37158]  INFO -- : get
http://localhost:12111/v1/invoices/upcoming?customer=cus_123&subscription_items%5B0%5D%5Bplan%5D=gold&subscription_items%5B0%5D%5Bquantity%5D=2
```

Honestly, some of this can still use a lot of cleanup: it's weird that
we manually encode parameters ourselves for bodies, but not for queries;
but I think this'll fix the problem for now.

Fixes #608.
2017-12-07 10:51:07 -08:00
Brandur
ea426108f0 Bump version to 3.8.1 2017-12-06 10:16:11 -08:00
Brandur
ee30b1f915
Merge pull request #611 from stripe/ob-fix-610
Support Tempfiles in file_upload creation requests
2017-12-06 10:14:59 -08:00
Olivier Bellone
949efb017d
Support Tempfiles in file_upload creation requests 2017-12-05 16:52:37 -08:00
Brandur
ffb6ea4a31
Merge pull request #607 from stripe/brandur-remove-manual-stubs
Remove manual exchange rate stubbing
2017-10-31 09:49:39 -07:00
Brandur
85c811a18f Remove manual exchange rate stubbing
stripe-mock 0.4.0 comes with the up-to-date exchange rates API. Here we
bump the required version and remove the manual exchange rate stubbing
in stripe-ruby's test suite.
2017-10-31 09:17:51 -07:00
Brandur
44e590fdb8 Bump version to 3.8.0 2017-10-31 08:49:33 -07:00
Brandur
665af07f52
Merge pull request #606 from stripe/ob-exchange-rate
Add support for exchange_rates API requests
2017-10-31 08:48:45 -07:00
Olivier Bellone
b153b39203
Add support for exchange_rates API requests 2017-10-31 10:25:18 +01:00
Brandur
36e6c16cc8 Bump version to 3.7.0 2017-10-26 07:53:09 -07:00
Brandur
c974c0b904 Merge pull request #603 from stripe/ob-source-transactions
Add support for listing source_transactions
2017-10-26 07:51:54 -07:00
Olivier Bellone
c455be74d4
Add support for listing source_transactions 2017-10-26 15:43:34 +02:00
Brandur
265d064f91 Fix links in the CHANGELOG 2017-10-20 12:16:15 -07:00
Brandur
987bbd09c0 Merge pull request #600 from stripe/brandur-explicit-operations
Add explicit operations list everywhere
2017-10-18 12:05:25 -07:00
Brandur
2a087595a9 Add explicit operations list everywhere
Makes the `operations` argument to `nested_resource_class_methods`
required and adds explicit lists to any invocations that were missing
one.

The impetus here is that I think it's more easily digestible if each
call site is explicit about what operations it supports and therefore
which methods it's about to create on the class.
2017-10-17 18:02:36 -07:00
Brandur
9ade60b082 Remove trailing whitespace 2017-10-17 18:01:56 -07:00
Brandur
53c2f1a760 Bump version to 3.6.0 2017-10-17 17:56:07 -07:00
Brandur
af51af2577 Add some documentation to NestedResource module 2017-10-17 17:52:35 -07:00
Brandur
cf5354cc27 Alphabetize inclusion order 2017-10-17 17:50:20 -07:00
Brandur
7699033d90 Merge pull request #597 from stripe/ob-nested-resource-class-methods
Nested resource class methods
2017-10-17 17:50:52 -07:00
Brandur
20f4feaec0 Bump version to 3.5.3 2017-10-16 13:13:41 -07:00
Brandur
5c3b741a2c Merge pull request #599 from stripe/brandur-dont-persist-idempotency-key
Don't persist `idempotency_key` option between API requests
2017-10-16 13:09:52 -07:00
Brandur
b4e64969cc Don't persist idempotency_key option between API requests
Excludes `idempotency_key` from opts to persist between API requests.
Obviously the same idempotency key is not something that we ever want to
use again.

Fixes #598.
2017-10-16 13:00:32 -07:00
Brandur
6dca58937d Merge require lists together + add uri
There's really no reason for these to have been two separate lists.
Also, add `uri` as an explicit dependency (so far it's been getting
included by luck with other libraries).
2017-10-16 12:32:18 -07:00
Brandur
e4af9ad820 Merge pull request #596 from stripe/ob-fix-554
Encode arrays as hashes when needed
2017-10-16 12:03:59 -07:00
Brandur
6a87b9ce68 Fix wording in test case name 2017-10-16 12:00:48 -07:00
Brandur
cfa6c2b8ae Merge pull request #595 from stripe/ob-fix-524
Call Object#method if method accessor is called with arguments
2017-10-16 12:01:07 -07:00
Brandur
517c1f08ca Merge pull request #594 from stripe/ob-fix-deep-copy
Maintain class in deep_copy
2017-10-16 11:59:13 -07:00
Olivier Bellone
7f866aab5c
Nested resource class methods 2017-10-15 18:49:13 +02:00
Olivier Bellone
4406f8e258
Call Object#method if method accessor is called with arguments 2017-10-14 23:00:40 +02:00
Olivier Bellone
de21302f4e
Encode arrays as hashes when needed 2017-10-14 17:48:20 +02:00
Olivier Bellone
c920a7c649
Maintain class in deep_copy 2017-10-14 01:05:06 +02:00
Brandur
f628a1eff5 Convert stripe-dotnet links to stripe-ruby (fixes bad copy + paste)
While converting this changelog over, I improperly added links that were
copied from stripe-dotnet. The numbers were right, but the links was
wrong because it was going to the wrong project. This patch corrects all
those bad links.
2017-10-13 10:34:09 -07:00
Brandur
c59c3661c6 Bump version to 3.5.2 2017-10-13 10:33:30 -07:00
Brandur
1c1e58a6eb Merge pull request #593 from stripe/brandur-changelog
Convert History.txt to CHANGELOG.md
2017-10-13 10:00:28 -07:00
Brandur
f543771003 Merge pull request #592 from stripe/brandur-reimplement-custom-marshal
Implement custom Marshal encoder/decoder for `StripeObject`
2017-10-13 09:52:45 -07:00
Brandur
72e1a14552 Comment out Vim hint 2017-10-13 09:45:42 -07:00
Brandur
a05f59edf2 Convert History.txt to CHANGELOG.md
Converts `History.txt` to a Markdown-based changelog in the same style
as the one established in stripe-dotnet [1].

We leave `History.txt` in place with a reference to the new file so that
existing links will not be broken.

[1] https://github.com/stripe/stripe-dotnet/pull/1026
2017-10-13 09:42:41 -07:00
Brandur
91099f9ee5 Implement custom Marshal encoder/decoder for StripeObject
Backtracks a little bit #586 by bringing back custom `StripeObject`
encoding and decoding methods for Ruby's `Marshal`. These work by just
persisting values and some opts, and skipping everything else. It's
mostly the same as what we had before, but implemented a little more
cleanly so that we don't actually need to invoke `Marshal` anywhere
ourselves.

In #586 we still managed to remove all the uses of `Marshal` in our own
codebase to make the linter happy. Even though we wouldn't recommend the
use of `Marshal`, this code at least enables it for anyone using a Rails
cache or similar mechanism.

Addresses #90.
2017-10-13 09:31:08 -07:00
Brandur
2a0df29bf4 Bump version to 3.5.1 2017-10-12 10:20:24 -07:00
Brandur
d41a59fc82 Merge pull request #591 from stripe/ob-fix-590
Ensure that each thread has its own client
2017-10-12 09:59:22 -07:00
Olivier Bellone
a210c5cd76
Ensure that each thread has its own client 2017-10-12 18:20:13 +02:00
Brandur
a579368c17 Improve latest change description in changelog 2017-10-11 09:42:29 -07:00
Brandur
283e611a88 Fix typo in changelog ("fromm") 2017-10-11 09:31:08 -07:00
Brandur
c251dfa952 Bump version to 3.5.0 2017-10-11 09:30:35 -07:00
Brandur
a0a9c7cf22 Merge pull request #589 from stripe/ob-detach-sources
detach method for detaching sources from customers
2017-10-11 09:29:25 -07:00
Olivier Bellone
92e216634c
detach method for detaching sources from customers 2017-10-11 11:15:38 +02:00
Brandur
6bd1d6b9a0 Bump version to 3.4.1 2017-10-05 09:56:33 -07:00
Brandur
e4725b8006 Merge pull request #588 from stripe/ob-fix-576
Require Faraday 0.10 for proper nested array encoding
2017-10-05 09:47:44 -07:00
Olivier Bellone
cd7e607258
Require Faraday 0.10 for proper nested array encoding 2017-10-05 17:56:39 +02:00
Brandur
9099b5d24d Merge pull request #587 from stripe/brandur-log-query-string
Log query string as well as body on log debug
2017-10-05 08:41:20 -07:00
Brandur
8ea866616b Log query string as well as body on log debug
This patch modifies the debugging-level logging logic slightly so that
if it's a `GET` request that includes a query string, we log that string
just like we would've for a request body on a `POST` or like.

This especially comes in handy when looking when trying to resolve
something like a problem with the upcoming invoices endpoint like we saw
in #576, but will be useful in a number of situations.
2017-10-04 13:00:35 -07:00
Brandur
3f454495bf Merge pull request #586 from stripe/brandur-remove-marshal
Implement deep copy for StripeObject and remove marshal/unmarshal
2017-09-29 07:13:32 -07:00
Brandur
212a2052a4 Merge pull request #585 from stripe/brandur-guard-clause
Remove Rubocop TODO around guard clauses
2017-09-29 02:15:37 -07:00
Brandur
80d85a522c Implement deep copy for StripeObject and remove marshal/unmarshal
We were previously using a bit of a hack to get a free deep copy
implementation through Ruby's marshaling framework. Lint call this out
as a security problem though, and rightfully so: when combined with
unsanitized user input, unmarshaling can result in very serious security
breaches involving arbitrary code execution.

This patch removes all uses of marshal/unmarshal in favor of
implementing a deep copy method for `StripeObject`. I also reworked some
of the constants around what keys are available for `opts`. I'm still
not completely happy with the results, but I think it's going to need a
slightly larger refactor in order to get somewhere truly good.

There is what could be a breaking change for people doing non-standard
stuff with the library: the opts that we copy with an object are now
whitelisted, so if they were being used to pass around extraneous data,
that might not work as expected anymore. But because this is a contract
that we never committed to, I don't think I'd bump the major version for
change.
2017-09-28 11:02:20 -07:00
Brandur
cb198baaa3 Remove Rubocop TODO around guard clauses
Removes Rubocop TODO around guard clauses and fixes the outstanding
offenses.

This is starting to get into territory that feels of more dubious value
to me, but at least it did get me writing a couple more tests, so let's
see how it goes by keeping this on.
2017-09-28 09:32:44 -07:00
Brandur
45101b7b0d Merge pull request #584 from stripe/brandur-rubocop-fixes
Fix low hanging Rubocop TODOs
2017-09-28 09:16:31 -07:00
Brandur
7f85eea3ee Fix low hanging Rubocop TODOs
I wanted to see what fixing Rubocop TODOs was like, so I tried to
eliminate all the easy ones. Most of these were pretty easy, and the
changes required are relatively minimal.

Some of the stuff left is harder. Pretty much everything under
`Metrics/*` is going to be a pretty big yak shave. A few of the others
are just going to need a little more work (e.g. `Style/ClassVars` and
`Style/GuardClause`). Going to stop here for now.
2017-09-27 15:07:18 -07:00
Brandur
f8e28baf6b Merge pull request #583 from stripe/brandur-pin-rubocop
Pin Rubocop dependency in `Gemfile`
2017-09-27 13:41:13 -07:00
Brandur
867bf9c4e0 Pin Rubocop dependency in Gemfile
Because we're a library, our `Gemfile.lock` is in `.gitinore` (see [1]).
This means that you'd be otherwise be vulnerable to the whims of
whatever version of Rubocop is installed on the local system.

Because Rubocop changes fairly quickly and those changes tend to lead to
either errors or warnings on its runs, lock the gem to a particular
version in our `Gemfile`. We should try to keep the locked version
relatively current.

[1] http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
2017-09-27 13:07:50 -07:00
Brandur
234b0809bf Merge pull request #575 from stripe/ob-rubocop
Start using RuboCop for linting
2017-09-27 12:41:52 -07:00
Olivier Bellone
e02ff7f849
Start using RuboCop for linting 2017-09-27 21:28:25 +02:00
Brandur
56a07b1986 Merge pull request #582 from stripe/brandur-upgrade-mock-020
Upgrade stripe-mock to 0.2.0
2017-09-22 12:10:03 -07:00
Brandur
ed6d7a7cf9 Upgrade stripe-mock to 0.2.0
This pulls us onto the new version of stripe-mock which should be
checking parameters more accurately now that it's on OpenAPI 3.0.
2017-09-22 12:01:30 -07:00
tmaxwell-stripe
ebeded507d Merge pull request #580 from stripe/tmaxwell/remove-outdated-tests 2017-09-20 14:58:03 -07:00
Tim Maxwell
f4412eec1b Work around idiosyncrasies of stripe-mock 2017-09-20 14:11:11 -07:00
Tim Maxwell
0b4ac62eae Remove recipient card tests 2017-09-20 14:03:00 -07:00
Tim Maxwell
d12fcdb862 Remove tests for legacy Bitcoin API 2017-09-20 13:48:05 -07:00
Brandur
ab1c971e8d Bump version to 3.3.2 2017-09-20 12:17:40 -07:00
Brandur
36c2ed58ad Merge pull request #579 from garethrees/patch-1
Add correct required_ruby_version
2017-09-20 12:16:57 -07:00
Gareth Rees
bc3abe663f Add correct required_ruby_version
The `stripe` gem installs on 1.9.3, but is unusable due to the use of keyword args.

    vagrant@vagrant-ubuntu-trusty-64: ~
    $ ruby -v
    ruby 1.9.3p551 (2014-11-13) [x86_64-linux] Brightbox

    vagrant@vagrant-ubuntu-trusty-64: ~
    $ sudo gem install stripe
    Fetching: multipart-post-2.0.0.gem (100%)
    Fetching: faraday-0.13.1.gem (100%)
    Fetching: stripe-3.3.1.gem (100%)
    Successfully installed multipart-post-2.0.0
    Successfully installed faraday-0.13.1
    Successfully installed stripe-3.3.1
    3 gems installed

    vagrant@vagrant-ubuntu-trusty-64: ~
    $ irb
    irb(main):001:0> require 'stripe'
    SyntaxError: /var/lib/gems/1.9.1/gems/stripe-3.3.1/lib/stripe.rb:207: syntax error, unexpected tLABEL
      def self.set_app_info(name, version: nil, url: nil)
                                          ^
    /var/lib/gems/1.9.1/gems/stripe-3.3.1/lib/stripe.rb:207: Can't assign to nil
      def self.set_app_info(name, version: nil, url: nil)
                                               ^
    /var/lib/gems/1.9.1/gems/stripe-3.3.1/lib/stripe.rb:225: syntax error, unexpected keyword_end, expecting $end
            from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
            from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
            from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
            from (irb):1
            from /usr/bin/irb:12:in `<main>'
2017-09-20 19:43:55 +01:00
Brandur
465da7a997 Bump version to 3.3.1 2017-08-18 10:15:11 -07:00
Brandur
aa5ef2f7ff Add comment so the post-verify parse change doesn't regress 2017-08-18 10:13:54 -07:00
Brandur
a19dfed759 Merge pull request #572 from timcraft/webhook
Parse webhook payload after verifying the signature header
2017-08-18 10:11:51 -07:00
Tim Craft
4739ece7b0 Parse webhook payload after verifying the signature header 2017-08-18 11:17:57 +01:00
Brandur
8e897a43b5 Bump version to 3.3.0 2017-08-11 15:02:09 -07:00
Brandur
92d28b38cd Merge pull request #570 from stripe/brandur-support-logger
Add support for setting a logger
2017-08-11 14:59:13 -07:00
Brandur
1ca67cb954 Correct behavior for error logging
A few changes:

* Add a new `Util.log_error` method which will forward to the equivalent
  of `#error` on a logger.
* Move errors produced by `StripeClient` to use `Util.log_error`.
* Change standard stdout logging behavior to log to stderr in the case
  of `Util.log_error.
* Change `Stripe.log_level` values to be an enum in a similar fashion as
  the standard library's built in `Logger`.
2017-08-11 11:45:43 -07:00
Brandur
cb111a8e74 Add support for setting a logger
Adds support for setting `Stripe.logger` to a logger that's compatible
with `Logger` from Ruby's standard library. In set, the library will no
longer log to stdout, and instead emit straight to the logger and defer
decision on what log level to print to it.

Addresses a request in #566.
2017-08-11 11:22:14 -07:00
Brandur
20ec883e8b Bump version to 3.2.0 2017-08-03 14:09:33 -07:00
Brandur
c0bccc8c23 Merge pull request #568 from stripe/brandur-log-stripe-account
Log `Stripe-Account` values with `STRIPE_LOG`
2017-08-03 14:08:55 -07:00
Brandur
eb3671b067 Log Stripe-Account values with STRIPE_LOG
Hopefully the last tweak in a while, but a discussion on [1] tipped me
off that this was missing. Here we add a `Stripe-Account` for a request
and response to logging. Follows #566 and #567.

[1] https://github.com/stripe/stripe-node/issues/364
2017-08-03 14:02:06 -07:00
Brandur
8264b5a82c Merge pull request #567 from stripe/brandur-log-num-retries
Log `num_retries` with `STRIPE_LOG`
2017-08-03 14:01:48 -07:00
Brandur
441331bd82 Log num_retries with STRIPE_LOG
This one is minor, but I realized after shipping #566 that it would be
nice if the number of retries was also logged for every request. This
patch follows up #566 by adding that in.

I also renamed `retry_count` to `num_retries` because I subjectively
think this name is a little better.
2017-08-03 13:50:00 -07:00
Brandur
aaf8391f3d Bump version to 3.1.0 2017-08-03 13:45:35 -07:00
Brandur
e52c3a2aeb Merge pull request #566 from stripe/brandur-stripe-log
Implement `STRIPE_LOG` for stripe-ruby
2017-08-03 13:44:09 -07:00
Brandur
ce69d749e1 Implement STRIPE_LOG for stripe-ruby
Adds logging support for stripe-ruby in a similar way that we did it for
stripe-python [1], with the idea that users you can optionally get some
additional low-cost-to-configure logging for operational visibility or
debugging.

I made a few tweaks from the Python implementation (which I'll try to
contribute back to there):

* Added an elapsed parameter to responses so you can tell how long they
  lasted.
* Mixed in idempotency_key to all lines that users have a way to
  aggregate logs related to a request from start to finish.
* Standardized naming between different log lines as much as possible.
* Detect a TTY and produce output that's colorized and formatted.

[1] https://github.com/stripe/stripe-python/pull/269
2017-08-03 13:39:15 -07:00
Brandur
a24b7bcf77 Merge pull request #565 from stripe/jacqueline-fix-upcoming
Add upcoming invoice subscription items test
2017-08-02 07:39:07 -07:00
Jacqueline Xu
43b78055aa Add upcoming invoice subscription items test 2017-08-01 17:22:29 -07:00
Brandur
2826bc366a Merge pull request #553 from stripe/brandur-stripestub
Power test suite with stripe-mock
2017-07-31 13:31:06 -07:00
Brandur
00180c5f35 Power test suite with stripe-mock
Moves away from Committee and towards stripe-mock, an external
self-contained executable API stub server based on OpenAPI [1]. The
motivation here is that instead of making stripe-ruby a special
snowflake, we can use a single well-tested and feature-rich mock
implementation to drive every API's test suite.

[1] https://github.com/stripe/stripe-mock
2017-07-31 13:25:48 -07:00
Brandur
d326e51b0e Bump version to 3.0.3 2017-07-28 11:45:12 -07:00
Brandur
bcb5c5325e Merge pull request #564 from stripe/brandur-revert-nil-handling
Allow empty strings in API invocation parameters
2017-07-28 11:41:53 -07:00
Brandur
1417cb5bd1 Allow empty strings in API invocation parameters
Currently, with a normal API resource, you can unset fields by
specifying a `nil` to that field's setter:

``` ruby
c = Charge.retrieve('ch_123')
c.customer = nil
c.save
```

This actually gets serialized as the form `customer=` (i.e. an empty
string), but we had to use the empty string to handle unsets because
form encoding has no concept of a `nil`/`null`.

To try and prevent usage errors, we actually prevent you from setting
fields with an empty string:

``` ruby
c = Charge.retrieve('ch_123')
c.customer = '' # error! use nil instead
```

When specifying parameters though, this doesn't work anywhere nearly as
well because usage patterns like this are very common in Ruby:

``` ruby
charge_opts = {
  params[:amount],
  params[:currency],
  params[:customer],
}
charge = Charge.create(charge_opts)
```

Each one of `params` above may or may not be `nil`, so we've
traditionally filtered those fields out during the invocation of
`Charge.create`.

Recently, I suggested to Slava that we may be able to change this
behavior, and we ended up putting in a patch as part of #557. Users
brought to my attention that this would be far too disruptive of a
change in #560 though, and having thought about it more carefully, I
agree. There's also an argument that filtered `nil` values are just a
better API, especially in Ruby where patterns like the one above are
frequently in effect.

So the best thing I can think of currently is to leave things as they
were before #557, and just require that users use an explicit empty
string when passes in parameter hashes:

``` ruby
Charge.update(customer: '') # will try to unset customer
```

Empty strings will continue to error for `StripeObject` fields like they
always have.

I don't think this is a perfect solution by any means (the different
between values on `StripeObject` versus using parameters is weird), but
it's the least disruptive thing that I can think of right now that gets
us the functionality that we need for endpoints like
`/v1/invoices/upcoming`.

Fixes #560.
2017-07-27 13:47:25 -07:00
Brandur
b0918b9317 Merge pull request #563 from stripe/brandur-improve-oauth-error-safety
Improve error handling safety in the event of unrecognized OAuth error
2017-07-27 11:36:12 -07:00
Brandur
24a1704f05 Improve error handling safety in the event of unrecognized OAuth error
It was brought up in #562 that in case we receive an OAuth error that we
don't know about, `specific_oauth_error` will fall through with a `nil`,
then picked up by `specific_api_error` which will always try to handle
the error as if it were a `Hash` (even if we know it's not!) and thus
lead to typing problems at runtime.

This patch throws a generic `OAuthError` in cases where a code comes
back that we don't recognize. I'm still crazy about the fact that we
don't have a better way of recognizing an OAuth error in particular, but
it should do the trick.
2017-07-27 09:01:53 -07:00
Brandur
713d7f9fa8 Merge pull request #562 from ymendel/handle_invalid_client_oauth_error
handle invalid-client oauth error
2017-07-27 08:53:35 -07:00
Yossef Mendelssohn
21036261fc handle invalid_client error code from deauth
Actually handle the error code and make the right error, instead of
sending it through the `specific_api_error`.
2017-07-26 13:19:50 -04:00
Yossef Mendelssohn
9e1e755ccd add OAuth::InvalidClientError
Taking the explanation from
https://stripe.com/docs/connect/oauth-reference#post-deauthorize-error-codes
and trying to fit it in with the comment style.
2017-07-26 13:19:21 -04:00
Yossef Mendelssohn
83444b60cd test handling of invalid_client error code
An error in OAuth deauthorization could return the error code of
`invalid_client`, but that isn't handled by the code. That leads to a
`TypeError` instead of a clean, understandable error.
2017-07-26 13:14:12 -04:00
Brandur
2394467615 Note that version 3.0.2 was yanked 2017-07-12 17:45:20 -07:00
Brandur
6914178677 Bump version to 3.0.2 2017-07-12 14:00:48 -07:00
Brandur
5786abcb7a Merge pull request #557 from stripe/slava-1156
Allows removing coupon via passing nil
2017-07-12 13:59:23 -07:00
Slava Akhmechet
3094199fa8 styling 2017-07-12 12:58:20 -07:00
Slava Akhmechet
b4308aaa7e Moving tests closer to the core 2017-07-12 12:54:53 -07:00
Brandur
743de63894 Bump version to 3.0.1 2017-07-11 17:02:49 -07:00
Brandur
8bae71f246 Merge pull request #559 from stripe/brandur-include-saved-resources
Include IDs of resources set into properties
2017-07-11 17:00:35 -07:00
Brandur
ab3b1c9dfb Remove now uneeded #saved_and_unchanged method 2017-07-11 12:41:03 -07:00
Brandur
3c632d68b7 Refactor #serialize_params_value to make key optional 2017-07-11 12:40:32 -07:00
Brandur
d90c2b8e74 Include IDs of resources set as properties
Tweaks the serialization behavior so that when a resource is explicitly
set to a resource's field and that resource is subsequently saved, then
if it looks like the set resource was persisted we extract its ID and
send it up to the API.

By slight extension we also throw an `ArgumentError` if it looks like
that set resource was _not_ persisted because if the user set it
explicitly then it was probably not their intention to have it silently
ignored by the library in the event of a problem.
2017-07-11 12:37:19 -07:00
Slava Akhmechet
78178f72d0 Following up with Brandur's fix suggestion 2017-07-10 13:59:23 -07:00
Slava Akhmechet
d0c4450e7e Allows removing coupon via passing nil 2017-07-07 11:27:26 -07:00
Brandur
bf8638a06f Bump version to 3.0.0 2017-06-27 11:37:55 -07:00
Brandur
98855853cf Merge pull request #555 from stripe/ob-pay-invoice-params
Add parameters when calling `pay` on an invoice
2017-06-27 11:35:44 -07:00
Olivier Bellone
78cd1d4f3d Add parameters when calling pay on an invoice 2017-06-27 14:01:08 +02:00
Brandur
94f6f4c809 Merge pull request #552 from stripe/brandur-remove-fixtures
Remove `FIXTURE` definitions for ephemeral keys
2017-06-21 16:06:52 -07:00
Brandur
524526c9b7 Remove FIXTURE definitions for ephemeral keys
Redefining the constant like this produces a warning:

```
$ bundle exec rake
/Users/brandur/stripe/stripe-ruby/test/stripe/ephemeral_key_test.rb:75: warning: already initialized constant Stripe::EphemeralKeyTest::FIXTURE
/Users/brandur/stripe/stripe-ruby/test/stripe/ephemeral_key_test.rb:6: warning: previous definition of FIXTURE was here
Loaded suite /Users/brandur/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/rake_test_loader
Started
...
```

They also don't appear to be used, so it should be fine just to strip
them out of the test suite.
2017-06-21 15:39:41 -07:00
Marc Hesse
8139980f27 Bump version to 2.12.0 2017-06-20 18:31:57 -07:00
Marc Hesse
d69ccfc1dd Add support for ephemeral keys (#549) 2017-06-20 18:30:30 -07:00
Marc Hesse
3f01024974 Update OpenAPI files for ephemeral keys (#551) 2017-06-20 16:23:27 -07:00
Brandur
8a4e68868d Merge pull request #550 from robinbrandt/docs-api-response
Fix documentation for getting a request id
2017-06-12 13:04:37 -07:00
Robin Brandt
d08ec9895d Fix documentation for getting a request id
The last response is returned as a second return value of
Stripe::StripeClient#request.
2017-06-12 15:51:08 -04:00
Brandur
358af9ffb8 Merge pull request #547 from stripe/remi-remove-raw-pans
Remove raw PANs and use magic tokens instead
2017-05-30 12:36:14 -07:00
Remi Jannel
f0b9ba7c6f Remove raw PANs and use magic tokens instead 2017-05-28 10:05:36 -04:00
Brandur
d152f0766c Bump version to 2.11.0 2017-05-26 14:18:29 -07:00
Andrew Yang
855ce0c7d4 Merge pull request #545 from stripe/andrewyang-idempotency-key-param
Warn user if a known opt (such as `idempotency_key`) is in params
2017-05-26 13:48:49 -07:00
Andrew Yang
e66eac41d1 Warn user if a known opt (such as idempotency_key) is in params 2017-05-26 13:29:36 -07:00
Brandur
1d2359cfbc Bump version to 2.10.0 2017-05-25 10:16:06 -07:00
Brandur
c98057fbf9 Merge pull request #546 from stripe/ob-login-links
Add support for login_links on the Account resource
2017-05-25 10:15:25 -07:00
Remi Jannel
27dca775c7 Do not rely on fixtures for login_links as it's not always here. 2017-05-19 14:49:33 -04:00
Olivier Bellone
330763aa02 Adds support for login links 2017-05-19 17:22:54 +02:00
Brandur
f87e1ed219 Merge pull request #543 from stripe/brandur-update-openapi
Update OpenAPI
2017-05-18 16:05:23 -07:00
Brandur
08d24f9835 Modify a few tests to comply with new OpenAPI changes 2017-05-18 15:56:59 -07:00
Brandur
47aa53e3bd Update OpenAPI and fixtures 2017-05-18 15:56:50 -07:00
Brandur
89cb224b39 Bump version to 2.9.0 2017-05-18 12:57:08 -07:00
Brandur
429afa959f Merge pull request #523 from stripe/ob-oauth
Add OAuth methods
2017-05-18 12:56:19 -07:00
Olivier Bellone
a645a78cd0 Add OAuth methods 2017-05-18 11:29:59 +02:00
Brandur
b27cd9b5ed Bump version to 2.8.0 2017-04-28 09:46:23 -07:00
Brandur
2854e7565f Merge pull request #537 from stripe/ob-webhook-signatures
Support for deserializing webhook events and verifying signatures
2017-04-28 09:43:36 -07:00
Brandur
bac96faf8e Merge pull request #536 from stripe/brandur-timeouts
Add section for configuring timeouts to README
2017-04-28 08:01:03 -07:00
Olivier Bellone
0376e242d9 Support for deserializing webhook events and verifying signatures 2017-04-28 14:25:40 +02:00
Brandur
b44744db39 Add section for configuring timeouts to README
Timeouts are about to come to stripe-java [1], so for consistency we
mirror the README section that we're going to be adding over there.

[1] https://github.com/stripe/stripe-java/pull/369
2017-04-27 14:03:27 -07:00
Brandur
5f18d3d18c Bump version to 2.7.0 2017-04-26 12:14:16 -07:00
Brandur
4ca10ae845 Merge pull request #535 from stripe/brandur-invoice-line-item-test
Add test structure for `InvoiceLineItem`
2017-04-26 12:13:38 -07:00
Brandur
24e12b1422 Add test structure for InvoiceLineItem
This doesn't come back directly from the API so the suite is empty, but
just for completeness add a test file for the newly created
`InvoiceLineItem` model.
2017-04-26 12:08:19 -07:00
Brandur
48c0067efe Merge pull request #534 from frewsxcv/invoice-line-item
Add `Stripe::InvoiceLineItem` class.
2017-04-26 12:06:48 -07:00
Corey Farwell
408c697847 Add Stripe::InvoiceLineItem class.
Fixes #531.
2017-04-26 14:59:02 -04:00
Brandur
8cda03a1bf Bump version to 2.6.0 2017-04-26 11:35:51 -07:00
Brandur
b7c5cf96ba Merge pull request #533 from frewsxcv/constantize-object-names
Add string constants for each of the Stripe object names.
2017-04-26 11:35:07 -07:00
Corey Farwell
c4c38d63fc Add string constants for each of the Stripe object names. 2017-04-26 14:20:22 -04:00
Brandur
500dfd98a0 Bump version to 2.5.0 2017-04-24 16:35:33 -07:00
Brandur
14f54018c4 Merge pull request #532 from frewsxcv/patch-1
Don't require `opts` param for `convert_to_stripe_object`.
2017-04-24 16:34:37 -07:00
Corey Farwell
f057ee1893 Don't require opts param for convert_to_stripe_object. 2017-04-24 18:40:03 -04:00
Brandur
ed15772fd6 Bump version to 2.4.0 2017-04-18 06:05:52 -07:00
Brandur
0be4b69710 Merge pull request #529 from stripe/brandur-app-info
Support "app info" for plugins in Ruby
2017-04-18 06:04:59 -07:00
Brandur
cdccdbe4e2 Remove private modifier
Ruby 2.0 doesn't seem to like this syntax unfortunately.
2017-04-18 05:07:39 -07:00
Brandur
06992ef370 Add app info to User-Agent as well 2017-04-17 12:57:16 -07:00
Brandur
65c5c675ed Unset global .stripe_account after test 2017-04-14 14:40:19 -07:00
Brandur
6acd21ac48 Support "app info" for plugins in Ruby
Adds support for "app info" (a mechanism that allows a plugin's author
to identify that plugin) in Ruby. This is already supported in PHP and
we're adding it elsewhere.
2017-04-14 14:37:01 -07:00
Brandur
74b5f08930 Bump version to 2.3.0 2017-04-14 09:48:55 -07:00
Brandur
420aac584b Annotate why we get this value with a comment 2017-04-14 09:47:51 -07:00
Brandur
34b524547a Merge pull request #528 from iamvery/iamvery/add-boolean-predicates-when-accessor-is-missing
Include predicate for lazily added boolean accessors
2017-04-14 09:46:56 -07:00
Jay Hayes
44bad70987 Include predicate for lazily added boolean accessors
Previously, the value of whatever accessor was missing was left out of
the call to build it. This had the effect of skipping over the
lazily-built predicate method when the missing accessor is for a
boolean.

Of course, I realize this all is a bit contrived as most of the time
folks aren't assigning these values manually to stripe objects. However,
in my testing it caught me by surprised that the behavior is asymmetric
depending on how and when values are assigned.

As such I believe this is a less surprising implementation.
2017-04-14 09:31:58 -05:00
Brandur
d2cada1c1c Bump version to 2.2.1 2017-04-07 12:18:42 -07:00
Brandur
ef512aa855 Merge pull request #527 from stripe/ob-fix-faraday-min-version
Fix Faraday minimum version
2017-04-07 12:16:53 -07:00
Olivier Bellone
2c2180fc5c Fix Faraday minimum version 2017-04-07 09:40:43 -07:00
Brandur
2979e5fc62 Bump version to 2.2.0 2017-04-06 14:02:39 -07:00
Brandur
8684b27b54 Merge pull request #522 from stripe/remi-split-payout-transfer
Added support for the new Payout and RecipientTransfer objects
2017-04-06 14:01:43 -07:00
Brandur
8fe03b40fc Update OpenAPI specification and fixtures 2017-04-06 13:48:41 -07:00
Remi Jannel
65e8f505d5 Added support for the new Payout and RecipientTransfer objects
The Transfer object used to represent all movements of funds in Stripe. It
split in three resources:
- Transfer: this describes the movement of funds between Stripe accounts
and is specific to Stripe Connect.
- Payout: this describes the movement of funds from a Stripe account to a
bank account, debit card or any future payout method.
- RecipientTransfer: this describes the movement of funds from a Stripe
account to a Recipient's card or Bank Account. This is here for legacy
reasons and can only be accessed from an expanded BalanceTransaction.

This change is behind an API version so old API versions would still use
the Transfer object for everything while new API version would see the
split.

This applies beyond the new object as some properties/methods are removed
from Transfer and other properties are renamed on other objects.
2017-03-31 14:03:56 -04:00
Brandur
f9fda0ed4c Small update for wording consistency and Vim hint 2017-03-28 12:16:45 -07:00
Brandur
cb841602fa Merge pull request #520 from stripe/brandur-update-openapi-conventions
Update some OpenAPI repository conventions
2017-03-23 17:29:46 -07:00
Brandur
96e03a8443 Update some OpenAPI repository conventions
See [1] for details, but a few conventions changed around the structure
of the OpenAPI repository and the data within the fixtures file. Here we
put in some minor changes to compensate for them.

[1] https://github.com/stripe/openapi/pull/3
2017-03-23 16:28:36 -07:00
Brandur
0727e11a5b Bump version to 2.1.0 2017-03-17 12:17:00 -07:00
Brandur
53f97b5000 Merge pull request #515 from stripe/ob-delete-sources
Adds support for detaching sources from customers
2017-03-17 12:15:56 -07:00
Olivier Bellone
433c660cfe Fix sources 2017-03-17 16:11:05 +01:00
Olivier Bellone
58a965523a Fix cards 2017-03-17 16:11:05 +01:00
Olivier Bellone
89f207f993 Update fixtures files 2017-03-17 16:11:05 +01:00
Olivier Bellone
b8e6a385cf Adds support for detaching sources from customers 2017-03-17 16:11:05 +01:00
Brandur
c9a3c7933b Bump version to 2.0.3 2017-03-16 13:03:27 -07:00
Brandur
bb53b3e63f Merge pull request #516 from stripe/ob-fix-512
Exclude client when dumping objects
2017-03-16 13:02:34 -07:00
Olivier Bellone
d3e40bb1de Exclude client when dumping objects 2017-03-16 20:54:13 +01:00
Brandur
66d8ecd0d0 Bump version to 2.0.2 2017-03-16 09:06:27 -07:00
Brandur
da9d8f7353 Merge pull request #517 from iamvery/fix-typo-in-json-error-handling
Replace invalid message Faraday::Response#code with valid #status
2017-03-16 09:02:10 -07:00
Jay Hayes
20553e7422 Replace invalid message Faraday::Response#code with valid #status
The Faraday::Response object does not respond to #code. The correct
message is #status. It seems this case was previously unhandled by the
test suite as there was no case for the server responding "success" with
an invalid JSON body.
2017-03-16 06:24:45 -05:00
Brandur
ae5bf8d460 Merge pull request #514 from stripe/brandur-update-certs-url
Point certificate bundle URL directly at cURL
2017-03-15 13:20:08 -07:00
Brandur
f4e0de5974 Also update our certificate bundle for good measure 2017-03-15 10:46:35 -07:00
Brandur
90344eeaa0 Point certificate bundle URL directly at cURL
We were using this GitHub link instead because the cURL site didn't
support HTTPS for the longest time. They do now, so repoint this URL.
2017-03-15 10:44:59 -07:00
Brandur
eb0883ee75 Merge pull request #513 from stripe/brandur-update-spec
Add Rake task to update OpenAPI specification
2017-03-14 23:52:10 -07:00
Brandur
effce7f181 Rename schema_data to spec_data for consistency 2017-03-14 17:07:50 -07:00
Brandur
4d7019bee6 Move OpenAPI spec from spec/ to openapi/
Naming a directory `spec` in a Ruby project is terribly ambiguous. This
clarifies the purpose of this directory and makes it easier to find if
you know that you're looking for OpenAPI.
2017-03-14 17:07:50 -07:00
Brandur
3b193db847 Add script to update the OpenAPI specification
Also fixes the task to retrieve a CA bundle which broke on the upgrade
from rest-client to Faraday.
2017-03-14 17:07:49 -07:00
Brandur
8564d3b629 Update bundle OpenAPI specification 2017-03-14 16:50:50 -07:00
Brandur
edac0b2c51 Merge pull request #511 from stripe/brandur-readme-update
Prefer use of the word "library" over "bindings"
2017-03-14 10:43:07 -07:00
Brandur
677454efe8 Link directly to API keys 2017-03-14 10:41:33 -07:00
Brandur
a84d8e7691 s/SDK/library/ 2017-03-14 10:38:54 -07:00
Brandur
500ace9f7b Prefer use of the word "SDK" over "bindings"
Minor difference in vernacular, but as noted in stripe/stripe-node#312,
the usage of the word "bindings" is unusual outside of Stripe.
2017-03-13 16:09:52 -07:00
Brandur
8f817b8365 Merge pull request #509 from stripe/brandur-bump-api-spec
Bump OpenAPI spec to latest
2017-02-24 10:19:12 -08:00
Brandur
6393ea6416 Expect cards instead of tokens 2017-02-23 18:12:51 -08:00
Brandur
3a0417c648 Add latest API spec and fixtures 2017-02-23 18:12:43 -08:00
Brandur
1bb9ac48b9 Bump version to 2.0.1 2017-02-22 08:11:30 -08:00
Brandur
083038e7c0 Merge pull request #508 from stripe/brandur-fix-file-uploads
Properly encode file uploads
2017-02-22 08:07:53 -08:00
Brandur
77c8535fa3 Properly encode file uploads
As described in #506, file uploads were broken on the way over to
Faraday and unfortunately I didn't catch it because the file upload
creation test wasn't using a matcher that was strict enough to really
catch anything.

Here we add the multipart middleware to our Faraday connection, add a
compatibility layer to `FileUpload` so that we can support `File` like
the rest-client based version always did (Faraday generally expects an
`UploadIO` object), and then tighten up our tests so that we'd be able
to catch future regressions.

Fixes #506.
2017-02-21 17:35:21 -08:00
Brandur
ea90ddb6d3 Bump version to 2.0.0 2017-02-14 14:24:40 -08:00
Brandur
150432183a Merge pull request #505 from stripe/brandur-update-readme
Update README
2017-02-14 14:14:19 -08:00
Brandur
5dd5d2b608 Merge pull request #499 from stripe/brandur-openapi-test-suite
100% OpenAPI-powered test suite
2017-02-14 12:48:33 -08:00
Brandur
7d186618fc Update README
Adds a section on configuring a custom client, makes certain sections
more terse, and rewrites the "configuration section" to be more
consistent and prominent.
2017-02-14 12:48:07 -08:00
Brandur
d8f3609f25 Don't shadow outer variable 2017-02-14 12:19:16 -08:00
Brandur
9bf2f67f0c Remove some internal/deprecated API methods 2017-02-14 12:17:37 -08:00
Brandur
d917480324 Add descriptions for has_more 2017-02-14 12:17:37 -08:00
Brandur
9f150d8b05 New version of specs, now with list annotations 2017-02-14 12:17:37 -08:00
Brandur
6eae453735 Commit various spec improvements 2017-02-14 12:17:37 -08:00
Brandur
6b2e3c1eb5 Update create params for methods that were previously too forgiving 2017-02-14 12:17:37 -08:00
Brandur
b1adb9a1e9 Update OpenAPI spec 2017-02-14 12:17:37 -08:00
Brandur
d101b3a7a1 Remove OverrideSinatra and its features because they're unused
I'd originally added this class for the first stub pass that used
OpenAPI because I thought we'd need the ability to finetune some of our
stubbed responses. It turns out that we've been able to get away without
it so far so I'm removing it for now. This commit can be reverted if it
turns out that we need it back later.
2017-02-14 12:17:37 -08:00
Brandur
b0b219844c Fix wording: hyper-schema is now OpenAPI spec 2017-02-14 12:17:37 -08:00
Brandur
03af6d0ac8 Add .gitattributes to suppress spec changes in diffs 2017-02-14 12:17:37 -08:00
Brandur
02ea970f67 Remove all resource-related test data
Now that we're powering all test suites with the fixture data that's
generated along with the OpenAPI spec, we don't need this secondary
sample data anymore. Remove all of it except for helpers to simulate
different types of error responses.
2017-02-14 12:17:37 -08:00
Brandur
3f549fb5ad Port all tests over to OpenAPI
Follows the path established in 2d75c8f by porting the rest of
stripe-ruby's tests over to OpenAPI. There are a few other changes here
where I've removed some tests that are duplicated or don't make much
sense, or reorganized how we test certain things, but this commit is
largely the same migration operation applied in bulk a few dozen test
suites.
2017-02-14 12:17:37 -08:00
Brandur
5f4eff7e35 Port charge test suite to use OpenAPI spec
Ports the charge test suite over to use the stub server which is powered
by the OpenAPI spec and its fixtures.

We also introduce a number of conventions here especially around test
case naming and assertions that we'll diffuse to all other test suites
as we port them over. The entire set of tests is internally inconsistent
because of how each new module and resource was added incrementally over
time and while no strong conventions existed.
2017-02-14 12:17:37 -08:00
Brandur
f0579950a7 Add testing infrastructure to use spec and fixtures
Adds some testing infrastructure that reads in the OpenAPI spec and its
fixtures. These changes will allow us to starting porting over each of
stripe-ruby's test suites.
2017-02-14 12:17:37 -08:00
Brandur
e9d4e27a4b Add OpenAPI spec + fixture data
This adds an OpenAPI spec for the Stripe API and sample responses for
all top-level resources. We will use the spec and the samples to power
the stripe-ruby test suite.
2017-02-14 12:17:37 -08:00
Brandur
357a99236a Add Committee/Sinatra + add Rack hack
We want to support older versions of Ruby so introduce a Rack hack to
get an older version of it that can run against them.
2017-02-14 12:17:37 -08:00
Brandur
4debb6ba5d Use one default connect per thread 2017-02-14 12:17:37 -08:00
Brandur
db72af0fdc Push Pry into MRI
The JRuby build seems to be having trouble.
2017-02-14 12:17:37 -08:00
Brandur
d4bcfd9f78 Refactor errors interfaces 2017-02-14 12:17:37 -08:00
Brandur
6dfea0d623 A few extra header tests 2017-02-14 12:17:37 -08:00
Brandur
2ade248e32 All tests working! 2017-02-14 12:17:37 -08:00
Brandur
31020c4596 Move profiling information to SystemProfiler + merge tests 2017-02-14 12:17:37 -08:00
Brandur
de08a9b986 Lots of broken tests, but working implementation! 2017-02-14 12:17:37 -08:00
Brandur
41f58e3cde Functional and tested StripeClient 2017-02-14 12:17:37 -08:00
Brandur
1c780e2b3f Working test suite! 2017-02-14 12:17:37 -08:00
Brandur
1886d9a625 Move to an alternative system based on StripeClient 2017-02-14 12:17:37 -08:00
Brandur
593bbab53f Use unambiguous wording "StripeResponse object" instead of "structure" 2017-02-14 12:17:37 -08:00
Brandur
b5ad0e30d7 Change to hash parameter for now for 1.9 support 2017-02-14 12:17:37 -08:00
Brandur
1412479bf6 Check that responses are set on API resources 2017-02-14 12:17:37 -08:00
Brandur
b365189ae9 Add tests for new .convert_to_stripe_object argument 2017-02-14 12:17:37 -08:00
Brandur
44fbe04bb7 Add test suite for StripeResponse 2017-02-14 12:17:37 -08:00
Brandur
843ea88219 Add a StripeResponse to objects created by API calls 2017-02-14 12:17:37 -08:00
Brandur
15f77a6e47 Merge pull request #496 from stripe/brandur-webmock
Use Webmock instead of Mocha for HTTP stubbing
2017-02-14 12:16:32 -08:00
Brandur
31b0ccfb33 Merge pull request #495 from stripe/brandur-kill-19
Remove support for Ruby 1.9
2017-02-14 12:12:03 -08:00
Brandur
3cf2ba3527 Use basic JSON.generate instead of make_response abstraction 2017-02-14 12:07:18 -08:00
Brandur
360d4e97ba Fix problems introduced by rebase + make consistent 2017-02-14 12:07:18 -08:00
Brandur
de700d3cc8 Convert the last set of tests 2017-02-14 12:07:18 -08:00
Brandur
d1d5b9d39d More tests converted 2017-02-14 12:07:18 -08:00
Brandur
0019cfdc7e More updated tests 2017-02-14 12:07:18 -08:00
Brandur
1ef1f79a16 Lots of fixed tests 2017-02-14 12:07:18 -08:00
Brandur
7ed2abffdd Remove support for Ruby 1.9
This has been discussed, but we'll finally be doing it for the next
major version so that we can introduce a few features that depend on
gems that don't support 1.9.
2017-02-14 12:07:18 -08:00
Brandur
ddaf36e00c Remove support for Ruby 1.9
This has been discussed, but we'll finally be doing it for the next
major version so that we can introduce a few features that depend on
gems that don't support 1.9.
2017-02-14 12:06:10 -08:00
Brandur
32530b1ad6 Merge pull request #500 from stripe/brandur-ruby-24
Add Ruby 2.4 to the build list
2017-02-02 10:27:06 -08:00
Brandur
622ea63281 Add Ruby 2.4 to the build list 2017-02-02 10:16:52 -08:00
Brandur
98c42e0b69 Bump version to 1.58.0 2017-01-19 14:11:17 -08:00
Brandur
c46ec2b355 Merge pull request #494 from stripe/ob-sources-tests
Better tests for sources
2017-01-19 14:10:25 -08:00
Olivier Bellone
9735255318 Better tests for sources 2017-01-19 18:32:58 +01:00
Brandur
b291bce240 Alphabetize class name list 2017-01-13 12:41:35 -08:00
Brandur
6b697ae23a Merge pull request #491 from stripe/brandur-uname
Colocate uname helpers + tests
2017-01-13 11:46:11 -08:00
Brandur
4da4bd3ff3 Colocate uname helpers + tests
Colocates the helper methods for looking up a uname by renaming them to
have the same prefix as the base method (i.e. `get_uname`).

Also adds an additional rescue in case we try to run an executable on a
system but it wasn't founded (this should never happen).

Also adds some tests to make sure that each method gets at least a very
basic amount of exercise in the test suite.
2017-01-13 10:59:08 -08:00
Brandur
1b15101d8d Merge pull request #490 from stripe/brandur-errors-test
Add basic test for errors
2017-01-13 10:50:50 -08:00
Brandur
50a023a33b Add basic test for errors
Just adds a super simplistic test for the errors module. The win here is
to (hopefully) lower the friction a little bit the next time a feature
is introduced into errors because there's now suite where a new test can
be written.
2017-01-13 10:38:20 -08:00
Brandur
c3e1e82d9b Merge pull request #489 from stripe/brandur-consolidate-and-document-errors
Consolidate errors to one file + document them
2017-01-13 10:38:02 -08:00
Brandur
09c4885d31 Consolidate errors to one file + document them
Right now we have every error class in a separate file which doesn't do
anyone a lot of good, especially given that most of them are just stubs
that derive directly from `StripeError`.

This patch pulls them all into one file and gives them some
documentation. It follows #487 and #488 as minor refactoring work.
2017-01-13 10:28:10 -08:00
Brandur
aab50511a1 Merge pull request #488 from stripe/brandur-alphabetize-require-list
Alphabetize stripe.rb require list
2017-01-13 10:27:55 -08:00
Brandur
da1b87f1c6 Alphabetize stripe.rb require list
Alphabetizes the list of named model requires in stripe.rb. This makes
it a little easier to spot things, and makes the correct spot to insert
a new model fully deterministic.

This continues along the path of #487 in introducing minor cleanups.
2017-01-13 10:06:32 -08:00
Brandur
f957cfc088 Merge pull request #487 from stripe/brandur-alphabetize-stripe-rb
Alphabetize methods in lib/stripe.rb
2017-01-13 10:05:56 -08:00
Brandur
83201e1a48 Alphabetize methods in lib/stripe.rb
This one is unfortunately a lot of churn, but it's incredibly
frustrating how difficult it is to find methods in this file.

Here we alphabetize the methods, but do nothing else. Alphabetization
only occurs within visibility blocks, so visibility is not affected at
all.
2017-01-13 09:58:29 -08:00
Brandur
fb555a764e Bump version to 1.57.1 2016-11-28 17:52:27 -08:00
Brandur
d9d28fef21 Merge pull request #483 from stripe/brandur-disallow-protected-field-set
Don't allow protected fields in `Save.update` API operation
2016-11-28 17:51:25 -08:00
Brandur
11a6eec5f5 Don't allow protected fields in Save.update API operation
As described in #481, adding a protected field like `legal_entity` as
part of an update API operation can cause some issues like a custom
encoding scheme not being considered and special handling around empty
values being ignored.

As a an easy fix for this, let's disallow access to protected fields in
the same way that we disallow them from being set directly on an
instance of a given model.

Helps address (but is not a complete fix for) #481.
2016-11-28 11:42:57 -08:00
Brandur
58184c2039 Bump version to 1.57.0 2016-11-21 18:03:06 -08:00
Brandur
ae3e6db268 Merge pull request #480 from stripe/ob-3ds-retrieve
Adds 3DS retrieve endpoint
2016-11-21 18:02:20 -08:00
Olivier Bellone
4122f9bbb3 Adds 3DS retrieve endpoint 2016-11-21 19:36:58 +01:00
Brandur
b3828b6736 Bump version to 1.56.2 2016-11-17 11:54:35 -08:00
Brandur
1c4d43aad5 Merge pull request #479 from Amos47/recurse-on-stripe-objects
Allow to_s to also pretty_generate embedded StripeObjects
2016-11-17 11:53:34 -08:00
Amos47
46d992cf0d allow to_s to also pretty_generate embedded StripeObjects 2016-11-17 14:28:51 -05:00
Brandur
c826049813 Bump version to 1.56.1 2016-11-09 15:16:33 -08:00
Brandur
bf326fb243 Merge pull request #478 from stripe/brandur-fix-memory-leak
Fix memory leak
2016-11-09 15:15:50 -08:00
Brandur
e3e070785b Fix memory leak
Fixes a memory leak caused by a doubled up `instance_eval`. See [1] for
context and discussion.

[1] https://github.com/stripe/stripe-ruby/issues/477
2016-11-08 17:38:58 -08:00
Olivier Bellone
f50e7a4162 Merge pull request #476 from ronbak/feram-patches
Minor Fixes
2016-11-06 14:00:10 +01:00
Feram
f14bf618e5 Fix typo unkown 2016-11-06 05:19:10 +00:00
Brandur
747a78d4d7 Merge pull request #474 from stripe/ob-issue-template
Added a template for GitHub issues
2016-11-03 11:23:07 -07:00
Brandur
2e7873149f Merge pull request #475 from takiy33/remove-respond_to-method-for-1.9.2
Remove respond_to? method for Ruby 1.9.2 or earlier
2016-11-03 11:22:09 -07:00
takiy33
2e1931b153 Remove respond_to? method for Ruby 1.9.2 or earlier 2016-11-03 23:10:10 +09:00
Olivier Bellone
a80f5f0a3d Added a template for GitHub issues 2016-11-03 12:04:14 +01:00
Brandur
2de99c55ce Bump version to 1.56.0 2016-10-24 09:23:06 -07:00
Brandur
f44bf4def3 Correct CHANGELOG 2016-10-24 09:21:42 -07:00
Brandur
1437fa5418 Bump version to 1.55.1 2016-10-24 09:16:29 -07:00
Brandur
2d4cdd95ac Merge pull request #472 from IndieBarry/ybk-fix-method-not-defined
Create accessor methods in update_attributes
2016-10-24 09:12:24 -07:00
Barry Kim
4faa7d169f Create accessor methods in update_attributes 2016-10-21 17:06:58 -07:00
Brandur
7e17330561 Merge pull request #471 from stripe/brandur-alphabetize-class-list
Alphabetize class list
2016-10-14 16:59:08 -07:00
Brandur
dff2bf10dd Alphabetize class list
This is a pretty pedestrian change, but here we alphabetize the list of
StripeObject class mappings so that it's easier to scan it for
accidental omissions.
2016-10-14 16:31:51 -07:00
Brandur
876ae8e4dd Merge pull request #470 from stripe/brandur-rename-permissions
Rename error class to be singular "permissions"
2016-10-14 10:58:29 -07:00
Brandur
7b9169712f Rename error class to be singular "permissions"
The addition of this class was unreleased so this is not a breaking
change.
2016-10-14 10:29:09 -07:00
Brandur
8f8d0e9cca Merge pull request #469 from stripe/jack-403
Handle 403 status codes
2016-10-14 10:01:44 -07:00
Jack Flintermann
1806d9524c handle 403 status codes 2016-10-14 08:57:19 -04:00
Brandur
52b4203af5 Merge pull request #468 from morgoth/fix-retry-description
Fixed description about DELETE request retries
2016-10-03 09:11:36 -06:00
Wojciech Wnętrzak
bb6838b5a9
Fixed description about DELETE request retries
[ci skip]
2016-10-03 14:18:47 +02:00
Kyle Conroy
c131bcbcac Correctly encode the subscription items array (#467)
* Correctly encode the subscription items array

* Use super

* Handle non-arrays as well

* Also encode items on create
2016-09-27 13:46:57 -07:00
Jacqueline
d2f783df34 Add support for multiplan subscriptions (#466)
* Add support for multiplan subscriptions:
Serialize indexed arrays into hashes with index keys in subscription create, subscription update, and upcoming invoice
Add a SubscriptionItem object that supports creation, deletion, update, listing, and retrieval

* Remove helpers that convert items array to indexed hash
2016-09-21 17:44:00 -07:00
Brandur
7637eb48bf Bump version to 1.55.0 2016-09-15 10:27:19 -07:00
Brandur
bcb7b21a47 Merge pull request #465 from stripe/vijay-apple-pay-domain
Ruby bindings for ApplePayDomain
2016-09-15 11:24:03 -06:00
Vijay Singh
e2cc264c12 Hoist extend and include directives to top of class 2016-09-15 10:14:42 -07:00
Vijay Singh
7ac03e0a88 Changed from ApplePay::Domain to ApplePayDomain 2016-09-14 18:43:56 -07:00
Vijay Singh
4e802c9814 Fixed incorrect comment/variable naming 2016-09-14 18:20:55 -07:00
Vijay Singh
35bbb7a26b Ruby bindings of ApplePayDomain 2016-09-14 18:16:12 -07:00
Brandur
3b595a9e7f Bump version to 1.54.0 2016-09-01 10:24:30 -07:00
Brandur
4a4b8699fb Merge pull request #463 from stripe/brandur-whitelist-retry-exceptions
Whitelist retry exceptions
2016-09-01 10:23:06 -07:00
Brandur
6ebf6ad92a Whitelist retry exceptions
Right now we are retrying *most* non-HTTP exceptions. This is
problematic because in something like a test context, even a rogue name
error could initiate a retry. It's also bad for production because there
are quite a number of socket errors [1] for which we don't want to
retry.

Fixes #462.

[1] https://ruby-doc.org/stdlib-2.3.0/libdoc/socket/rdoc/Socket.html
2016-08-31 15:23:21 -07:00
Brandur
805b65478c Bump version to 1.53.0 2016-08-31 08:10:34 -07:00
Brandur
e3dd15273c Merge pull request #460 from stripe/brandur-upgrade-rest-client
Relax rest-client requirements
2016-08-31 08:09:26 -07:00
Brandur
5039d22339 Merge pull request #461 from stripe/brandur-fix-warnings
Fix interpreter warnings
2016-08-31 08:09:19 -07:00
Brandur
6b46b50c1b Fix interpreter warnings
These aren't causing the build to fail or anything, but they do get
spewed out every time our test suite runs.
2016-08-31 07:12:53 -07:00
Brandur
aa12f7e621 Relax rest-client requirements
Our fairly old requirements for rest-client (and therefore mime-types)
are starting to cause some dependency hell problems for some customers.
Try relaxing these constraints and locking 1.9 specifically into
compatible versions.
2016-08-31 06:56:17 -07:00
Brandur
73a1cf33de Bump version to 1.52.0 2016-08-30 14:48:55 -07:00
Brandur
2da96e4798 Merge pull request #458 from stripe/brandur-generalize-save-nested-resource
Generalize saving nested resources
2016-08-30 14:47:52 -07:00
Brandur
22839df560 Nicen this code up a little bit and add a comment 2016-08-30 13:42:11 -07:00
Brandur
c796958516 Generalize saving nested resources
Since #433, saving API resources nested under other API resources has
not been the default. Instead, any instances where this should occur
have been special cased with specific method implementations that would
set the `#save_with_parent` flag when a field is written.

This ended up causing some problems because as seen in #457, because
places that we need to do this aren't well vetted, some were forgotten.

This makes implementation of new fields that need this behavior simpler
by implementing a `.save_nested_resource` metraprogramming method on the
`APIResource` class. This can be called as necessary by any concrete API
resource implementations.

We replace existing implementatinos and also add one to `Subscription`,
which had previously been suffering from a similar problem where its
`#source` had not received a special case.
2016-08-30 11:52:16 -07:00
Brandur
c15e3953fe Bump version to 1.51.1 2016-08-30 11:13:56 -07:00
Brandur
41f09a75a3 Merge pull request #457 from stripe/brandur-fix-account-external-account-set
Flag Account#external_account into save_with_parent system
2016-08-30 11:12:57 -07:00
Brandur
1dd5cea24d Fix title of test context 2016-08-30 10:22:17 -07:00
Brandur
67b10a52ca Add deprecated #bank_account=
Add deprecated `#bank_account=` to maintain backwards compatibility.
This would have been broken by #433, so this change keeps the
functionality alive in case someone has not upgraded since.
2016-08-29 13:44:46 -07:00
Brandur
d6514ef633 Flag Account#external_account into save_with_parent system
In #433, we built a framework under which subresources are usually not
persisted, but in certain cases they can be. At the time,
`Customer#source` was the only field that I knew about that had to be
flagged into it.

Issue #456 has raised that we also be doing `Account#external_account`.
This patch adds support for that.

Fixes #456.
2016-08-29 10:34:08 -07:00
Brandur
5573cc73fc Bump version to 1.51.0 2016-08-26 10:20:29 -07:00
Brandur
d61c1b1211 Merge pull request #455 from stripe/brandur-header-like-headers
Move away from rest-client's "symbol header names"
2016-08-26 10:19:00 -07:00
Brandur
ee03100891 Merge pull request #454 from stripe/brandur-error-on-improper-array-of-maps
Produce an error on bad array of maps
2016-08-26 10:17:22 -07:00
Brandur
6cd72a1eb4 Fix word reversal 2016-08-25 17:11:55 -07:00
Brandur
7df3a4bdd6 One more test case to show that the check is recursive 2016-08-25 17:09:50 -07:00
Brandur
a5a9eb94db Produce an error on bad array of maps
This produces an error when we detect an "array of maps" that cannot be
encoded with `application/x-www-form-urlencoded`; that is to say, one
that does not have each hash starting with a consistent key that will
allow a Rack-compliant server to recognize boundaries.

So for example, this is fine:

```
items: [
    { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk' },
    { :type => 'discount', :amount => -10000, :currency => 'cad', :description => 'potato' }
],
```

But this is _not_ okay:

```
items: [
    { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk' },
    { :amount => -10000, :currency => 'cad', :description => 'potato', :type => 'discount' }
],
```

(`type` should be moved to the beginning of the array.)

The purpose of this change is to give users better feedback when they
run into an encoding problem like this one. Currently, they just get
something confusing from the server, and someone on support usually
needs to examine a request log to figure out what happened.

CI will fail until the changes in #453 are brought in.
2016-08-25 17:07:56 -07:00
Brandur
fb9fd44dd6 Bump version to 1.50.1 2016-08-25 14:36:59 -07:00
Brandur
497201aca7 Merge pull request #453 from stripe/brandur-stop-alphabetizing
Don't alphabetize encoded maps by key
2016-08-25 14:34:05 -07:00
Brandur
2a9413e155 Move away from rest-client's "symbol header names"
This moves away from rest-client's convention of using symbols as header
names so as to present less obfuscation as to how these are actually
named when they go over the wire.

Because headers can be injected via the bindings' API I was initially
worried that this change might break something, but upon inspection of
rest-client source, I can see now that headers take precedence as
assigned by their insertion order into the header hash, and are
"stringified" in that same loop [1]. This means that even if a user
injects a symbolized header name (`:idempotency_key`), it will still
correctly overwrite the one generated by stripe-ruby despite that using
the string format (`"Idempotency-Key"`).

[1] https://github.com/rest-client/rest-client/blob/master/lib/restclient/request.rb#L603,L625
2016-08-25 11:42:44 -07:00
Brandur
d9b6f08ce5 Don't alphabetize encoded maps by key
Alphabetizing maps being encoded by key can cause problems because the
server side Rack relies on the fact that that a new array item will
start with a repeated key.

For example, given this encoding:

```
items: [
    { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk' },
    { :type => 'discount', :amount => -10000, :currency => 'cad', :description => 'potato' }
],
```

We need to have `type` appear first so that an array boundary is
recognized. So the encoded form should take:

```
items[][type]=sku&items[][parent]=...&items[][type]=discount&items[][amount]=...
```

But currently `type` gets sorted to the back, so we get something more
like:

```
items[][parent]=...&items[][type]=...&items[][amount]=...&items[][currency]=...&items[][description]=...&items[][type]=potato
```

Which the server will receive as this:

```
items: [
    { :type => 'sku', :parent => 'sku_94ZYSC0wppRTbk', :amount => -10000, :currency => 'cad', :description => 'potato' }
    { :type => 'discount' }
],
```

Here we remove the alphabetization to fix the problem and correct a bad
test.
2016-08-25 10:54:08 -07:00
Brandur
980fd2bd07 Merge pull request #449 from stripe/brandur-readme-usage
Add usage section to README
2016-08-17 15:24:33 -07:00
Brandur
0ef5c629f9 Add stripe_account in here as well 2016-08-17 13:56:50 -07:00
Brandur
8952860d8e Bump version to 1.50.0 2016-08-15 13:36:56 -07:00
Brandur
adb8e5307d Merge pull request #450 from stripe/will-add-source-create
Add ability to create sources
2016-08-15 12:09:38 -07:00
Will Bronitsky
6062d27ed8 Add ability to create sources 2016-08-12 09:53:39 -07:00
Brandur
b2d0490a86 Add usage information for using an API key with a list operation 2016-08-10 11:28:52 -07:00
Brandur
af68678895 Add usage section to README
Add a section that contains basic usage information to the README.
2016-08-10 11:00:41 -07:00
Brandur
e7f09c2e68 Bump version to 1.49.0 2016-07-28 17:35:50 -07:00
Brandur
830e2baf42 Merge pull request #446 from stripe/will-add-source-functionality
Add Source functionality
2016-07-28 17:34:58 -07:00
Will Bronitsky
4a6d70bf14 Add Source functionality 2016-07-28 17:25:06 -07:00
Romain Huet
2026c06242 Update the Travis CI badge 2016-07-12 18:55:38 -07:00
Brandur
d7abd71071 Bump version to 1.48.0 2016-07-12 10:11:55 -07:00
Brandur
5d31fc1e1b Merge pull request #442 from stripe/ob-3ds
Added support for 3D Secure
2016-07-12 10:11:29 -07:00
Olivier Bellone
be8c56458f Added support for 3D Secure 2016-07-12 17:01:33 +02:00
Brandur
7ed6e48b48 Bump version to 1.47.0 2016-07-11 16:54:50 -07:00
Brandur
b0f347dcf3 Merge pull request #439 from mikesea/rest-client-version
Relax rest-client version requirements
2016-07-11 16:53:40 -07:00
Mike Chlipala
65bbee4bf8 Relax rest-client version requirements 2016-07-11 16:36:23 -07:00
Brandur
d32a514393 Merge pull request #441 from stripe/brandur-mime-types-workaround-2
Workaround for mime-types related failures on 1.9
2016-07-11 15:48:45 -07:00
Brandur
d250120102 Workaround for mime-types related failures on 1.9 2016-07-11 15:06:56 -07:00
Brandur
d6c73c2b65 Merge pull request #438 from stripe/brandur-remove-restclient-workaround
Remove hack to work around rest-client bug
2016-07-07 11:16:51 -07:00
Brandur
ac49ef0b59 Remove hack to work around rest-client bug
This removes a hack in the code that's designed to work around a
rest-client bug which was added back in 2011. Unfortunately neither
comments nor commit messages bother to tell us what the nature of the
bug actually was, but based on what it's rescuing, it might be
rest-client/rest-client#58, which has been fixed for over five years
now.

Following up on the work done in #436, let's continue to try and simply
the error handling paths by taking this out.
2016-07-07 09:25:48 -07:00
Brandur
660f7725b7 Bump version to 1.46.0 2016-07-07 09:20:14 -07:00
Brandur
b97e1010c0 Merge pull request #436 from stripe/brandur-retry-conflict
Rework HTTP retry path + retry 409s
2016-07-07 09:19:36 -07:00
Brandur
bf1cc03227 Bump version to 1.45.0 2016-07-07 09:05:25 -07:00
Brandur
e2499edfa3 Merge pull request #433 from stripe/brandur-serialize-whitelist
Go back to not saving subresources, but exclude `Customer#source=`
2016-07-07 09:04:06 -07:00
Brandur
3984246514 Rework HTTP retry path + retry 409s
Two changes:

1. The HTTP retry path has been refactored to make retries on errors
that are not RestClient exceptions possible by bringing the logic up a
level. This also has the effect of somewhat simplifying the exception
handling logic which can be somewhat difficult to reason about right
now.

2. Retry on `RestClient::Conflict` (a 409 from the API) as discussed in
issue #431.

Fixes #431.
2016-07-05 12:37:39 -07:00
Brandur
6a41234406 Additional commentary on #source= method and implementation 2016-07-01 15:54:38 -07:00
Brandur
6560cfaf4b Don't talk about "default source" here 2016-07-01 15:54:38 -07:00
Brandur
2a4a50da8e Introduce #save_with_parent flag
Introduce a `#save_with_parent` flag that allows the default behavior of
never saving API resources nested under a parent to be overridden, a
feature that we so far only know to need for updating a source under a
customer.
2016-07-01 15:54:38 -07:00
Brandur
d0a3493144 Revert "Remove check that prevents API resource subobjects from being serialized"
This reverts commit 7bbc6ef2e59006cc6d9410a92a09d8c5c68d2893.
2016-07-01 15:54:38 -07:00
Brandur
be8466b47b Merge pull request #434 from stripe/brandur-fix-ci
Fix Gem builds in CI
2016-07-01 15:54:18 -07:00
Brandur
1e166d9be7 Fix Gem builds in CI
CI is failing for a number of Ruby versions because shoulda is pulling
in should-matchers, which then pulls in activesupport. activesupport's
new 5.0.0 version is being picked up, and that requires at least Ruby
2.2.2.

Luckily the solution is easy, we're not using shoulda-matchers, only
shoulda-context, so just tighten up our dependencies a little and the
problem goes away.
2016-07-01 15:44:32 -07:00
Brandur
774e885334 Clean up comments around exponential backoff 2016-06-30 10:44:08 -07:00
Kyle Conroy
8377a9f941 Bump version to 1.44.0 2016-06-29 14:35:07 -07:00
Kyle Conroy
732a494ac4 Add update class method to API resources (#426)
* Rename the `Update` operation to `Save`
* Add the `update` class method to all saveable resources
* Add tests for update method
* Add tests for plans, invoice items, and application fees
2016-06-29 14:13:42 -07:00
Brandur
cb8917b7a3 Merge pull request #432 from Edouard-chin/req_url_doc_fix
Removed a forgotten line of doc [ci skip]:
2016-06-29 07:23:07 -07:00
Edouard CHIN
d288be358a Removed a forgotten line of doc [ci skip]:
- This removes the doc about `req_url` while saving a StripeObject, this options was removed in `e226ef`
2016-06-29 02:11:56 -04:00
Brandur
f2aa8c1e58 Bump version to 1.43.1 2016-06-17 14:48:07 -07:00
Brandur
ea06b1ba67 Merge pull request #428 from stripe/rasmus-fix_order_return_object
Convert return_order response to OrderReturn.
2016-06-17 14:47:14 -07:00
Rasmus Rygaard
f37a1f2f9f Convert return_order response to OrderReturn. 2016-06-17 11:03:56 -07:00
Brandur
3b06b2c880 Merge pull request #424 from JuanitoFatas/fix/gemspec-homepage
Fix homepage for Ruby docs in gemspec
2016-06-13 09:07:40 -07:00
JuanitoFatas
f4f8d38643 Fix homepage for Ruby docs in gemspec 2016-06-13 18:07:11 +08:00
Brandur
6fb907b322 Merge pull request #423 from stripe/brandur-document-convert
Document `Util.convert_to_stripe_object`
2016-06-09 09:39:24 -07:00
Brandur
6695340d50 Minor fixes to Rubydoc of #update_attributes 2016-06-09 09:19:28 -07:00
Brandur
531e0ff317 Document Util.convert_to_stripe_object
Adds some basic documentation to `Util.convert_to_stripe_object`.
2016-06-09 09:02:23 -07:00
Brandur
6920d9db68 Update authors/email in Gemspec
Unfortunately neither of these people work for Stripe anymore. Let's put
a valid contact email address in here instead.
2016-05-25 10:55:29 -07:00
Brandur
065ad92c0e Bump version to 1.43.0 2016-05-20 10:32:29 -07:00
Brandur
31c6fbe8bb Merge pull request #419 from stripe/rasmus-add_order_returns
Add order returns
2016-05-20 10:28:02 -07:00
Rasmus Rygaard
6202d66873 Add tests for return deletion, updating. 2016-05-20 09:54:09 -07:00
Rasmus Rygaard
dab45737c9 Add order returns. 2016-05-18 17:56:15 -07:00
Brandur
43c86909d7 Merge pull request #418 from stripe/remi-add-alipay-account
Support AlipayAccount retrieval and deletion
2016-05-18 11:02:03 +02:00
Remi Jannel
2a6673a8e5 Support AlipayAccount retrieval and deletion 2016-05-17 17:52:00 -04:00
Kyle Conroy
49382f7ac2 Bump version to 1.42.0 2016-05-04 14:15:44 -07:00
Jacqueline
60248fbd00 Use v1/subs endpoints for operations on subs and allow direct sub access (#411)
* allow subs to be retrieved & created with new v1/subs API endpoint

* edit tests to check for url

* fix customer subscription URLs to go through v1/customers
2016-05-04 14:14:24 -07:00
Brandur
ca7adcf8c8 Bump version to 1.41.0 2016-04-13 14:00:35 -07:00
Brandur
679b2b9b19 Merge pull request #412 from Edouard-chin/global-stripe-account-head
Allow `stripe_account` to be set globally:
2016-04-13 13:58:32 -07:00
Edouard CHIN
75f366acb9 Allow stripe_account to be set globally:
- When performing requests on the behalf of a managed account, `stripe_account` option must be passed everytime, this can become redundant
- Allowing to set the `stripe_account` globally makes thing easier for wrapping every request in a single method, the same way as it is for defining the `api_key` globally
2016-04-13 20:40:55 +00:00
Brandur
c98f555aeb Merge pull request #410 from stripe/brandur-fix-warnings
Fix warnings emitted during tests
2016-04-11 15:47:32 -07:00
Brandur
2663e9ff85 Merge pull request #409 from stripe/br-charge-outcomes
add test for handling of charge.outcome subfield
2016-04-11 15:23:43 -07:00
Brandur
8f55baa6ea Fix warnings emitted during tests
I'm not sure exactly what changed here (did we change the `$VERBOSE`
setting?), but I'm not seeing a whole lot of warnings when running the
test suites locally and in CI. For example:

```
Started
........................................./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
............../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
......../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
.../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
........./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
...
..../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
....../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
..../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
......./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
........./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
........../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
................./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
.../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
..../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
....../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
..........
........./home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
....../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
......../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
......../home/travis/build/stripe/stripe-ruby/lib/stripe/api_operations/list.rb:6: warning: instance variable @opts not initialized
............./home/travis/build/stripe/stripe-ruby/lib/stripe/stripe_object.rb:35: warning: instance variable @values not initialized
./home/travis/build/stripe/stripe-ruby/lib/stripe/stripe_object.rb:35: warning: instance variable @values not initialized
...................../home/travis/build/stripe/stripe-ruby/lib/stripe/transfer.rb:8: warning: instance variable @api_key not initialized
..............
..
Finished in 0.785621037 seconds.
```

Most of these are due to unused or uninitialized variables. This patch
fixes all warnings by fixing offending code.
2016-04-11 15:20:42 -07:00
Ben Rahn
6dfc4e8c25 add test for handling of charge.outcome subfield 2016-04-11 14:47:30 -07:00
Karla
cb734cfeac Merge pull request #408 from stripe/karla-openssl-errors
Catch SSL connection errors, and re-raise them as APIConnectionErrors
2016-04-11 10:39:13 -07:00
Karla Burnett
0046cd1e4f Catch SSL connection errors, and re-raise them as APIConnectionErrors
This is consistent with API library behavior in other languages, and with our
API documentation (which doesn't mention needing to handle this type of error).
2016-04-08 18:15:22 -07:00
Brandur
37cde9ed03 Bump version to 1.40.0 2016-04-06 15:53:54 -07:00
Brandur
2c79925212 Merge pull request #407 from stripe/brandur-remove-api-resource-check
Remove check that prevents API resource subobjects from being serialized
2016-04-06 13:47:38 -07:00
Brandur
bebf77e099 Merge pull request #397 from stripe/brandur-ca-store
Initialize an internal CA store
2016-04-05 10:53:44 -07:00
Brandur
7bbc6ef2e5 Remove check that prevents API resource subobjects from being serialized
Prior to my last major serialization refactor, there was a check in the
code that would remove any subobjects from serialization that were of
their own proper resource type (for example, if a charge contained a
customer, that customer would be removed).

What I didn't realize at the time is that the old serialization code had
a bug/quirk that would allow *certain types* of subobjects that were API
resources to make it through unscathed.

In short, the behavior requirement here is *directly* contradictory.
There was a test in place that would make sure that `customer` was
removed from this hash:

``` ruby
{
  :id => 'ch_id',
  :object => 'charge',
  :customer => {
    :object => 'customer',
    :id => 'customer_id'
  }
}
```

But, as reported in #406, we expect, and indeed need, for `source` (a
card) to make it through to the API in this hash:

``` ruby
{
  :id => 'cus_id',
  :object => 'customer',
  :source => {
    :object => 'card',
    :id => 'card_id'
  }
}
```

My proposal here is to just remove the check on serializing API
resources. The normal code that only sends up keys/hashes that have
changed is still in place, so in the first example, `customer` still
isn't sent unless the user has directly manipulated a field on that
subobject. I propose that in those cases we allow the API itself to
reject the request rather than try to cut it off at the client level.

Unfortunately, there is some possibility that removing those API
resources is important for some reason, but of course there's no
documentation on it beyond the after-the-fact post-justification that I
wrote during my last refactor. I can't think of any reason that it would
be too destructive, but there is some level of risk.
2016-04-01 10:54:53 -07:00
Brandur
3930d9a587 Bump version to 1.39.0 2016-03-31 14:43:52 -07:00
Brandur
4be5c9d23d Merge pull request #402 from stripe/brandur-cybertrust
Add "CyberTrust Global Root"
2016-03-31 14:35:29 -07:00
Brandur
9ae8a49697 Merge pull request #404 from stripe/brandur-improve-error-message
Improve error message on setting empty strings
2016-03-28 08:09:21 -07:00
Brandur
98d06ae6df Improve error message on setting empty strings
This improves the error message that a user sees when attempting to set
a property to an empty string.

Fixes #403.
2016-03-24 10:58:59 -07:00
Brandur
4947b0dfd0 Add "CyberTrust Global Root"
This allows old OpenSSL versions (0.9.8 and 1.0.0) to successfully
verify Stripe's certificate chain.
2016-03-22 17:10:55 -07:00
Brandur
e18823e63b Bump version to 1.38.0 2016-03-18 08:50:59 -07:00
Brandur
38f3263abe Merge pull request #401 from herimedia/add-options-to-save
Allow options (headers) to be passed into .save
2016-03-18 08:49:48 -07:00
Niels Ganser
db3059a3c0 Allow options (headers) to be passed into .save
in the same manner as is already possible for .create.
2016-03-18 13:30:36 +01:00
Brandur
b2db930f6a Bump version to 1.37.0 2016-03-14 14:30:56 -07:00
Brandur
efe4deb847 Merge pull request #400 from stripe/gregsabo-add-account-reject
Create account.reject method.
2016-03-14 14:30:12 -07:00
Greg Sabo
2c0f6bc219 Create account.reject method. 2016-03-14 13:43:19 -07:00
Brandur
b17cf0b78b Merge pull request #399 from stripe/brandur-fix-warning
Initialize @max_network_retries
2016-03-14 10:24:54 -07:00
Brandur
5c47264cc2 Initialize @max_network_retries
Certain platforms will throw an error if this variable is accessed
without being initialized. Assign it a value instead of relying on the
OR operator to give it a default.
2016-03-14 10:16:14 -07:00
Brandur
dfa0bf75a8 Merge pull request #398 from stripe/brandur-byebug-platform-lock
Lock Byebug to just the MRI
2016-03-14 10:15:39 -07:00
Brandur
a905da2ff2 9.0.5.0 instead? 2016-03-14 09:56:35 -07:00
Brandur
dd2bae2057 Lock Byebug to just the MRI
Here we predicate the installation of Byebug on being on the MRI. This
allows us to `bundle install` on alternate platforms like JRuby.

Also performs some Gemfile management: add latest MRI and JRuby versions
and remove special case Gemfiles.
2016-03-14 08:59:13 -07:00
Brandur
5ea3c264e3 Initialize an internal CA store
This attempts to give some semblance of thread safety to parallel
library requests by pre-assigning a certificate store, the
initialization of which seems to be a weak point for thread safety. Note
that while this does seem to empirically improve the situation, it
doesn't guarantee actual thread safety.

A longer term solution to the problem is probably to assign a per-thread
HTTP client for much stronger guarantees, but this is a little further
out. More discussion on that topic in #313.

Fixes #382.
2016-03-14 07:57:51 -07:00
Brandur
c3c541363b Bump version to 1.36.2 2016-03-14 07:25:28 -07:00
Brandur
5c999c3100 Merge pull request #396 from stripe/brandur-fix-list
Fix reference to URLs on ListObject
2016-03-14 07:24:14 -07:00
Brandur
0311b4a7cd Fix reference to URLs on ListObject
In #394 we renamed `url` to `resource_url` in order to prevent name
collisions in API resource that also have a `url` property.
Unfortunately, this didn't account for the fact that when making API
calls on a list object we rely on a returned `url` property to build a
request, and this had been renamed to `resource_url`. Test should have
caught this, but they were written to work differently than how live
API calls actually function.

This patch repairs the problem by adding a `resource_url` to list
objects, and modifies test to be more accurate to reality so that
they'll catch this class of problem in the future.

Fixes #395.
2016-03-14 06:52:26 -07:00
Brandur
f612aa9057 Merge pull request #394 from shekibobo/feature/resource-url
Fix ApiResource resource URL clashing with user-defined URL properties. Fixes #393.
2016-03-11 11:23:00 -08:00
Joshua Kovach
e226ef2ea1 Change everything from url to resource_url 2016-03-11 02:53:50 -05:00
Brandur
7849e844cd Merge pull request #390 from stripe/brandur-refactor-serialize-params
Refactor `serialize_params` under `StripeObject`
2016-03-07 11:41:48 -08:00
Brandur
b452835344 Fix spelling problem 2016-03-07 11:32:50 -08:00
Brandur
592bc89688 Refactor special case serialization for clarity 2016-03-07 11:27:45 -08:00
Brandur
dd11f4b297 Remove the ugly dirty == false 2016-03-07 11:11:57 -08:00
Brandur
27ebcbb697 Revert to opts = {} and rename to method_options 2016-03-07 09:59:33 -08:00
Brandur
eba117d5e8 Kill outdated "two" 2016-03-07 09:56:08 -08:00
Brandur
06cbe6239a Improve the accuracy on the comment above Hash serialization 2016-03-04 19:26:08 -08:00
Brandur
c173f802a6 Add comment about APIResource exclusion for clarity 2016-03-04 19:24:15 -08:00
Brandur
adcb806aac Add test to check .serialize_params deprecation 2016-03-04 19:22:17 -08:00
Brandur
f215827e2f Remove uses and deprecate .serialize_params 2016-03-04 19:18:26 -08:00
Brandur
fcfef21c77 Add spec for #dirty! 2016-03-04 19:10:59 -08:00
Brandur
f723080220 Refactor serialize_params under StripeObject
This pull does two major things:

1. Refactors `serialize_params` to be more concise and readable while
   still complying to our existing test suite. Unfortunately over time
   this method has become a ball of mud that's very difficult to reason
   about, as recently evidenced by #384.
2. Moves `serialize_params` from class method to instance method (while
   still keeping for old class method for backwards compatibility). This
   is to give it a more sane interface.
2016-03-04 19:04:29 -08:00
Brandur
fa314f6166 Bump version to 1.36.1 2016-03-04 15:01:05 -08:00
Brandur
127c6694e8 Merge pull request #389 from stripe/brandur-fix-save-with-hash
Fix serialization of hashes passed to `#save`
2016-03-04 14:59:44 -08:00
Brandur
d92d084211 Add a few more low-level StripeObject tests 2016-03-04 14:52:30 -08:00
François de Metz
bc6cc96310 Fix serialization of hash when calling save.
Hashes are converted to StripeObject when used as params of save.
They need to be converted to hash on serialize.

Signed-off-by: François de Metz <francois@stormz.me>
Signed-off-by: Cyril Duez <cyril@stormz.me>
2016-03-04 14:40:57 -08:00
Brandur
abbf4c6426 Fix some gross trailing whitespace 2016-03-04 14:03:32 -08:00
Brandur
f711494f54 Merge pull request #387 from stripe/brandur-pass-params-fee-refund
Pass params and opts through on `ApplicationFee#refund`
2016-03-03 23:59:33 -08:00
Brandur
3fab2cd59f Pass params and opts through on ApplicationFee#refund
`params` and `opts` are not currently passed through when using the
`#refund` helper on `ApplicationFee`. This was an omission on the
original refactor to use the new endpoint, and wasn't an intentional
design.

Fixes #386.
2016-03-02 13:45:57 -08:00
Brandur
24632af95a Merge pull request #385 from stripe/brandur-md-readme
Change README to Markdown
2016-02-22 16:20:28 -08:00
Brandur
f7717208ae Change README to Markdown
This is kind of a bike shed, but at this point it's a little more clear
that Markdown has won the format wars and that people are a little more
used to seeing/editing it.

This moves the `README` to Markdown and also includes some minor
cleanup:

* Fixes a broken reference link (`curl`).
* Normalizes lines to 80 characters.
* Normalizes code snippets to be prefixed by four spaces.
* Normalizes sentence to be separately by only a single space.
2016-02-22 16:07:07 -08:00
Brandur
270dfe6052 Fix grammar problem 2016-02-19 10:28:03 -08:00
Brandur
eda056b9f6 Improve accuracy of puts message 2016-02-15 09:10:35 -08:00
Brandur
3e9cba3afd Merge pull request #380 from mohnish/master
Clean up stripe-console and use the IRB API
2016-02-15 09:09:29 -08:00
Mohnish Thallavajhula
07a27b61b6 Clean up stripe-console and use the IRB API 2016-02-14 09:43:24 -08:00
Brandur
097e185042 Merge pull request #379 from ahacop/remove-json
Remove json gem dependency
2016-02-09 12:04:33 -08:00
Ara Hacopian
c0ef16ad1d Remove json gem dependency
All required rubies include JSON as part of the stdlib.
2016-02-09 14:12:39 -05:00
Brandur
9b1315d08c Bump version to 1.36.0 2016-02-08 08:24:04 -08:00
Brandur
85f191217b A few more nominal whitespace tweaks 2016-02-08 08:23:33 -08:00
Brandur
555341029b Tweak whitespace for consistency 2016-02-08 08:21:34 -08:00
Brandur
b2d74b09ff Merge pull request #376 from Easybring/master
support for country_spec
2016-02-08 08:19:36 -08:00
Ioannis Kolovos
f8532d225e Support for Stripe::CountrySpec 2016-02-06 16:55:29 +02:00
Brandur
3a258806a2 Bump version to 1.35.1 2016-02-03 14:06:08 -08:00
Brandur
d8fc785f34 Merge pull request #374 from stripe/brandur-refund-fallback
Provide compatibility patch the Charge#refund helper
2016-02-03 14:04:54 -08:00
Brandur
65b92dec4b Provide compatibility patch the Charge#refund helper
An unfortunate side effect of #364 is that it broke compatibility for
users on very old API versions because their `refunds` field will come
back as an array.

This adds a compatibility layer that will allow even users on old API
versions to seamlessly upgrade their gem versions.
2016-02-03 13:45:01 -08:00
Brandur
23c61cc867 Bump version to 1.35.0 2016-02-01 05:14:43 -08:00
Brandur
687be7015d Merge pull request #372 from stripe/brandur-update-bundle
Update CA bundle
2016-02-01 05:12:26 -08:00
Brandur
7aed899e1a Merge pull request #371 from stripe/brandur-configuration-ca-bundle-path
Allow the CA bundle to be configured
2016-02-01 05:12:14 -08:00
Brandur
31bbf02d4d Update CA bundle
Our CA bundle has fallen quite out of date since it was last pulled.
This patch updates it and adds a Rake task to make this task more
repeatable.

One thing worth noting is I've switched us over from the Ubuntu bundle
to the Mozilla bundle that's maintained by cURL. The bundle seemed to be
previously extracted by a custom script that I don't really want to
maintain. cURL and Excon both use the Mozilla bundle and it should be a
safe replacement.
2016-01-26 14:32:16 -08:00
Brandur
61ba47d619 Allow the CA bundle to be configured
As requested in #370, this will allow advanced users to configure a
certificate bundle that is expected to be more up-to-date than what
we've managed to include with the gem.
2016-01-26 14:19:07 -08:00
Brandur
91f42f4bc2 Bump version to 1.34.0 2016-01-25 11:24:07 -08:00
Brandur
a508688c3c Merge pull request #368 from stripe/rasmus-support_product_sku_deletion
Support deleting SKUs and products.
2016-01-25 11:22:59 -08:00
Rasmus Rygaard
8d8fb67aae Support deleting SKUs and products. 2016-01-25 10:32:49 -08:00
Brandur
03086b8086 Bump version to 1.33.1 2016-01-21 15:16:34 -08:00
Brandur
89cf6071b7 Merge pull request #366 from yogeshjain999/charge_refund_fix
Forward parameters passed to charge.refund
2016-01-21 11:54:33 -08:00
Yogesh Khater
4fe8474279 Forward parameters passed to charge.refund
fixes #365
2016-01-21 12:00:42 +05:30
Brandur
932ddb825a Bump version to 1.33.0 2016-01-19 15:48:20 -08:00
Brandur
52a26ff08f Merge pull request #364 from stripe/brandur-deprecate-refund-helpers
Deprecate `#refund` helpers on `Charge` and `ApplicationFee`
2016-01-19 15:46:54 -08:00
Brandur
13cba9f29a Remove deprecations 2016-01-19 15:31:44 -08:00
Brandur
437c2dfa02 Move extend to top of file 2016-01-15 10:37:24 -08:00
Brandur
cd9d2bc71e Also re-implement Charge#refund to use our new endpoint
This was already done for `ApplicationFee`.
2016-01-15 10:36:42 -08:00
Brandur
8a20ab8972 Deprecate #refund helpers on Charge and ApplicationFee
As discussed previously in #354 and alluded to in #363, this patch
deprecates the `#refund` helpers on `Charge` and `ApplicationFee` in
favor of the resource-centric approach (i.e. `charge.refunds.create`).

We do this for a few reasons:

1. The new approach is far preferred and uses our modern endpoints. It's
   also been the mechanism suggested by the documentation for ages now.
2. The old approach is somewhat risky in that a forgotten "s" can lead
   to an accidental refund (i.e. `charge.refund` instead of
   `charge.refunds`).

Follows up #354. Fixes #363.
2016-01-14 18:16:56 -08:00
Brandur
0c14e6ec1f Bump version to 1.32.1 2016-01-07 10:57:46 -07:00
Brandur
6fca0e63d9 Merge pull request #361 from stripe/brandur-init-original-values
Always initialize `original_values` ivar in `StripeObject`
2016-01-07 10:46:32 -07:00
Brandur
4521bfe626 Merge pull request #362 from iloveitaly/bitcoin-refresh-fix
BitcoinReceiver refresh fix
2016-01-06 20:12:26 -07:00
Michael Bianco
2255dd73a8 Adding nil customer value to mock bitcoin receiver hash 2016-01-06 21:47:32 -05:00
Michael Bianco
c259547dd7 Check for nil customer value when determining bitcoin receiver URL
Stripe API responses include `customer: nil`, which causes `refresh`
to throw an exception
2016-01-06 21:45:29 -05:00
Brandur
2564990aa2 Always initialize original_values ivar in StripeObject
This is kind of a weird one because it'll only cause a failure when
serializing a subobject or hash of a `StripeObject`, but it's good
practice to initialize instance variables anyway.

Fixes #360.
2016-01-06 14:40:52 -07:00
Brandur
121a8bfee4 Merge pull request #359 from rthbound/list-object-extends-api-operations
ListObject extends ApiOperations::Create
2016-01-06 09:22:10 -07:00
Ryan T. Hosford
0acf314e30 ListObject extends ApiOperations::Create
- Addresses a bit of duplication.
2016-01-05 22:52:33 -06:00
Brandur
c78b1b8337 Bump version to 1.32.0 2016-01-05 10:19:23 -07:00
Brandur
d5f5efb77d Merge pull request #354 from stripe/brandur-refund-url-correction-2
Update application fee refunds (round 2)
2015-12-03 17:37:36 -08:00
Kyle Conroy
4e01b13efc Merge pull request #353 from nbrustein/retry-network-failures
feat(request): optionally retry network failures
2015-11-23 13:37:38 -08:00
Nate Brustein
a31986fa6e feat(request): optionally retry all requests that fail on a network failure 2015-11-23 14:30:54 -05:00
Brandur
53ff2ef7f4 Add a semi-deprecation comment 2015-11-19 14:23:33 -08:00
Brandur
c7e515ba7b Use refunds.create + maintain backward compatibility 2015-11-19 14:10:33 -08:00
Brandur
bc66a38cd4 Update application fee refunds (round 2)
Follows up the patch in #351, which I now believe is wrong. The trouble
is that we were mutating the application fee object, when in reality an
application fee refund is actually a completely new resource (see
[creating a refund][create-refund]). This patch edits the original
attempt to cut a new object and updates tests accordingly.

Once again, related to stripe/stripe-php#208.

[create-refund]: https://stripe.com/docs/api#create_fee_refund
2015-11-18 12:25:52 -08:00
Brandur
02f68e45e7 Merge pull request #351 from stripe/brandur-refund-url-correction
Correct URL used for refunding application fees
2015-11-16 13:06:26 -08:00
Brandur
c7fd5b6baa Correct URL used for refunding application fees
This uses the new endpoint instead of the deprecated one.

Related to stripe/stripe-php#208.
2015-11-16 11:07:32 -08:00
Brandur
59e7752a00 Merge pull request #349 from stripe/brandur-remove-18-hacks
Remove test hacks introduced to work around Ruby 1.8 limitations
2015-11-04 17:44:54 -08:00
Brandur
03b64a059d Remove test hacks introduced to work around Ruby 1.8 limitations 2015-11-04 16:41:59 -08:00
Kyle Conroy
90c9d8efa2 Merge pull request #348 from stripe/ruby18
No longer support Ruby 1.8.7
2015-11-04 15:52:18 -08:00
Kyle Conroy
7bf660d124 Only support Ruby >= 1.9.3
Update the README, Gemfiles, and gemspec to remove all references to
Rubies < 1.9.3.
2015-11-04 14:52:56 -08:00
Brandur
159335078c For completeness, add a test case with an empty string 2015-11-03 13:38:59 -08:00
Brandur
5769eb7c1e More consistent spacing 2015-11-03 09:31:21 -08:00
Brandur
492b24894d Fix identation 2015-11-02 13:40:39 -08:00
Brandur
3eca0a4be4 Fix spacing between sentences 2015-11-02 13:17:19 -08:00
Brandur
878d753ff1 Bump version to 1.31.0 2015-10-29 12:06:03 -07:00
Brandur
c1c5b56762 Merge pull request #345 from iloveitaly/verify-bank-account
Adding BankAccount#verify
2015-10-29 12:05:45 -07:00
Michael Bianco
7cd161dd03 Tests for BankAccount#verify 2015-10-29 15:01:53 -04:00
Michael Bianco
cdc1165fc5 Adding BankAccount#verify 2015-10-29 13:50:45 -04:00
Brandur
aab350e833 Bump version to 1.30.3 2015-10-28 11:33:02 -07:00
Kyle Conroy
87077c5f19 Merge pull request #344 from stripe/brandur-patch-additional-owners
Special case the serialization of account's `additional_owners`
2015-10-27 16:03:35 -07:00
Brandur
ae4bb64c5a Call serialization of a changed array of hashes undefined for now 2015-10-27 11:53:36 -07:00
Brandur
431ef3b1f2 Special case the serialization of account's additional_owners
We attempt to do a special encoding trick when serializing
`additional_owners` under an account: when updating a value, we actually
send the update parameters up as an integer-indexed hash rather than an
array. So instead of this:

    field[]=item1&field[]=item2&field[]=item3

We send this:

    field[0]=item1&field[1]=item2&field[2]=item3

The trouble is that this had previously been built into the core library
as the default handling for all arrays. Because of this, it was
impossible to resize a non-`additional_owners` array as described in
more detail in #340.

This patch special cases `additional_owners` and brings sane behavior
back to normal arrays along with a test suite so that we try to build
some better guarantees around both the general and non-general cases.
2015-10-27 09:07:41 -07:00
Brandur
1182539ae4 Give code a little breathing room 2015-10-23 16:25:33 -07:00
Brandur
216218aeb0 Order hack to make 1.8.7 tests happy
It turns out that the tests had been working ... but mostly by virtue of
luck only. This should stabilize them more permanently.
2015-10-20 12:15:36 -07:00
Brandur
7dabbd444a Revert "Tweak faulty test logic"
This reverts commit eac89a1af140600904b8e723b20b9755545b6a6e.
2015-10-20 12:15:20 -07:00
Brandur
eac89a1af1 Tweak faulty test logic 2015-10-20 12:11:28 -07:00
Brandur
4ae867f540 Small introductory paragraph and feature list 2015-10-15 12:31:08 -07:00
Brandur
59c21b9d72 Merge pull request #336 from stripe/brandur-add-byebug
Add byebug/pry as a gem development dependency
2015-10-12 12:30:11 -07:00
Brandur
fe8350e3eb Bump version to 1.30.2 2015-10-12 12:19:22 -07:00
Brandur
72162f455d Merge pull request #335 from stripe/brandur-fix-opts
Correct internal usage of `#update_attributes`
2015-10-12 12:18:40 -07:00
Brandur
a084df78ef Add byebug/pry as a gem development dependency
I find myself using these quite a bit when looking into problems, and
currently have to manually re-add them to the Gemfile/gemspec to get
them in the bundle and make them available in tests.

Here we gate the debugger to only come in for Ruby > 2 so as to avoid
problems with various compatibility problems between debuggers and
versions of Ruby. If there's a demand for a pre-Ruby 2 debugger, we can
add that separately.

Any major objections to this one? Thanks.
2015-10-12 12:10:39 -07:00
Brandur
a014d505bc Correct internal usage of #update_attributes
Unfortunately usage of `#update_attributes` had rolled over from a time
where `#update_attributes_with_options` was still in use and `opts` were
being passed in as an optional argument which had the result of further
nesting the hash internally (i.e. `:opts => { :opts => ... } }`).

This patch fixes that problem, adds a regression test to prevent it from
reappearing, and banishes the unused `#update_attributes_with_options`.

Fixes #334.
2015-10-12 12:08:44 -07:00
Brandur
2ea5c9c1a6 Fix spelling mistake in log 2015-10-10 22:08:53 -07:00
Brandur
20512b0ff7 Bump version to 1.30.1 2015-10-10 12:54:44 -07:00
Brandur
452a89c02a Merge pull request #333 from stripe/brandur-remove-sort-hack
Remove sorting hack from parameter encoding
2015-10-10 12:50:07 -07:00
Brandur
77b1972a72 Use alternate testing approach to satisfy 1.8.7 2015-10-10 12:40:17 -07:00
Brandur
ca8b49e5fd Use array as input instead of hash (for 1.8.7 tests) 2015-10-10 12:12:57 -07:00
Brandur
395d16b8c1 Remove sorting hack from parameter encoding
I added this for a regression suite so that 1.8.7 could pass its tests,
but unfortunately this caused a regression in the way that parameters
are encoded for arrays of hashes. This patch reverts the change and adds
tests to detect a future regression.

(And 1.8.7 is expected to fail on this initial commit.)
2015-10-10 12:12:57 -07:00
Brandur
a41691d972 Merge pull request #332 from stripe/brandur-pass-all-filters-to-pages
Pass through all paging filters to descendent pages
2015-10-10 12:10:41 -07:00
Brandur
daf2789ad7 Pass through all paging filters to descendent pages
When additional filters were provided for pagination like an expansion
or a predicate, they would not propagate to any call after the first.
This patch addresses that issue by storing all filters and moving them
to any new page objects being created.

Fixes #331.
2015-10-09 13:58:23 -07:00
Brandur
cdb8599119 Bump version to 1.30.0 2015-10-09 10:45:25 -07:00
Brandur
dc545752f1 Merge pull request #330 from stripe/brandur-stripe-object-deleted
Add `StripeObject#deleted?`
2015-10-09 10:25:48 -07:00
Brandur
900fa4b5dc Add StripeObject#deleted?
Adds a special helper to `StripeObject` that helps a developer to
determine whether or not an object is deleted.

As described originally in #257, this is a bit of a special case because
a non-deleted object does not respond with `deleted` as part of its
representation, so while a deleted object would have this accessor
available automatically, non-deleted objects would not. This made use of
the SDK awkward because the presence of the method was not guaranteed.

Fixes #257 (again, heh).
2015-10-09 10:16:59 -07:00
Brandur
b3912c1712 Merge branch 'brandur-deprecate-refresh-from'
Conflicts:
	lib/stripe/stripe_object.rb
2015-10-08 17:49:27 -07:00
Brandur
d09093fca1 Add some tests just to make sure everything is working as we expect 2015-10-08 17:43:20 -07:00
Brandur
1a96d7cf8e Use Gem:: deprecation method instead of a custom one 2015-10-08 17:24:59 -07:00
Brandur
d8dcf7c6af Merge pull request #329 from stripe/brandur-dial-down-update-attributes-safety
Have StripeObject#update_attributes reflect behavior of accessors
2015-10-08 17:08:09 -07:00
Brandur
925066efd4 Remove outdated option 2015-10-08 14:44:42 -07:00
Brandur
11dd870900 Have StripeObject#update_attributes reflect behavior of accessors
This dials down the safety of `StripeObject`'s `#update_attributes`
method so that it allows properties to be assigned that it doesn't yet
know about. We're doing this for a few reasons:

1. To reflect the current behavior of accessors (i.e. `obj.name = ...`)
   through `method_missing`.
2. To allow `#update_attributes` to assign properties on new projects
   that don't yet know their schema from an API call.

Fixes #324.
2015-10-08 14:04:11 -07:00
Brandur
3468698ce9 Make 1.8 happy 2015-10-08 10:03:18 -07:00
Brandur
8b255c7005 Deprecate StripeObject#refresh_from
As discussed in #325, this deprecates the public visibility of
`#refresh_from` (by renaming it). It also adds some deprecation
infrastructure to produce warnings when it's used.
2015-10-08 09:57:16 -07:00
Brandur
e75fd86ae5 Fix miswording of error message 2015-10-08 07:39:56 -07:00
Brandur
dd22228f43 Merge pull request #323 from stripe/brandur-cgi-escape
Replace deprecated `URI.escape` with a customized `CGI.escape`
2015-10-06 17:53:55 -07:00
Brandur
eb8787754c Replace deprecated URI.escape with a customized CGI.escape
Replaces my original attempt in #319 in a way that doesn't depend on
`URI.encode_www_form` which doesn't exist in 1.8.7. This should
hopefully get us the best of all worlds.

Caveats around use of `+` instead of `%20` as detailed in #319 still
apply.

Fixes #286.
2015-10-06 14:46:58 -07:00
Brandur
0485de9669 Merge pull request #322 from stripe/brandur-add-regression-suite
Add regression suite for testing parameter encoding
2015-10-06 14:44:20 -07:00
Brandur
5853fd47dd Add one more set of tests for #url_encode 2015-10-06 14:38:14 -07:00
Brandur
91262c9042 Sort encoded parameters for stability in 1.8.7 tests 2015-10-06 14:17:51 -07:00
Brandur
a48fd12c70 Add regression suite for testing parameter encoding
Pulls the test suite out of #319 so that we can get some coverage around
parameter encoding. This should prevent any recurrence of #318.

Also includes a little bit of refactoring.
2015-10-06 14:04:02 -07:00
Brandur
b7d714b58e Bump version to 1.29.1 2015-10-06 13:40:13 -07:00
Kyle Conroy
2f09c74c01 Merge pull request #321 from stripe/revert-299-brandur-uri-escape
Revert removal of `URI.escape`
2015-10-06 13:37:35 -07:00
Brandur
d38250d717 Revert "Remove use of deprecated URI.escape" 2015-10-06 13:30:39 -07:00
Brandur
a2b56178fe Bump version to 1.29.0 2015-10-05 12:56:44 -07:00
Brandur
d92983c22a Merge pull request #317 from stripe/brandur-extend-create
Extend Stripe::APIOperations::Create instead of including
2015-10-05 12:43:26 -07:00
Brandur
aa7e559115 Extend Stripe::APIOperations::Create instead of including
Lets not be too shy about just using `extend` instead of `include` here
when it's more appropriate to do so. The advantage to this approach is
that the module can be either extended _or_ included with this change,
but couldn't be without it due to the `ClassMethods` meta-magic.

List has already started doing this as of #314, so we don't have to be
afraid of breaking convention here.
2015-10-05 12:24:53 -07:00
Brandur
e2692e9805 Merge pull request #314 from stripe/brandur-pagination
Pagination
2015-10-05 12:23:01 -07:00
Brandur
42ea34b969 Pagination
Usage on a top-level collection:

```
Stripe::Customer.list.auto_paging_each do |customer|
  puts customer
end
```

Usage on a subcollection:

``` ruby
customer.invoices.auto_paging_each do |invoice|
  puts invoice
end
```

We've also renamed `#all` to `#list` to prevent confusion ("all" implies
that all resources are being returned, and in Stripe's paginated API
this was not the case). An alias has been provided for backward API
compatibility.

Fixes #167.

Replaces #211 and #248.
2015-10-05 12:15:09 -07:00
Brandur
60b7617624 Bump version to 1.28.1 2015-10-05 11:45:37 -07:00
Kyle Conroy
8287904c00 Merge pull request #316 from stripe/apt-file-uploads-retrieve-url
Use correct URL for file upload retrieval
2015-10-05 11:36:30 -07:00
Brandur
84f3bd8f17 Bump version to 1.28.0 2015-10-05 11:00:34 -07:00
Jieren Chen
7d28eaab64 Merge pull request #310 from stripe/drj/t5176-legal-entity-override
Disallow directly overriding legal_entity
2015-10-02 12:12:09 -07:00
Brandur
90c6eeb398 Merge pull request #311 from stripe/brandur-mass-assign
Add attribute mass assignment and use it in #save
2015-10-02 09:29:55 -07:00
Andrew Thorp
841a34385a Use correct URL for file upload retrieval 2015-10-01 17:36:51 -07:00
Brandur
b57cd5aca4 Support Ruby 1.8.7 2015-10-01 16:59:56 -07:00
Brandur
71a44f70f5 Move internal method to protected 2015-10-01 16:28:21 -07:00
Jieren Chen
387edb5163 PR Fix: rename to protected_fields 2015-10-01 16:26:30 -07:00
Brandur
e23b57628f Add attribute mass assignment and use it in #save
As detailed in issue #119, we've somewhat unfortunately been allowing
object attributes to be passed in during a #save because we mix any
arguments directly into the serialized hash (it seems that this was
originally intended to be used more for meta parameters that go to the
request).

As also noted in #119, this use causes problems when certain types of
parameters (like subobjects) are used. We're now left in the somewhat
awkward position of either:

1. Removing this functionality on #save and breaking what may be
   behavior that people depend on.
2. Fully support this mass assignment.

This patch takes the second path by extracting a new #update_attributes
method and using it from #save. It's still far from a perfect approach
because keys that have the same name as certain options (e.g. `req_url`)
are not going to work, but it should capture the behavior that most
people want.

Fixes #119.
2015-10-01 16:21:34 -07:00
Jieren Chen
e451e3d3e2 Fix test 2015-10-01 13:51:55 -07:00
Jieren Chen
797478786d Disallow directly overriding legal_entity 2015-10-01 13:39:11 -07:00
Brandur
df2e36287d Merge pull request #309 from stripe/brandur-boolean-accessors
Add question mark helpers (e.g. #paid?) for boolean object values
2015-09-30 14:36:23 -07:00
Brandur
a88b062beb Merge pull request #300 from stripe/brandur-upsert
Create if #save is called on a new object
2015-09-30 13:54:20 -07:00
Brandur
c301c6c0f6 Add question mark helpers (e.g. #paid?) for boolean object values
This patch adds question marks helpers (e.g. #paid?) for any values in a
StripeObject that are a boolean. This is fairly idiomatic Ruby in that
it behaves similarly to other libraries like ActiveRecord.

Note that a caveat here is that nullable booleans will not get a helper
added for them if their current value is null. For this reason, we
should eventually prefer to derive these methods from some sort of
programmatic API manifest.

Replaces #257 and #274.
2015-09-30 13:48:59 -07:00
Brandur
a6a2664746 Merge pull request #303 from stripe/brandur-no-email-notifications
Don't give build notifications via e-mail
2015-09-30 13:28:31 -07:00
Brandur
180a7d849d Merge pull request #308 from stripe/brandur-list-empty
Add #empty? helper on ListObject
2015-09-30 13:22:13 -07:00
Brandur
1ae6ab48a6 Do not notify on successful builds 2015-09-30 13:17:11 -07:00
Brandur
af72a57c9d Add #empty? helper on ListObject
This makes ListObject behave a little more like an Array in that it gets
an #empty? helper. This should fit pretty well with the Enumerable
methods that it already has.

Replaces #193.
2015-09-30 13:13:41 -07:00
Brandur
9aa13697f7 Merge pull request #302 from stripe/franklin-normalize-opts
StripeObject: use Util.normalize_opts
2015-09-30 13:05:03 -07:00
Brandur
34ae473d6e Merge pull request #304 from stripe/brandur-enumerable-list-object
Mix `Enumerable` into `ListObject`
2015-09-30 12:59:14 -07:00
Brandur
cb677635e3 Merge pull request #306 from stripe/brandur-testing-information
Add information on running individual test suites and individual tests
2015-09-30 12:55:45 -07:00
Brandur
509c6c13a3 Merge pull request #307 from stripe/brandur-fix-invoices
Fix fixture data for invoices (and specifically invoice items)
2015-09-30 12:07:36 -07:00
Brandur
add851006d Fix fixture data for invoices (and specifically invoice items)
Fixes #228.
2015-09-30 12:02:53 -07:00
Brandur
c304cee8c2 Add information on running individual test suites and individual tests
Granular running of tests is one of Minitest's many gotchas. This
change adds some more information on how to run individual test suites
and individual tests which is useful when debugging.
2015-09-30 11:52:19 -07:00
Brandur
8c7a976ffb Space this method out a little bit 2015-09-30 11:28:05 -07:00
Brandur
5515824fe2 Mix Enumerable into ListObject
This pulls the `Enumerable` mixin into `ListObject`. There is some
question in pulls like #167 as to the future of `ListObject` and how it
might change when pagination is introduced, but because we're unlikely
to make any backward incompatible changes to the API, it's likely that
`ListObject` will continue to represent a page of data that's been
extracted from the API. Given that assumption, pulling `Enumerable` in
should be relatively safe.

Fixes #227.
2015-09-29 22:26:00 -07:00
Brandur
e0354b70f7 Add RDoc for #save 2015-09-29 22:10:51 -07:00
Brandur
0813a1fd45 Don't give build notifications via e-mail
I personally find that just looking at the red/green status of any given
pull request is enough information on the status of current builds.
2015-09-29 21:58:22 -07:00
Brandur
f308bb3a52 Merge pull request #301 from stripe/brandur-symbolize-names
Perform deep name symbolization from .construct_from
2015-09-29 19:02:16 -07:00
Brandur
f31eaa6b1e Perform deep name symbolization from .construct_from
When constructing an object using .construct_from treat keys that are
strings the same as keys which are symbols by calling Util's
symbolize_names on an input hash. This makes guarantees around
consistency a little better.

Fixes #151.
2015-09-29 17:52:16 -07:00
Brandur
6f9fa3b640 Merge pull request #299 from stripe/brandur-uri-escape
Remove use of deprecated `URI.escape`
2015-09-29 17:40:54 -07:00
Brandur
ac7d050ecf Create if #save is called on a new object
Modifies the behavior of an update so that it can create an object if it
was new. This allows an "upsert"-like functionality where the SDK will
tend to do the right/expected thing.

This is a tad janky in that it checks for the existence of a class-level
`.create` method which is expected to come from a different module, but
most modules in the project are already fairly deeply intertwined and
co-dependent.

Fixes #165.
2015-09-29 17:39:43 -07:00
Brandur
0db40e43fc Remove use of deprecated URI.escape
But we still want to percent-encode entities like spaces, so instead of
using `CGI.escape` we use a utility from WEBrick.

Fixes #286.
2015-09-29 16:33:20 -07:00
Brandur
fef7f8c641 Add a make_account to test data + charge_enabled -> charges_enabled 2015-09-29 15:46:43 -07:00
Brandur
cf67312ba5 Add tags to .gitignore 2015-09-29 15:46:27 -07:00
Franklin Hu
844169a744 StripeObject: use Util.normalize_opts
For object initialization and refresh_from, call `normalize_opts` so
`@opts` is in an expected form.
2015-09-29 14:22:11 -07:00
Brandur
30688422c4 Merge pull request #251 from godfat/to_hash-with-array
to_hash should also walk into arrays to make recursive call.
2015-09-28 15:31:54 -07:00
Brandur
2a22605618 Bump version to 1.27.2 2015-09-25 14:25:38 -07:00
Brandur
e37711e947 Merge pull request #297 from stripe/brandur-fix-bitcoin-transactions
Correct list + retrieval of Bitcoin transactions
2015-09-23 12:10:17 -07:00
Brandur
be8108143b Assert on entire test URL for a slightly better guarantee 2015-09-23 12:04:12 -07:00
Brandur
1a49af7f94 Correct list + retrieval of Bitcoin transactions
Corrects the paths at which the client looks for Bitcoin transactions
and adds a small test suite to check these results.

Fixes stripe/stripe-ruby#236.
2015-09-22 18:23:57 -07:00
Rasmus Rygaard
14d98a7710 Merge pull request #296 from stripe/rasmus-update_version
Bump version to 1.27.1
2015-09-21 09:12:21 -07:00
Rasmus Rygaard
accb624b35 Bump version to 1.27.1 2015-09-20 10:25:59 -07:00
Rasmus Rygaard
db794d6be7 Merge pull request #294 from stripe/rasmus-fix_product_hash_rocket
Fix hash literal for backwards compatibility.
2015-09-20 10:20:17 -07:00
Rasmus Rygaard
333613fca2 Fix hash literal for compatibility. 2015-09-19 17:10:54 -07:00
Russell Davis
7a0ead3fac Merge pull request #291 from stripe/handle-non-hash-error-responses
Handle error responses that are not hashes more gracefully
2015-09-14 21:34:37 -07:00
Rasmus Rygaard
721071d224 Bump version to 1.27.0 2015-09-14 16:42:14 -07:00
Rasmus Rygaard
51b0bff8e9 Merge pull request #292 from stripe/rasmus-orders_bindings
Add Relay bindings
2015-09-14 16:36:37 -07:00
Russell Davis
70ae271c9e Handle error responses that are not hashes more gracefully 2015-09-14 15:13:30 -07:00
Rasmus Rygaard
6e14ca9b2a Add SKU metadata tests. 2015-09-13 21:12:48 -07:00
Rasmus Rygaard
747dac6ea0 Add Orders. 2015-09-13 20:43:36 -07:00
Rasmus Rygaard
2c08524396 Remove #skus, simplify nested object check. 2015-09-13 18:21:02 -07:00
Rasmus Rygaard
690fd18cb3 Add SKUs, Products 2015-09-13 18:10:47 -07:00
Kyle Conroy
f56c486fa1 Bump version to 1.26.0 2015-09-11 15:12:43 -07:00
Jacqueline
e09dab7d2e Merge pull request #289 from stripe/jacqueline-429-error
add 429 rate limit error
2015-09-10 15:56:31 -07:00
Jacqueline Xu
a705799a2c add 429 rate limit error 2015-09-10 15:31:51 -07:00
Russell Davis
9a90321e9b Merge pull request #288 from tanguyantoine/master
Allow params when retrieving customer objects
2015-09-08 14:35:56 -07:00
Tanguy Antoine
467109d588 Allow params when retrieve customer objects
* Permit easy pagination for example
* ruby 2 syntax for hash
2015-09-08 23:29:40 +02:00
Kyle Conroy
5e3474c70c Bump version to 1.25.0 2015-08-17 16:40:48 -07:00
Kyle Conroy
81a88eced4 Merge pull request #282 from stripe/refunds
Add retrieve and all methods to refunds
2015-08-17 16:38:11 -07:00
Kyle Conroy
13979ce5be Add retrieve and all methods to refunds 2015-08-17 16:15:34 -07:00
Kyle Conroy
ea3a790669 Bump version to 1.24.0 2015-08-03 13:40:14 -07:00
Russell Davis
dc8cbe5bdd Merge pull request #278 from HashNuke/266-return-token-object-on-token-create
Fix #266: Add Token to object classes map
2015-08-03 13:05:10 -07:00
Akash Manohar J
21c7061b5e Fix #266: Add Token to object classes map 2015-08-04 01:26:23 +05:30
Caitlin
eb75ccd7fa Merge pull request #269 from stripe/disputes
Add top level dispute methods.
2015-08-03 11:32:37 -07:00
shalecraig
8ce205c7e2 Merge pull request #275 from stripe/shale/account-delete
Added the ability to delete an account
2015-07-28 17:19:21 -07:00
Shale Craig
af66e5ea35 Added the ability to delete an account 2015-07-28 16:16:01 -07:00
Russell Davis
4c0006f130 Merge pull request #230 from OutlawAndy/master
fix #223 support expansions when retrieving via ListObject
2015-07-27 15:56:09 -07:00
Andy Cohen
2d28ab642d add api_resource_test for ListObject expand support 2015-07-27 17:40:58 -05:00
Andy Cohen
97c9249ab1 extract method 'normalize_id' from 'StripeObject#initialize' & 'ListObject#retrieve' 2015-07-27 15:47:16 -05:00
Andy Cohen
31ccf7c6d3 fix #223 support expansions when retrieving via ListObject 2015-07-27 15:45:45 -05:00
Andy Cohen
54efdf5405 extract method 'normalize_id' from 'StripeObject#initialize' & 'ListObject#retrieve' 2015-07-27 15:24:15 -05:00
Russell Davis
bae4fc2fdf Merge pull request #267 from andyt/add_configurable_timeouts
Add configurable timeouts. [#265]
2015-07-27 13:20:45 -07:00
Russell Davis
d6dc78d5ce Merge pull request #258 from theicfire/chase-array-params-bug
Requests with arrays of dictionaries now properly work
2015-07-23 15:12:18 -07:00
Chase Lambert
801dd99318 Get requests with arrays of dictionaries to work 2015-07-23 15:03:48 -07:00
Kyle Conroy
34010d7a99 Add evidence tests 2015-07-17 17:20:08 -07:00
Caitlin Johnson
a37912f122 Add top level dispute methods. 2015-07-16 14:19:41 -07:00
Andy Triggs
6be76b9754 Add configurable timeouts. [#265] 2015-07-15 16:57:58 +01:00
Russell Davis
8c6dc1a838 Remove gemnasium dependencies status badge
Looks like it's meant for Ruby apps, not gems. It shows the dependency info
from the gemfile rather than the gemspec, which is misleading.

cc @bkrausz @kyleconroy
2015-07-08 17:15:53 -07:00
Caitlin Johnson
43870a4601 Bump version to 1.23.0 2015-07-06 17:03:01 -07:00
Kyle Conroy
8b0a074cbf Merge pull request #262 from stripe/request-ids
Add request IDs to all API errors
2015-07-02 14:33:12 -07:00
Kyle Conroy
053c44f35c Add request IDs and HTTP headers to errors
The request ID, if it exists, is now added to the output for the error
2015-07-02 13:54:02 -07:00
Kyle Conroy
c18f237da4 Merge pull request #263 from stripe/data-rename
Rename test data methods
2015-07-02 13:51:49 -07:00
Kyle Conroy
b3610798c2 Rename test data methods 2015-07-02 11:51:38 -07:00
Kyle Conroy
d072cc79fe Create API error from response instead of body and code 2015-07-02 09:54:23 -07:00
Brian Krausz
37d1a0b8bf Bump version to 1.22.0 2015-06-10 18:04:02 -07:00
Brian Krausz
3106255495 Merge pull request #254 from stripe/bank_accounts
Add support for account bank accounts
2015-06-10 17:26:18 -07:00
Brian Krausz
a86bd06484 Rename fake tok ID 2015-06-10 17:26:11 -07:00
Brian Krausz
5883e421c1 Add support for account bank accounts 2015-06-06 12:52:34 -07:00
Lin Jen-Shin
abbe72f5ff to_hash should also walk into arrays to make recursive call. 2015-05-21 02:00:34 +08:00
Russell Davis
8ba1a0e490 Merge pull request #247 from jkogara/update_readme
Update README with link to docs
2015-05-06 10:52:05 -07:00
John O'Gara
792b2b6957 Update README with link to docs 2015-05-06 09:27:40 +01:00
Andy Brody
97b3f397fc Merge pull request #240 from stripe/ab-jruby
Run tests on jruby in 1.9 mode.
2015-04-23 17:35:41 -07:00
Andy Brody
867acd4560 Don't test yajl.gemfile on jruby. 2015-04-23 17:04:22 -07:00
Russell Davis
fd9e8dd313 Merge pull request #226 from dylanjha/master
Fix incorrect error message- Stripe::Card.retrieve
2015-04-23 14:14:04 -07:00
Andy Brody
782a596c8f Fix error when SSL verification is disabled.
Fixes #242
2015-04-15 16:43:58 -07:00
Andy Brody
4c9ecb245b Actually bump version to 1.21.0 2015-04-14 15:06:50 -07:00
Andy Brody
32d5d3c7d9 Run tests on jruby in 1.9 mode. 2015-04-14 15:01:22 -07:00
Andy Brody
05069050db Version 1.21 2015-04-14 14:59:44 -07:00
Andy Brody
af7efeff98 Remove unnecessary dependency on mime-types.
Let rest-client depend on mime-types directly.
2015-04-14 14:49:27 -07:00
Andy Brody
960fd2b422 Merge pull request #238 from stripe/ab-uname
Revamp uname calls
2015-04-13 18:17:32 -07:00
Andy Brody
3d9b9464ad Add comments for ENOMEM. 2015-04-13 17:21:15 -07:00
Brian Krausz
e0981eb77a Merge pull request #239 from dhiemstra/customer_source_fix
Dont unset keys when they dont exist
2015-04-12 11:51:17 -07:00
Danny Hiemstra
573f5702d7 Dont unset keys when they dont exist 2015-04-11 12:39:45 +02:00
Andy Brody
743c4e3ee1 Also handle uname on jruby, windows, bsd.
And add RUBY_ENGINE to the reported information if it exists.
2015-04-09 18:21:53 -07:00
Andy Brody
d046a876f9 Prefer reading /proc/version over calling uname.
This will be way faster on linux systems than shelling out to uname.
Also add hostname from Socket.gethostname since that information is
provided by `uname -a` but not /proc/version.
2015-04-09 18:19:59 -07:00
Andy Brody
cee76d05ca Merge pull request #237 from stripe/ssl-blacklist-remove
Remove SSL certificate blacklist checks.
2015-04-09 16:49:08 -07:00
Andy Brody
ede362588c Remove SSL certificate blacklist checks. 2015-04-09 16:10:32 -07:00
Russell Davis
a980110740 Bump version to 1.20.4 2015-03-26 17:40:06 -07:00
Russell Davis
bc3f514c5c Merge pull request #221 from bobjflong/BL/nilkey2
Safer argument parsing
2015-03-25 15:38:59 -07:00
Bob Long
c269e9bd9b Safer argument parsing (attempt 2) 2015-03-25 15:15:02 +00:00
Andy Cohen
2f9f5d5036 fix #223 support expansions when retrieving via ListObject 2015-03-24 20:20:20 -05:00
Russell Davis
08b7aa6358 Merge pull request #229 from stripe/add-account-test
Add a test for retrieving accounts using an API key as the only param
2015-03-24 17:00:57 -07:00
Russell Davis
52fc50797f Add a test for retrieving accounts using an API key as the only param 2015-03-24 16:48:22 -07:00
Dylan Jhaveri
16dd5856c4 Fix incorrect error message- Stripe::Card.retrieve
* This error message said "Cards cannot be retrieved without a customer
ID. Retrieve a card using customer.cards.retrieve('card_id')"

This is incorrect. `customer.cards` throws a `NoMethodError: undefined
method `cards' for #<Stripe::Customer:0x0000010c8bdca8>`.

* The correct method is `Stripe::Customer#sources`, and this fixes the
error message.
2015-03-18 01:20:21 -07:00
Brian Krausz
403e92fc88 Bump to version 1.20.3 2015-03-13 10:35:23 -07:00
Brian Krausz
37494242f5 Don't recurse into APIResources when updating
Fixes #224

CC @russelldavis
2015-03-13 10:31:55 -07:00
Brian Krausz
9b92e86ef2 Bump version to 1.20.2 2015-03-10 12:30:06 -07:00
Brian Krausz
0df1c9b176 Fix updates on objs with arrays of strings 2015-03-09 12:08:59 -07:00
Brian Krausz
6976393e9e Fix singleton retrieval
Minor fix so just pushing to master

Fixes #214

CC @russelldavis
2015-03-05 12:27:45 -08:00
Brian Krausz
33e20efb35 Merge pull request #217 from stripe/bk-hashes
Fix updating for nested hashes
2015-03-05 12:09:25 -08:00
Brian Krausz
f8d5687040 Fixes as requested 2015-03-05 00:07:13 -08:00
Brian Krausz
a47a754795 Support arrays & add more nested tests 2015-03-03 14:25:10 -08:00
Brian Krausz
03abd88f0c Fix updating for nested hashes 2015-03-02 18:29:59 -08:00
Max Lahey
1bcaa10abd version bump to 1.20.1 2015-02-26 17:47:46 -08:00
Max Lahey
368d6806a8 Merge pull request #216 from stripe/card-to-sources-endpoint
card management should use the sources endpoint
2015-02-26 17:44:27 -08:00
Max Lahey
d1a50a8918 customer card management should use the customer sources endpoint 2015-02-26 17:32:33 -08:00
Russell Davis
2df5817192 Merge pull request #213 from stripe/deprecate-code-dot-stripe-dot-com
Deprecate code.stripe.com
2015-02-19 17:28:13 -08:00
Russell Davis
d945c2f157 Deprecate code.stripe.com 2015-02-19 17:09:42 -08:00
Max Lahey
c1d5c94864 version bump to 1.20.0
added structure to support for unified customer sources api
2015-02-19 17:01:39 -08:00
Brian Krausz
f76b5c7889 Bump version to 1.19.1 2015-02-18 12:42:36 -08:00
Brian Krausz
cedc3bbad5 Fix test 2015-02-18 12:27:47 -08:00
Brian Krausz
9a82f7d1ba Fix invoice paying/fetching upcoming
Fixes #209
2015-02-18 12:24:11 -08:00
Brian Krausz
a85e2277d6 Bump version to 1.19.0 2015-02-15 23:24:31 -08:00
Brian Krausz
98e7a5ad62 Merge pull request #205 from stripe/bk-accounts
Add backwards compat for Accounts & Transfer Reversals
2015-02-15 21:09:48 -08:00
Brian Krausz
8dab401efe Test naming fix 2015-02-15 21:09:34 -08:00
Brian Krausz
9659b403c9 Fix object expansion
Fixes #206
2015-02-15 20:34:16 -08:00
Brian Krausz
40405669e2 Comment for clarity 2015-02-13 11:40:46 -08:00
Brian Krausz
d1bceb0041 Support transfer reversals 2015-02-12 22:24:09 -08:00
Brian Krausz
581e6348cc Support old signature in Account.retrieve 2015-02-12 20:06:03 -08:00
Brian Krausz
1ee098bd2e Merge pull request #203 from stripe/bk-accounts
Support persisted use of Stripe-Account header everywhere
2015-02-11 14:45:48 -08:00
Brian Krausz
3cbc60f35c Rename @@opts_to_persist 2015-02-11 12:31:57 -08:00
Brian Krausz
592e503c85 Merge pull request #204 from pineconellc/bk-accounts
Add Account to business object mapping
2015-02-11 12:26:22 -08:00
Jeff Browning
aeb99cb0d2 Add Account to business objects 2015-02-11 11:14:26 -05:00
Brian Krausz
ff5be97ada TIL Hash#select is different in 1.8 2015-02-10 11:25:24 -08:00
Brian Krausz
b819e5de37 Remove unnecessary error & more 1.8 fixing 2015-02-09 23:59:13 -08:00
Brian Krausz
bf18ae9376 Fix use of 1.9-style hashes 2015-02-09 23:42:23 -08:00
Brian Krausz
4d611c62f7 Support persisted use of Stripe-Account header everywhere
Including implicit use in /v1/accounts/ endpoints
2015-02-09 23:38:34 -08:00
Russell Davis
085ad6cfb3 Merge pull request #201 from akshaymohite/master
Using backslash instead of string concatenation for separating multi-line messages
2015-01-24 10:25:39 -08:00
Akshay
b9db97c6b9 Using backslash instead of string concatenation for separating multi-line messages 2015-01-24 23:17:46 +05:30
Max Lahey
583f025c1f 1.18.0 release: Support making bitcoin charges through BitcoinReceiver source object 2015-01-21 19:29:23 -08:00
Max Lahey
9f175e070f added BitcoinTransaction 2015-01-20 11:58:43 -08:00
Max Lahey
0e9a88f796 Wired up support for BitcoinReceiver 2015-01-20 11:58:41 -08:00
Russell Davis
7087e38bb9 Merge pull request #200 from yatish27/master
Removes unnecessary semi colon
2015-01-13 11:23:16 -08:00
Yatish Mehta
45bb015adc Removes unnecessary semi colon 2015-01-13 13:55:12 -05:00
Russell Davis
0d04c080ae Merge pull request #199 from yatish27/master
Adds Ruby 2.2 in travis.yml
2015-01-13 08:38:00 -08:00
Yatish Mehta
a2d3ab59c0 Adds 2.2 in travis.yml 2015-01-13 10:17:48 -05:00
John J. Wang
0db3fc1f7a Merge pull request #198 from stripe/wangjohn-file-upload-list
Adding support for listing file uploads.
2015-01-12 20:09:05 -05:00
wangjohn
ad26262a2c Adding support for listing file uploads. 2015-01-12 12:44:46 -08:00
Russell Davis
dd71f80021 Bump version to 1.17.3 2015-01-12 12:24:47 -08:00
Russell Davis
b080e9a7d1 Merge pull request #197 from anark/master
Pass along api_key when refunding fees
2015-01-10 11:50:14 -08:00
Andrew Narkewicz
001679e809 Pass along api_key when refunding fees 2015-01-10 08:40:56 -08:00
Kyle Conroy
23aa1c8c7d Bump version to 1.17.2 2015-01-08 10:47:29 -08:00
Kyle Conroy
a580e4f751 Merge pull request #195 from stripe/delete-api-key
Pass along API key
2015-01-08 10:39:47 -08:00
Kyle Conroy
43d591a93e Pass along API key 2015-01-08 10:32:57 -08:00
wangjohn
8be1ad0e48 Minor version bump. 2015-01-07 11:21:55 -08:00
Russell Davis
b06d62a8af Merge pull request #191 from anark/master
Added deauthorize method to Account
2015-01-06 14:41:39 -08:00
Russell Davis
accbb8cf4c Merge pull request #192 from stripe/fix-dependencies-for-ruby-187
Force an older version of the i18n gem for Ruby < 1.9.3
2015-01-05 18:24:47 -08:00
Russell Davis
317634ede7 Force an older version of the i18n gem for Ruby < 1.9.3
This should fix the travis build for 1.8.7 and 1.9.2.
2014-12-26 14:45:25 -08:00
Andrew Narkewicz
8f93cd5fac Added deauthorize method to account for deauthorizing from stripe connect application 2014-12-26 09:10:23 -07:00
John J. Wang
9a34961748 Merge pull request #181 from stripe/wangjohn-file-uploads
File uploads
2014-12-22 21:15:29 -05:00
wangjohn
ef249b7ceb Create the file upload api resource (+ bump version) 2014-12-22 18:04:53 -08:00
wangjohn
62e110a33e Bumping version to 1.16.1 2014-12-19 18:03:44 -08:00
John J. Wang
8e311b716f Merge pull request #188 from stripe/wangjohn-stripe-account-header
Include stripe account parameter for setting header.
2014-12-19 21:01:00 -05:00
wangjohn
6990bbd798 Include stripe account parameter for setting header. 2014-12-19 11:27:12 -08:00
Kyle Conroy
67da7aa9a7 Merge pull request #187 from stripe/idempotency
Replace the `api_key` argument with a hash of options
2014-12-18 16:09:40 -08:00
Kyle Conroy
e3a68bb3b9 Replace api_key with an options hash
For now, only two options are supported: `api_key` and
`idempotency_key`. In the future, we'll be adding support for additional
headers as needed.
2014-12-17 23:23:46 -08:00
shalecraig
9407c932af Merge pull request #184 from stripe/shale/more-per-request-headers
More per request headers
2014-12-16 18:24:10 -08:00
Shale Craig
7c6c8269c6 Add ability to specify custom headers for list_object.create 2014-12-16 15:46:08 -08:00
Shale Craig
fd104697f3 Add ability to specify custom headers for application_fee.refund 2014-12-16 15:44:57 -08:00
Shale Craig
4bef41192a Add the ability to use an api_key for application_fee.refund 2014-12-16 15:43:16 -08:00
Kyle Conroy
100c522a32 Merge pull request #183 from stripe/per-request-headers
Add per-request headers
2014-12-15 16:56:58 -08:00
Kyle Conroy
bfaaae9336 Add per-request headers 2014-12-15 16:11:45 -08:00
Kyle Conroy
f0c698163e Merge pull request #182 from joshk/patch-1
Use the new build env on Travis
2014-12-15 14:27:44 -08:00
Josh Kalderimis
d309437bd0 Use the new build env on Travis
more capacity, more ram, more cpu, more wow
2014-12-15 20:21:53 +01:00
Michael Manapat
34a86a241b Merge pull request #180 from stripe/mlm-add-fraud-reporting-methods
Add fraud reporting methods
2014-12-14 12:37:56 -08:00
Michael Manapat
f3c0766a0d Add fraud reporting methods 2014-12-11 20:33:50 -08:00
Russell Davis
9c7ebd21c9 Merge pull request #168 from harlow/hw-ruby-19-hash
Consistently use symbols for hash keys
2014-11-14 16:09:48 -08:00
Harlow Ward
1d97c81d8b Consistently use symbols for hash keys
* Updated keys to symbols to match the rest of the test helper
2014-11-14 15:45:25 -08:00
Russell Davis
99cb861dbd Merge pull request #172 from westonplatter/rename-internal-var
rename internal variable. rename `new` to `new_hash` so it's not a keyword
2014-11-14 14:31:20 -08:00
Russell Davis
5c4fa57f09 Merge pull request #170 from westonplatter/formatting
Formatting. Just a few suggestions on code format.
2014-11-14 14:30:03 -08:00
Russell Davis
d6e2dae298 Change Helpers to Stripe::TestData 2014-11-14 14:10:45 -08:00
Russell Davis
3e1e4ea240 Merge pull request #169 from harlow/hw-extract-helpers
Extract response helpers to module
2014-11-14 13:57:08 -08:00
Harlow Ward
cdfbfee06c Extract response helpers to module
Allow developers to use Stripe test data when stubbing responses
locally. This should help mitigate the risk of API drift with stubbed
responses.

* Move response helpers to their own file
2014-11-13 23:19:46 -08:00
Weston Platter
c060ce63f0 rename internal variable. rename new to new_hash so it's not a Ruby keyword 2014-11-02 21:17:08 -07:00
Weston Platter
7810d888c1 formatting. alphabetize key-values by keys and add comments. 2014-11-02 20:29:13 -07:00
Weston Platter
30b0e4156a formatting. remove () from methods that don't have arguments 2014-11-02 20:28:43 -07:00
Russell Davis
7aee297980 Merge pull request #157 from timcraft/return-self
Return self from Stripe::StripeObject#refresh_from
2014-10-30 16:44:21 -07:00
Russell Davis
da216fd53b Add instructions for use with Ruby versions < 1.9.2 2014-10-09 16:02:03 -07:00
Michelle Bu
e751a48bce Merge pull request #153 from stripe/update-coupon
Add coupon update
2014-10-09 13:07:00 -07:00
Greg Sabo
ed873459b7 Bump version to 1.16.0 2014-10-08 14:17:09 -07:00
Tim Craft
0fc6ee5e5b Return self from Stripe::StripeObject#refresh_from 2014-08-22 19:43:13 +01:00
Greg Sabo
2c6f4caa99 Merge pull request #156 from stripe/make_coupons_updateable
Make coupons update-able.
2014-08-20 13:32:52 -04:00
Greg Sabo
a596138526 Make coupons update-able. 2014-08-19 16:24:44 -07:00
Russell Davis
afd42ecd41 Merge pull request #155 from stripe/fix-connection-error-message
Better error message for ServerBrokeConnection exception
2014-08-18 16:05:36 -07:00
Russell Davis
f7467728d7 Better error message for ServerBrokeConnection exception 2014-08-18 15:05:16 -07:00
Russell Davis
5ec4c3f68f Fix error in new versions of bundler from using frozen version string 2014-08-18 14:56:38 -07:00
Kyle Conroy
8d066ca608 Add coupon update 2014-08-06 16:10:18 -07:00
Cosmin Nicolaescu
4aed61af42 v1.15.0 2014-07-29 20:13:56 -07:00
Cosmin Nicolaescu
1d5da7f9ae Merge pull request #150 from stripe/cos-appfee-refund
make ApplicationFee.refunds a list object instead of array
2014-07-29 09:51:48 -07:00
Cosmin Nicolaescu
d3dfa18990 make ApplicationFee.refunds a list object instead of array 2014-07-28 23:28:24 -07:00
Andy Brody
9cf5089dc1 Revert "Change rest-client pin to ruby < 1.9.2."
This reverts commit 39a196541f857ac6266b7a06f589ead21c87a8aa.

Just kidding. Activesupport itself depends on ruby >= 1.9.3.
2014-07-15 13:42:48 -07:00
Andy Brody
39a196541f Change rest-client pin to ruby < 1.9.2.
The latest rest-client supports rubies >= 1.9.2
2014-07-15 13:06:04 -07:00
Russell Davis
8b604f630b Merge pull request #143 from ngauthier/update-mime-types
update mime-types requirement to allow 1.x and 2.x
2014-07-14 13:33:46 -07:00
Russell Davis
1d49b4cc41 Merge pull request #145 from stripe/fix-gemfiles
Fix gemfiles for use with Ruby  < 1.9.3
2014-07-14 10:58:16 -07:00
Russell Davis
3c76c9f150 Fix gemfiles for use with Ruby < 1.9.3
Any project using this gem (with Ruby < 1.9.3) will need to do the same
in its own gemfile.
2014-07-13 13:44:36 -07:00
Russell Davis
ca0d2e603d Merge pull request #144 from stripe/better-rakefile
Run tests using TestTask
2014-07-11 16:19:31 -07:00
Russell Davis
2827ad15d6 Run tests using TestTask
- Runs all tests at once instead of one at a time, this way we don't pay
the cost of constantly reloading the environment. Takes test time from 20
seconds to 4.

- Removes the separate testing using activesupport/all, which wasn't actually
doing anything since the tests were running in a separate process.

Thanks to @JoshCheek for surfacing these issues.
2014-07-11 14:54:21 -07:00
Amber Feng
8bb6acfca9 Merge pull request #122 from mcolyer/fix-psych-deserialization
Check for `@values` in StripeObject#method_not_found.

This is necessary because we check for `@values` in `respond_to_missing?` now, but this isn't necessarily always set. For example, in deserializing from YAML, Psych creates the object using `allocate` and not `new`, which ends up skipping any initializing of instance variables. See #122 for more details.
2014-07-08 21:52:05 -07:00
Nick Gauthier
660befd6c3 update mime-types requirement to allow 1.x and 2.x 2014-07-08 09:41:00 -04:00
Amber Feng
52792264ef Merge pull request #118 from vandrijevik/nested-to-hash
Improved StripeObject#to_hash
2014-07-07 21:23:00 -07:00
Vladimir Andrijevik
238e071232 Merge remote-tracking branch 'stripe/master' into nested-to-hash 2014-06-30 12:45:40 +02:00
Kyle Conroy
bb9388384f Bump to version 1.14.0 2014-06-17 17:35:47 -07:00
Kyle Conroy
a2efbfa094 Merge pull request #140 from stripe/kjc-add-refund
Add support for refund resource
2014-06-17 16:57:02 -07:00
Kyle Conroy
e59a494215 Add support for refund resource 2014-06-16 17:13:57 -07:00
Kyle Conroy
c6987ce09b Merge pull request #139 from stripe/truly_disable_ssl
Don't check blacklist if SSL verification is off
2014-06-05 16:04:54 -07:00
Kyle Conroy
0695960fc7 Don't check blacklist if SSL verification is off
It's helpful to be able to test the bindings with instances of the
Stripe API running locally, or running on a server that doesn't support
SSL. When :verify_ssl_certs is false, don't check the SSL cert against
the blacklist, as there probably isn't a certificate to check.
2014-06-05 15:49:26 -07:00
Stephen Wan
79cdeb0545 Bump Version 2014-05-28 16:11:40 -07:00
Stephen Wan
145a9df170 Merge pull request #137 from stripe/stephen-transfer-cancelation
Added support for transfer cancelation
2014-05-28 10:02:15 -07:00
Stephen Wan
c25d4b0cbf Cleaned up transfer tests 2014-05-27 16:59:22 -07:00
Stephen Wan
f13a050935 Added support for transfer cancelation 2014-05-26 11:30:20 -07:00
Amber Feng
56176b2539 Bump version. 2014-05-21 16:52:13 -07:00
Michelle Bu
5a0c97e561 Merge pull request #136 from stripe/recipient-cards
Construct the recipient card URL if the recipient property exists.
2014-05-21 16:28:34 -07:00
Michelle Bu
57309a05de Add tests for cards 2014-05-21 16:27:49 -07:00
Amber Feng
51af58c947 This needs to be a respond_to? instead. 2014-05-21 11:43:12 -07:00
Amber Feng
bc43fff551 Construct the recipient card URL if the recipient property exists. 2014-05-21 10:49:38 -07:00
Kyle Conroy
ca07ef08fd Add Travis CI badge to the README 2014-05-15 12:01:10 -07:00
Richo Healey
48f76057f4 Document our approach to SSL preflighting 2014-04-10 12:44:16 -07:00
Richo Healey
e6850316f7 Bump version 2014-04-09 20:57:37 -07:00
Richo Healey
f340d6249c Merge pull request #128 from stripe/richo-blacklist-certificates
blacklist certificates
2014-04-09 20:33:46 -07:00
Richo Healey
67f90ec108 Verify the fingerprint on api.stripe.com before making any requests 2014-04-09 19:57:45 -07:00
Andy Brody
6944e4e97f Update CA certificates bundle to 20130906.
http://www.ubuntu.com/usn/usn-2154-1/
https://gist.github.com/ab/9756531
2014-03-25 00:24:05 -07:00
Andy Brody
5c166e09c2 Sort the CA bundle in preparation for updating it. 2014-03-24 23:18:41 -07:00
Vladimir Andrijevik
5502c58162 Merge remote-tracking branch 'origin/master' into nested-to-hash 2014-03-18 11:10:14 +01:00
Matt Colyer
974f5ce425 Check for @values in StripeObject#method_not_found
If a StripeObject is being deserialized by psych, @values.has_key? is
called before @values is initialized which prevents proper
deserialization from occurring. Checking for existence first resolves
the issue.
2014-02-24 14:16:21 -08:00
Amber Feng
637d5899f6 Make History.txt more consistent 2014-02-18 15:07:32 -08:00
Amber Feng
5a7d69cd04 Bump version to 1.10.2 2014-02-18 14:56:55 -08:00
Amber Feng
089090cbe3 Merge pull request #121 from newaperio/lleger-create-subscription
Add ability to create subscriptions without fetching customer record. Closes #120.
2014-02-18 14:39:17 -08:00
Amber Feng
ff565c1b91 Merge pull request #117 from vandrijevik/fix-assert-equal-calls
Fix order of assert_equal calls that were backwards
2014-02-18 14:28:48 -08:00
Logan Leger
3ba9148042 Add ability to create subscriptions without fetching customer record
This commit adds `Customer#create_subscription`, which allows a
subscription to be created on a customer without first fetching the
customer record.

Previously:
```
customer = Stripe::Customer.retrieve('cus_abc123def') # GET request
customer.subscriptions.create(plan: 'cool-plan-1')    # POST request
```

**No alteration has been made to the above method; the preceding
implementation still functions as it did previously.**

With `#create_subscription`:
```
customer = Stripe::Customer.new('cus_abc123def')      # No request
customer.create_subscription(plan: 'cool-plan-1')     # POST request
```

This method removes the initial `GET` request and instead issues a
`POST` directly to create the subscription.
2014-02-18 15:12:44 -06:00
Krithika Muthukumar
880e5b539c fixing typo 2014-02-17 09:54:02 -08:00
Vladimir Andrijevik
310c69e90d In StripeObject#to_hash, call #to_hash on values which respond to it 2014-02-12 20:19:30 +01:00
Vladimir Andrijevik
650179b2aa Fix order of assert_equal calls that were backwards 2014-02-12 20:18:52 +01:00
Andrew Thorp
218178ea54 Bump to 1.10.1 2014-02-03 21:37:07 -06:00
Andrew Thorp
5029e818aa Merge pull request #105 from stripe/fix-marshaling
Fixes marshaling of Stripe Objects
2014-02-03 19:31:33 -08:00
Andrew Thorp
0fdd830975 fixed marshaling forrealz 2014-02-03 21:29:32 -06:00
Andrew Thorp
c46d285b47 fix lurky marshaling 2014-02-03 21:29:32 -06:00
Andrew Thorp
f74edde14c remove nilcheck of @values 2014-02-03 21:29:32 -06:00
Andrew Thorp
7ec8a12dff use _dump and self._load instead of marshal_* 2014-02-03 21:29:32 -06:00
Andrew Thorp
02b40e6637 fix tests 2014-02-03 21:29:32 -06:00
Andrew Thorp
c880d6a277 fixed marshaling of stripe objects, fixes #90 2014-02-03 21:29:32 -06:00
Andrew Thorp
7275b9b951 whoops, respond_to? cannot be protected 2014-02-03 21:29:32 -06:00
Andrew Thorp
45fe0c2591 whoops, forgot 1.8 support 2014-02-03 21:29:16 -06:00
Andrew Thorp
413939f89f fixed marshaling of stripe objects, fixes #90 2014-02-03 21:29:16 -06:00
Andrew Thorp
e1148c9f08 fixed marshaling forrealz 2014-02-03 21:17:37 -06:00
Andrew Thorp
11ed3d2d32 Merge pull request #110 from stripe/allow-expanding-on-save
Allow save to take opts
2014-01-29 17:50:06 -08:00
Andrew Thorp
9b3a3a020b Merge pull request #106 from stripe/replace-multi-json-with-json
Replace multi_json with json
2014-01-29 17:49:41 -08:00
Andrew Thorp
90278f20d4 fix lurky marshaling 2014-01-29 19:25:27 -06:00
Jim Danz
eeb2528a74 Bump version to 1.10.0 2014-01-29 16:51:03 -08:00
jimdanz
6eb9a784c0 Merge pull request #113 from jimdanz/ms
Ms
2014-01-29 16:48:03 -08:00
Jim Danz
d2058b3d1a Fixup old tests for new param style in test_subscription 2014-01-29 16:34:48 -08:00
Jim Danz
02b1b05eef Merge branch 'master' of github.com:stripe/stripe-ruby into ms 2014-01-29 14:59:33 -08:00
Jim Danz
c4d5774170 Support deleting subscription discounts 2014-01-29 14:59:29 -08:00
Jim Danz
06cfcc6131 Also uncomment legacy methods 2014-01-29 14:59:23 -08:00
Jim Danz
8231fba217 Revert "Clearing out subscription code/tests from Customer."
This reverts commit d6ebab33109ff2501ba9709d2ac1dd666be0ab67.
We'll support the legacy single-subscription API style
indefinitely, and also we generaly try to make it so that
people can use modern bindings with out-of-date API versions.
2014-01-29 14:57:40 -08:00
Jim Danz
97f8df2934 Merge branch 'multiple-subscriptions' of github.com:pat/stripe-ruby into ms 2014-01-29 14:42:57 -08:00
Andrew Thorp
90b613e416 remove nilcheck of @values 2014-01-29 07:58:55 -06:00
Andrew Thorp
689c15fde2 use _dump and self._load instead of marshal_* 2014-01-29 07:54:35 -06:00
Andrew Thorp
56e0403158 fix tests 2014-01-27 08:44:09 -06:00
Andrew Thorp
5331e81f54 #save doesn't need an api_key, it's on the object already 2014-01-26 12:13:39 -06:00
Andrew Thorp
da4c93c41c fixed marshaling of stripe objects, fixes #90 2014-01-25 15:38:44 -08:00
Tim Craft
a1dcef4b3f Add ruby 2.1.0 to travis config 2014-01-25 15:38:14 -08:00
Andrew Thorp
f9d8dd7d12 whoops, respond_to? cannot be protected 2014-01-25 15:38:14 -08:00
Andrew Thorp
88b4afbac0 allow save to take opts, and an api_key
fixes #78
2014-01-25 15:26:51 -08:00
Andrew Thorp
c5edb730cb Merge pull request #108 from timcraft/travis-ruby21
Add ruby 2.1.0 to travis config
2014-01-25 15:11:08 -08:00
Tim Craft
fdb2423c3a Add ruby 2.1.0 to travis config 2014-01-25 20:30:28 +00:00
Andrew Thorp
8b5f7d038c whoops, respond_to? cannot be protected 2014-01-24 23:37:35 -08:00
Andrew Thorp
ebfe240ab5 whoops, respond_to? cannot be protected 2014-01-24 23:37:09 -08:00
Andrew Thorp
837461ac28 whoops, forgot 1.8 support 2014-01-24 23:33:56 -08:00
Andrew Thorp
9ead81b352 replace multi_json with json, fixes #101 2014-01-24 23:27:25 -08:00
Andrew Thorp
e717ee711e fixed marshaling of stripe objects, fixes #90 2014-01-24 22:52:57 -08:00
Andrew Thorp
8b3a00c587 cleaning up a pull request from @thomasbrus 2014-01-24 21:27:45 -08:00
Thomas Brus
6a7f705be3 Fall back to #respond_to? if ruby version is lower than 1.9.2 2014-01-24 21:27:45 -08:00
Thomas Brus
a4b12fac62 Override #respond_to_missing? instead 2014-01-24 21:27:45 -08:00
Thomas Brus
dc10c1b344 Implemented #respond_to? 2014-01-24 21:27:45 -08:00
Thomas Brus
42cee040e0 Added unit test for respond_to 2014-01-24 21:27:45 -08:00
Andrew Thorp
ff7595c006 Merge pull request #97 from surfacedamage/customer-create-upcoming-invoice
Allow creation of new Invoice off Customer
2014-01-24 20:46:08 -08:00
Jim Danz
5bfe10c031 Add missing List operation to card 2014-01-22 19:42:04 -10:00
Pat Allan
b0f0c03990 Ensure delete parameters are passed through for subscriptions. 2014-01-22 17:42:37 +11:00
Pat Allan
d6ebab3310 Clearing out subscription code/tests from Customer. 2014-01-22 17:09:49 +11:00
Pat Allan
ee42d9c583 Adding tests for Subscription. 2014-01-22 17:09:49 +11:00
Conrad Decker
4d5f45a222 Add multiple subscription functionality - first pass 2014-01-22 17:09:49 +11:00
Amber Feng
d7ddf47d57 Merge pull request #103 from yaauie/issue-89/add-license-name-to-gemspec
Add license to gemspec. Fixes #89
2014-01-02 15:23:08 -08:00
Ryan Biesemeyer
1e8062b83b Add license to gemspec. Fixes #89 2013-12-21 22:19:43 +00:00
Amber Feng
f369ca16f9 Bump version to 1.9.9. 2013-12-02 11:56:33 -08:00
Amber Feng
127e906d60 Unit tests for ApplicationFee. 2013-11-14 14:04:55 -08:00
Felix Kenton
81e46f4d6c Added ApplicationFee class.
- Currently supports listing, retrieving and refunding.
2013-11-14 14:04:55 -08:00
Amber Feng
28ac4ffe00 Bump version to 1.8.9 2013-11-14 14:03:50 -08:00
Amber Feng
0149f83027 Fix api_resource_test to not return in blocks. 2013-11-14 13:52:22 -08:00
Amber Feng
84bda71e62 Remove whitespace. 2013-11-14 13:52:14 -08:00
Amber Feng
30c263bc59 Fix mime-types at 1.25 so we don't break Ruby 1.8. 2013-11-14 13:51:37 -08:00
Amber Feng
2a6c8b048a Merge pull request #95 from vipulnsward/cleanup_vars_2
Cleanup unused test variables
2013-11-14 11:48:45 -08:00
surfacedamage
73919cd1d5 Allow creation of new invoice off customer 2013-10-31 22:09:30 -04:00
Vipul A M
3e019adb6a Cleanup unused test variables 2013-10-25 23:23:22 +05:30
Kiran Bhattaram
294d6c63b3 Merge pull request #91 from stripe/metadata-api
Metadata API
2013-10-10 17:57:48 -07:00
kiran-b
a0f1856cbb refactored update api operation, added ruby 1.9 tests back 2013-10-09 20:56:31 -07:00
kiran-b
5626199c86 bumped version to 1.8.8 2013-10-08 21:13:51 -07:00
kiran-b
2970a577ba removed occasionally failing test: curl args order inconsistent 2013-10-08 21:13:44 -07:00
kiran-b
1724f85e26 tests for metadata 2013-10-08 21:01:13 -07:00
kiran-b
b52c98c9c3 added support for setting/deleting individual keys 2013-10-08 17:38:40 -07:00
Brian Collins
b02b557b74 Style tweaks 2013-10-08 13:54:39 -07:00
kiran-b
57656f6e89 update now accounts for metadata={'key' => 'val'} syntax 2013-10-08 13:54:39 -07:00
Michelle Bu
f9b13dfc2a active_card is no longer a thing 2013-10-07 10:05:59 -07:00
Lachy Groom
49724d755d Merge pull request #87 from stripe/lg-dispute-close
Ability to close disputes
2013-09-19 11:06:46 -07:00
Lachy Groom
11efb1e19e update version to 1.8.7 2013-09-18 15:53:13 -07:00
Lachy Groom
a5a6c19742 update version 2013-09-18 15:48:11 -07:00
Lachy Groom
30da413efc ability to close disputes 2013-09-18 15:43:05 -07:00
Amber Feng
06c860aeea Bump version to 1.8.6. 2013-08-13 20:58:34 +01:00
Finbarr Taylor
0851f2a7fd Added BalanceTransaction list resource.
Added Balance singleton resource.
2013-08-13 20:53:19 +01:00
Andrew Metcalf
56d8b910f7 Bump version 2013-08-12 09:07:37 -07:00
Andrew Metcalf
ac70a81be1 Merge pull request #82 from stripe/am-property-deletion
Support property deletion
2013-08-12 09:01:38 -07:00
Andrew Metcalf
c0ca48f848 rename mnemonic to description 2013-08-07 09:36:54 -07:00
Andrew Metcalf
d291020a43 clean up syntax 2013-08-06 15:47:33 -07:00
Andrew Metcalf
f0ddfca71d undo whitespace change 2013-08-06 15:29:29 -07:00
Andrew Metcalf
7d2ca0dbee better error messaging 2013-08-06 15:26:22 -07:00
Andrew Metcalf
88ead09193 support unsetting parameters by passing nil and updating 2013-08-06 11:37:35 -07:00
Evan Broder
fd09e67731 Merge pull request #77 from invisiblefunnel/master
Remove duplicate gemspec entries
2013-07-15 12:21:18 -07:00
Danny Whalen
bb9b4ecf97 Remove duplicate gemspec entries 2013-07-15 12:04:18 -07:00
Evan Broder
9999a482fd Merge pull request #76 from invisiblefunnel/master
Fix misspelled instance variable name
2013-07-15 11:52:27 -07:00
Danny Whalen
c0b77e6fbf Fix reference to instance variable 2013-07-15 11:38:13 -07:00
Sheena Pakanati
664a63a4de Bump version to 1.8.4 2013-07-11 17:49:03 -07:00
spakanati
1f1ebafe36 Merge pull request #75 from stripe/sp-cards
Support for new cards API
2013-07-11 17:42:56 -07:00
Sheena Pakanati
87604d945e Initial support for multiple cards. 2013-07-11 16:47:58 -07:00
Evan Broder
9b64772b7e Merge pull request #73 from timcraft/refactor-util-convert_to_stripe_object
Refactor Stripe::Util.convert_to_stripe_object method
2013-07-05 17:44:18 -07:00
Tim Craft
66be9d48dd Fix comment and use two argument form of Hash#fetch 2013-07-05 19:42:00 +01:00
Tim Craft
da6736478e Refactor Stripe::Util.convert_to_stripe_object method
* Extract hash mapping into object_classes method/ivar
* Use Hash#fetch instead of `if` and `||=`
2013-07-05 18:41:34 +01:00
Evan Broder
616b169958 Merge pull request #72 from timcraft/fix-the-build
Fix the build
2013-07-05 10:28:19 -07:00
Tim Craft
9ae705f845 Add version specifiers for activesupport/shoulda/mocha dev dependencies 2013-07-05 17:36:36 +01:00
Evan Broder
1fbce5288c Add a more helpful error message to ListObject#[]
Our list calls return their results wrapped in an object so that we
can include extra information. We use this, e.g., to include the URL
to query for more records in the Transfer#transactions sublist.

When you get a ListObject, if you want to actually manipulate it as a
list, you have to call `#data` first to get the actual underlying
list.

This adds an exception to the `#[]` method to make what's going on
clearer.

Fixes #68
2013-06-30 23:00:01 -07:00
Evan Broder
daafdb983d Fix confusion in ListObject around where api_key was coming from
Fixes #69
2013-06-30 22:34:30 -07:00
Evan Broder
c52973e7de Add a comment explaining file_readable 2013-06-29 22:46:52 -07:00
Evan Broder
2dbc700fc3 Bump version 2013-05-06 13:56:14 -07:00
Evan Broder
2861964755 Fix handling of per-resource API keys (fixes #67) 2013-05-06 13:53:00 -07:00
Evan Broder
aecfaa818f Bump version 2013-05-01 16:34:18 -07:00
Evan Broder
a95da742d4 Pass the customer-specific API key when getting the upcoming invoice 2013-05-01 15:02:34 -07:00
Evan Broder
dcb407c6d7 Merge remote-tracking branch 'origin/pull/65' 2013-05-01 14:46:23 -07:00
Evan Broder
3ab7c3253a Merge remote-tracking branch 'origin/pull/63' 2013-05-01 14:46:07 -07:00
Evan Broder
6f664422d4 Merge remote-tracking branch 'origin/pull/61' 2013-05-01 14:45:44 -07:00
Evan Broder
1b3dd625fd Merge remote-tracking branch 'origin/pull/60' 2013-05-01 14:43:44 -07:00
Evan Broder
a3884060a3 Merge remote-tracking branch 'origin/pull/58' 2013-05-01 14:38:05 -07:00
Evan Broder
c8fd610660 Merge remote-tracking branch 'origin/pull/57' 2013-05-01 14:38:03 -07:00
Evan Broder
523cdd548b Merge remote-tracking branch 'origin/pull/56' 2013-05-01 14:38:01 -07:00
Evan Broder
91c90ff43e Merge remote-tracking branch 'origin/pull/47'
Conflicts:
	lib/stripe.rb
2013-05-01 14:37:51 -07:00
Evan Broder
6b044e90ca Merge branch 'refactor'
Conflicts:
	lib/stripe.rb
2013-05-01 12:17:09 -07:00
Evan Broder
fe3eb47e60 Split out independent parts of Stripe.request and cleanup code
Make the SSL checks, user agent assembly, and request header
generation separate methods.

Also switch to class instance variables instead of class variables and
accessors instead of custom functions, and wrap lines to 80
characters.

Original patches come with thanks to Stevie Graham (with some style
fixups from me).

(fixes #53, fixes #54)
2013-05-01 12:14:29 -07:00
Brian Collins
56f9ba200f Add api_key argument to Invoice.upcoming 2013-04-19 13:06:17 +01:00
Rob Law
7e9407143e Add customer.upcoming_invoice convenience method
It seems to embrace the 'Ruby Way' (and more convenient in my own code) to be able to access an upcoming invoice from the customer itself rather than de-reference the customer id and ask the Invoice class itself for that info.
2013-04-14 14:21:29 +03:00
Amber Feng
cdf09a6f75 Bump version to 1.8.0. 2013-04-11 18:07:53 -07:00
Amber Feng
a7f7df94c6 Tests for transfers and recipients. 2013-04-11 18:00:47 -07:00
Amber Feng
b081187095 Allow creating transfers, add recipient object. 2013-04-11 18:00:31 -07:00
Alex Speller
abf5400726 Update README.rdoc 2013-04-06 17:13:18 +02:00
David Czarnecki
e593b0e0df Breakup tests into separate test files 2013-03-22 17:20:04 -04:00
Grant Olson
81ae6d7aee Due to a server misconfiguration issue, we were low on memory.
Attempting to spawn a subprocess to get the uname threw an out of
memory error.  Since the uname is only needed to provide diagnostic
info in the User-Agent, it shouldn't cause stripe to fail.
2013-03-20 14:48:26 -04:00
Jean Boussier
6a57264758 Allow to update a resource without retreiving it first
Rationale:

  Sometime you don't care about the current state of a resource
  you just want to update one of it's attributes.
  It should only require one request.

fixes #52

```ruby
  c = Stripe::Customer.new("cus_1EqKjPaFs4ZwDD")
  c.description = 'Ny new Description'
  c.save
```

Before:

```json
{
  error: {
    type: "invalid_request_error",
    message: "A parameter provided in the URL (id) was repeated as a GET or POST parameter. You can only provide this information as a portion of the URL.",
    param: "id",
  }
}
```

After:

Successfully update the customer and return it's whole state.
2013-03-14 11:04:18 -04:00
Tim Craft
6b43da28e3 Always call to_sym instead of type checking in Stripe::StripeObject#[] method 2013-03-14 14:06:09 +00:00
Tim Craft
ae30ffff7f Add Gemfile.lock to .gitignore 2013-03-14 13:50:24 +00:00
Tim Craft
fa24c46b90 Add ruby 2.0.0 to travis config 2013-03-14 13:49:19 +00:00
Amber Feng
ce34d9ef8b Use Invoice.all instead of Invoice.upcoming for base query parameter tests. 2013-03-11 18:07:45 -07:00
Amber Feng
7ddf3ea42b Fix URL building for when the base URL already has query parameters, and add test. 2013-03-11 13:19:28 -07:00
Evan Broder
a1ab276487 Merge pull request #51 from timcraft/patch-1
Remove rubygems require
2013-02-21 18:19:21 -08:00
Ross Boucher
56b792ccad Update version 2013-02-21 12:09:10 -08:00
Ross Boucher
b2aafa854e Add id to the list of permanent attributes 2013-02-21 11:54:16 -08:00
Ross Boucher
1b9f776f65 Merge pull request #50 from stripe/expand
Add the ability to send options with retrieve requests.
2013-02-04 15:54:26 -08:00
Ross Boucher
06c67e404e Revert to old style imports 2013-02-04 15:51:48 -08:00
Tim Craft
6a08f656d0 Remove rubygems require 2013-02-04 12:40:10 +00:00
Ross Boucher
5ffde047d3 Add the ability to send options with retrieve requests. 2013-02-01 12:12:03 -08:00
Evan Broder
3e30d5ad78 Merge pull request #49 from jalessio/patch-1
Update URL for API spec
2013-01-28 16:18:54 -08:00
Jamie
16a83dcce5 Update URL for API spec
https://stripe.com/api/spec 404's
2013-01-28 15:57:54 -08:00
spakanati
fb29711a4f Merge pull request #48 from stripe/sp-version
Add API version setting.
2013-01-15 12:59:54 -08:00
Sheena Pakanati
4dca4320d8 Bump version to 1.7.9. 2013-01-15 11:31:23 -08:00
Sheena Pakanati
4df245996b Add support for setting API version. 2013-01-15 11:31:03 -08:00
Evan Broder
0c28189194 Slightly cleaner way of getting all of activesupport 2012-12-04 16:11:34 -08:00
Alex MacCaw
f27e72cba6 remove Gemfile.lock 2012-12-04 13:59:26 -08:00
Alex MacCaw
738429a742 Add Gemfile.lock 2012-12-04 13:38:45 -08:00
Alex MacCaw
d196d8a343 Throw an error if the API key contains whitespace 2012-12-04 13:38:34 -08:00
Evan Broder
cf3c4a11b6 Bump version 2012-11-21 13:59:18 -08:00
Evan Broder
150c69a91d Delete Gemfile.locks
I'm pretty sure those weren't supposed to be committed in the first
place
2012-11-21 13:59:18 -08:00
Evan Broder
3354d9dddd Relax version constraint on multi_json (fixes #44)
We still need >= 1.0.4 because that's when support for pretty-printing
was introduced.
2012-11-21 13:59:14 -08:00
Amber Feng
be31c1934f Fix account API resource bug. 2012-11-08 14:40:15 -08:00
Sheena Pakanati
a841cbe0f4 Update version to 1.7.7 2012-11-08 12:18:31 -08:00
Sheena Pakanati
f389031887 Support for updating charge disputes 2012-11-08 12:16:36 -08:00
Ross Boucher
0080cfe707 Update date 2012-10-30 17:06:28 -07:00
Ross Boucher
140ef12a06 Merge remote branch 'origin/sp-invoice-create' 2012-10-30 17:04:35 -07:00
Ross Boucher
c0999ac5bb Remove the conflicting definition of transactions for transfers. 2012-10-29 22:13:07 -07:00
Sheena Pakanati
fd42cec19d Add support for creating invoices; bump version. 2012-10-29 11:03:51 -07:00
Ross Boucher
7f87b2bc4a Add support for list objects. Bumps version to 1.7.5 2012-10-25 19:42:23 -07:00
Evan Broder
7571ab5a38 Bump version 2012-10-08 16:54:40 -07:00
Evan Broder
79516e8552 Test on Ruby 1.9.2 in travis, since that's what Heroku uses by default 2012-10-08 16:43:39 -07:00
Evan Broder
f7a69489af Add a test for invoice pay 2012-10-08 16:40:39 -07:00
Evan Broder
e776c7a3cb Default the API method params to an empty dict, not nil
Fixes #42
2012-10-08 16:24:03 -07:00
Evan Broder
f625968bfd Bump version 2012-09-14 20:36:16 -07:00
Evan Broder
5ed29ec7be Don't use sudo in the README installation instructions
Fixes #40
2012-09-14 20:30:52 -07:00
Evan Broder
e8adad2c34 Encoding POST bodies ourselves, instead of letting rest-client
It's a bit unfortunate we have to do this, but this avoids an even
more unfortunate interaction between rest-client and hashery that
prevents passing a hash as the payload.

Also update the tests appropriately. This is also a bit messy, but I
didn't want to pull in Rack just for a handful of tests.

Fixes #38
2012-09-14 20:30:52 -07:00
Evan Broder
ae850157d7 Test that GET parameters are URL-encoded 2012-09-14 20:30:52 -07:00
Evan Broder
6b58d14fc1 URL-encode values (as well as keys) in GET params 2012-09-14 20:30:49 -07:00
900 changed files with 524994 additions and 5394 deletions

10
.editorconfig Normal file
View File

@ -0,0 +1,10 @@
# see http://editorconfig.org/
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
insert_final_newline = true

4
.gitattributes vendored Normal file
View File

@ -0,0 +1,4 @@
# may be useful in hiding large schema changes in pull request diffs (but not
# using it for now)
spec/*.json binary
spec/*.yaml binary

2
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1,2 @@
# All files should be reviewed by a member of the SDKs team
* @stripe/api-library-reviewers

78
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,78 @@
name: Bug report
description: Create a report to help us improve
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: what-happened
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
placeholder: Tell us what you see!
validations:
required: true
- type: textarea
id: repro-steps
attributes:
label: To Reproduce
description: Steps to reproduce the behavior
placeholder: |
1. Fetch a '...'
2. Update the '....'
3. See error
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: code-snippets
attributes:
label: Code snippets
description: If applicable, add code snippets to help explain your problem.
render: Ruby
validations:
required: false
- type: input
id: os
attributes:
label: OS
placeholder: macOS
validations:
required: true
- type: input
id: language-version
attributes:
label: Language version
placeholder: Ruby 3.1.2
validations:
required: true
- type: input
id: lib-version
attributes:
label: Library version
placeholder: stripe-ruby v5.52.0
validations:
required: true
- type: input
id: api-version
attributes:
label: API version
description: See [Versioning](https://stripe.com/docs/api/versioning) in the API Reference to find which version you're using
placeholder: "2020-08-27"
validations:
required: true
- type: textarea
id: additional-context
attributes:
label: Additional context
description: Add any other context about the problem here.
validations:
required: false

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Stripe support
url: https://support.stripe.com/
about: |
Please only file issues here that you believe represent actual bugs or feature requests for the Stripe Ruby library.
If you're having general trouble with your Stripe integration, please reach out to support.

View File

@ -0,0 +1,28 @@
name: Feature request
description: Suggest an idea for this library
labels: ["feature-request"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request!
- type: textarea
id: problem
attributes:
label: Is your feature request related to a problem? Please describe.
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
- type: textarea
id: solution
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
- type: textarea
id: alternatives
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.
- type: textarea
id: context
attributes:
label: Additional context
description: Add any other context about the feature request here.

11
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,11 @@
### Why?
<!-- Describe why this change is being made. Briefly include history and context, high-level what this PR does, and what the world looks like afterward. -->
### What?
<!--
List out the key changes made in this PR, e.g.
- implements the antimatter particle trace in the nitronium microfilament drive
- updated tests -->
### See Also
<!-- Include any links or additional information that help explain this change. -->

87
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,87 @@
name: CI
on:
workflow_dispatch: {}
push:
branches:
- master
- beta
- sdk-release/**
- feature/**
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
branches:
- master
- beta
- sdk-release/**
- feature/**
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
- name: Lint
run: just lint
- name: Build
run: gem build stripe.gemspec
- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: gems
path: '*.gem'
test:
name: Test (${{ matrix.ruby-version }})
# this version of jruby isn't available in the new latest (24.04) so we have to pin (or update jruby)
runs-on: ubuntu-22.04
strategy:
matrix:
ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2, 3.3, 3.4, jruby-9.4.0.0, truffleruby-head]
steps:
- uses: extractions/setup-just@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- uses: stripe/openapi/actions/stripe-mock@master
- name: test
run: just test typecheck
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
publish:
name: Publish
if: >-
((github.event_name == 'workflow_dispatch') || (github.event_name == 'push')) &&
startsWith(github.ref, 'refs/tags/v') &&
endsWith(github.actor, '-stripe')
needs: [build, test]
runs-on: ubuntu-22.04
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
name: gems
path: gems
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
- name: Publish gems to Rubygems
run: gem push gems/*.gem
env:
GEM_HOST_API_KEY: ${{secrets.GEM_HOST_API_KEY}}
- uses: stripe/openapi/actions/notify-release@master
if: always()
with:
bot_token: ${{ secrets.SLACK_BOT_TOKEN }}

21
.github/workflows/rules.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: rules
on:
workflow_dispatch: {}
pull_request:
types:
- auto_merge_enabled
jobs:
require_merge_commit_on_merge_script_pr:
name: Merge script PRs must create merge commits
if: ${{ contains(github.head_ref, '/merge-') }}
runs-on: ubuntu-latest
steps:
- run: |
if ${{ github.event.pull_request.auto_merge.merge_method != 'merge' }}; then
echo "Auto-merge method must be 'merge' instead of '${{github.event.pull_request.auto_merge.merge_method}}'"
exit 1
fi

7
.gitignore vendored
View File

@ -1,2 +1,9 @@
/stripe-*.gem
/Gemfile.lock
.rvmrc
Gemfile.lock
tags
/.bundle/
coverage/
.idea/
.ruby-version

398
.rubocop.yml Normal file
View File

@ -0,0 +1,398 @@
inherit_from: .rubocop_todo.yml
AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.3
Layout/CaseIndentation:
EnforcedStyle: end
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
Layout/LineLength:
Exclude:
- "lib/stripe/object_types.rb"
- "lib/stripe/stripe_client.rb"
- "lib/stripe/resources/**/*.rb"
- "lib/stripe/services/**/*.rb"
- "test/**/*.rb"
Lint/MissingSuper:
Exclude:
- "lib/stripe/resources/**/*.rb"
- "lib/stripe/services/**/*.rb"
- "test/stripe/request_params_test.rb"
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Max: 40
Exclude:
# `context` in tests are blocks and get quite large, so exclude the test
# directory from having to adhere to this rule.
- "test/**/*.rb"
Metrics/ClassLength:
Enabled: false
# There are several methods with many branches in api_requestor due to
# request logic.
Metrics/CyclomaticComplexity:
Exclude:
- "lib/stripe/api_requestor.rb"
- "lib/stripe/util.rb"
Metrics/PerceivedComplexity:
Exclude:
- "lib/stripe/api_requestor.rb"
- "lib/stripe/stripe_object.rb"
- "lib/stripe/util.rb"
Metrics/MethodLength:
# There's ~2 long methods in `APIRequestor` and one in `NestedResource`. If
# we want to truncate those a little, we could move this to be closer to ~30
# (but the default of 10 is probably too short).
Max: 55
Exclude:
- "lib/stripe/services/v1_services.rb"
- "lib/stripe/event_types.rb"
AllowedMethods:
- initialize
# TODO(xavdid): remove this once the first `basil` release is out
Naming/MethodName:
# these endpoints are removed soon so we pulled their overrides, meaning their names are wrong
# that won't make it out to users, but it's breaking linting/formatting in the meantime
Exclude:
- "lib/stripe/services/invoice_service.rb"
- "lib/stripe/resources/invoice.rb"
Metrics/ModuleLength:
Enabled: false
Metrics/ParameterLists:
# There's 2 methods in `StripeClient` that have long parameter lists.
Max: 8
# Optional parameters should be consistent across libraries, we need not be
# concerned about this. Was introduced with adding `base_address`
Exclude:
- "lib/stripe/api_operations/request.rb"
- "lib/stripe/stripe_object.rb"
- "lib/stripe/stripe_client.rb"
- "lib/stripe/resources/**/*.rb"
- "lib/stripe/services/**/*.rb"
Naming/MethodParameterName:
# We have many parameters that are less than 3 characters for tax codes
Exclude:
- "lib/stripe/resources/**/*.rb"
- "lib/stripe/services/**/*.rb"
Naming/VariableNumber:
# We use a variety of variable number syntaxes
Exclude:
- "lib/stripe/resources/**/*.rb"
- "lib/stripe/services/**/*.rb"
Style/AccessModifierDeclarations:
EnforcedStyle: inline
Style/AsciiComments:
Enabled: false
Style/FrozenStringLiteralComment:
EnforcedStyle: always
Style/HashEachMethods:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
Style/NumericPredicate:
Enabled: false
Style/StringLiterals:
EnforcedStyle: double_quotes
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma
Gemspec/DeprecatedAttributeAssignment: # new in 1.30
Enabled: true
Gemspec/DevelopmentDependencies: # new in 1.44
Enabled: true
Gemspec/RequireMFA: # new in 1.23
Enabled: false
Layout/LineContinuationLeadingSpace: # new in 1.31
Enabled: true
Layout/LineContinuationSpacing: # new in 1.31
Enabled: true
Layout/LineEndStringConcatenationIndentation: # new in 1.18
Enabled: true
Layout/SpaceBeforeBrackets: # new in 1.7
Enabled: true
Lint/AmbiguousAssignment: # new in 1.7
Enabled: true
Lint/AmbiguousOperatorPrecedence: # new in 1.21
Enabled: true
Lint/AmbiguousRange: # new in 1.19
Enabled: true
Lint/ConstantOverwrittenInRescue: # new in 1.31
Enabled: true
Lint/DeprecatedConstants: # new in 1.8
Enabled: true
Lint/DuplicateBranch: # new in 1.3
Enabled: true
Lint/DuplicateMagicComment: # new in 1.37
Enabled: true
Lint/DuplicateMatchPattern: # new in 1.50
Enabled: true
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
Enabled: true
Lint/EmptyBlock: # new in 1.1
Enabled: true
Lint/EmptyClass: # new in 1.3
Enabled: true
Lint/EmptyInPattern: # new in 1.16
Enabled: true
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
Enabled: true
Lint/LambdaWithoutLiteralBlock: # new in 1.8
Enabled: true
Lint/MixedCaseRange: # new in 1.53
Enabled: true
Lint/NoReturnInBeginEndBlocks: # new in 1.2
Enabled: true
Lint/NonAtomicFileOperation: # new in 1.31
Enabled: true
Lint/NumberedParameterAssignment: # new in 1.9
Enabled: true
Lint/OrAssignmentToConstant: # new in 1.9
Enabled: true
Lint/RedundantDirGlobSort: # new in 1.8
Enabled: true
Lint/RedundantRegexpQuantifiers: # new in 1.53
Enabled: true
Lint/RefinementImportMethods: # new in 1.27
Enabled: true
Lint/RequireRangeParentheses: # new in 1.32
Enabled: true
Lint/RequireRelativeSelfPath: # new in 1.22
Enabled: true
Lint/SymbolConversion: # new in 1.9
Enabled: true
Lint/ToEnumArguments: # new in 1.1
Enabled: true
Lint/TripleQuotes: # new in 1.9
Enabled: true
Lint/UnexpectedBlockArity: # new in 1.5
Enabled: true
Lint/UnmodifiedReduceAccumulator: # new in 1.1
Enabled: true
Lint/UselessAssignment:
Exclude:
- "test/stripe/generated_examples_test.rb"
Lint/UselessRescue: # new in 1.43
Enabled: true
Lint/UselessRuby2Keywords: # new in 1.23
Enabled: true
Metrics/CollectionLiteralLength: # new in 1.47
Enabled: true
Naming/BlockForwarding: # new in 1.24
Enabled: true
Security/CompoundHash: # new in 1.28
Enabled: true
Security/IoMethods: # new in 1.22
Enabled: true
Style/ArgumentsForwarding: # new in 1.1
Enabled: true
Style/ArrayIntersect: # new in 1.40
Enabled: true
Style/CollectionCompact: # new in 1.2
Enabled: true
Style/ComparableClamp: # new in 1.44
Enabled: true
Style/ConcatArrayLiterals: # new in 1.41
Enabled: true
Style/DataInheritance: # new in 1.49
Enabled: true
Style/DirEmpty: # new in 1.48
Enabled: true
Style/DocumentDynamicEvalDefinition: # new in 1.1
Enabled: true
Style/EmptyHeredoc: # new in 1.32
Enabled: true
Style/EndlessMethod: # new in 1.8
Enabled: true
Style/EnvHome: # new in 1.29
Enabled: true
Style/ExactRegexpMatch: # new in 1.51
Enabled: true
Style/FetchEnvVar: # new in 1.28
Enabled: true
Style/FileEmpty: # new in 1.48
Enabled: true
Style/FileRead: # new in 1.24
Enabled: true
Style/FileWrite: # new in 1.24
Enabled: true
Style/HashConversion: # new in 1.10
Enabled: true
Style/HashExcept: # new in 1.7
Enabled: true
Style/IfWithBooleanLiteralBranches: # new in 1.9
Enabled: true
Style/InPatternThen: # new in 1.16
Enabled: true
Style/MagicCommentFormat: # new in 1.35
Enabled: true
Style/MapCompactWithConditionalBlock: # new in 1.30
Enabled: true
Style/MapToHash: # new in 1.24
Enabled: true
Style/MapToSet: # new in 1.42
Enabled: true
Style/MinMaxComparison: # new in 1.42
Enabled: true
Style/MultilineInPatternThen: # new in 1.16
Enabled: true
Style/NegatedIfElseCondition: # new in 1.2
Enabled: true
Style/NestedFileDirname: # new in 1.26
Enabled: true
Style/NilLambda: # new in 1.3
Enabled: true
Style/NumberedParameters: # new in 1.22
Enabled: true
Style/NumberedParametersLimit: # new in 1.22
Enabled: true
Style/ObjectThen: # new in 1.28
Enabled: true
Style/OpenStructUse: # new in 1.23
Enabled: true
Style/OperatorMethodCall: # new in 1.37
Enabled: true
Style/QuotedSymbols: # new in 1.16
Enabled: true
Style/RedundantArgument: # new in 1.4
Enabled: true
Style/RedundantArrayConstructor: # new in 1.52
Enabled: true
Style/RedundantConstantBase: # new in 1.40
Enabled: true
Style/RedundantCurrentDirectoryInPath: # new in 1.53
Enabled: true
Style/RedundantDoubleSplatHashBraces: # new in 1.41
Enabled: true
Style/RedundantEach: # new in 1.38
Enabled: true
Style/RedundantFilterChain: # new in 1.52
Enabled: true
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
Enabled: true
Style/RedundantInitialize: # new in 1.27
Enabled: true
Style/RedundantLineContinuation: # new in 1.49
Enabled: true
Style/RedundantRegexpArgument: # new in 1.53
Enabled: true
Style/RedundantRegexpConstructor: # new in 1.52
Enabled: true
Style/RedundantSelfAssignmentBranch: # new in 1.19
Enabled: true
Style/RedundantStringEscape: # new in 1.37
Enabled: true
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
Enabled: true
Style/SelectByRegexp: # new in 1.22
Enabled: true
Style/SingleLineDoEndBlock: # new in 1.57
Enabled: true
Style/StringChars: # new in 1.12
Enabled: true
Style/SwapValues: # new in 1.1
Enabled: true
Style/YAMLFileRead: # new in 1.53
Enabled: true
Gemspec/AddRuntimeDependency: # new in 1.65
Enabled: true
Lint/ArrayLiteralInRegexp: # new in 1.71
Enabled: true
Lint/ConstantReassignment: # new in 1.70
Enabled: true
Lint/CopDirectiveSyntax: # new in 1.72
Enabled: true
Lint/DuplicateSetElement: # new in 1.67
Enabled: true
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
Enabled: true
Lint/ItWithoutArgumentsInBlock: # new in 1.59
Enabled: true
Lint/LiteralAssignmentInCondition: # new in 1.58
Enabled: true
Lint/NumericOperationWithConstantResult: # new in 1.69
Enabled: true
Lint/RedundantTypeConversion: # new in 1.72
Enabled: true
Lint/SharedMutableDefault: # new in 1.70
Enabled: true
Lint/SuppressedExceptionInNumberConversion: # new in 1.72
Enabled: true
Lint/UnescapedBracketInRegexp: # new in 1.68
Enabled: true
Lint/UselessConstantScoping: # new in 1.72
Enabled: true
Lint/UselessDefined: # new in 1.69
Enabled: true
Lint/UselessNumericOperation: # new in 1.66
Enabled: true
Style/AmbiguousEndlessMethodDefinition: # new in 1.68
Enabled: true
Style/BitwisePredicate: # new in 1.68
Enabled: true
Style/CombinableDefined: # new in 1.68
Enabled: true
Style/ComparableBetween: # new in 1.74
Enabled: true
Style/DigChain: # new in 1.69
Enabled: true
Style/FileNull: # new in 1.69
Enabled: true
Style/FileTouch: # new in 1.69
Enabled: true
Style/HashFetchChain: # new in 1.75
Enabled: true
Style/HashSlice: # new in 1.71
Enabled: true
Style/ItAssignment: # new in 1.70
Enabled: true
Style/ItBlockParameter: # new in 1.75
Enabled: true
Style/KeywordArgumentsMerging: # new in 1.68
Enabled: true
Style/MapIntoArray: # new in 1.63
Enabled: true
Style/RedundantFormat: # new in 1.72
Enabled: true
Style/RedundantInterpolationUnfreeze: # new in 1.66
Enabled: true
Style/SafeNavigationChainLength: # new in 1.68
Enabled: true
Style/SendWithLiteralMethodName: # new in 1.64
Enabled: true
Style/SuperArguments: # new in 1.64
Enabled: true
Style/SuperWithArgsParentheses: # new in 1.58
Enabled: true

87
.rubocop_todo.yml Normal file
View File

@ -0,0 +1,87 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-11-28 01:02:03 UTC using RuboCop version 1.57.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 2
Lint/HashCompareByIdentity:
Exclude:
- 'lib/stripe/api_requestor.rb'
# Offense count: 26
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 50
# Offense count: 9
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 592
# Offense count: 12
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 12
# Offense count: 9
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 7
# Offense count: 8
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 12
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: MinBranchesCount.
Style/CaseLikeIf:
Exclude:
- 'lib/stripe/stripe_configuration.rb'
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CombinableLoops:
Exclude:
- 'lib/stripe/api_requestor.rb'
# Offense count: 39
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowSplatArgument.
Style/HashConversion:
Exclude:
- 'lib/stripe/api_requestor.rb'
# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'lib/stripe/instrumentation.rb'
- 'lib/stripe/stripe_response.rb'
# Offense count: 15
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'lib/stripe.rb'
- 'lib/stripe/connection_manager.rb'
- 'lib/stripe/multipart_encoder.rb'
- 'lib/stripe/oauth.rb'
- 'lib/stripe/resources/bank_account.rb'
- 'lib/stripe/resources/source.rb'
- 'lib/stripe/api_requestor.rb'
- 'test/stripe/api_resource_test.rb'
- 'test/stripe/stripe_client_test.rb'
- 'test/stripe/webhook_test.rb'

View File

@ -1,8 +0,0 @@
language: ruby
rvm:
- 1.8.7
- 1.9.3
gemfile:
- gemfiles/default-with-activesupport.gemfile
- gemfiles/json.gemfile
- gemfiles/yajl.gemfile

9
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,9 @@
{
"recommendations": [
"EditorConfig.editorconfig", // default
"castwide.solargraph", // intellisense
"sorbet.sorbet-vscode-extension", // typechecking, where applicable
"LoranKloeze.ruby-rubocop-revived", // linting
"SarahRidge.vscode-ruby-syntax" // Semantic syntax highlighting
]
}

11
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
// Show the repo name in the top window bar.
"window.title": "${rootName}${separator}${activeEditorMedium}",
"editor.formatOnSave": true,
"files.trimTrailingWhitespace": true,
// Rubocop settings
"ruby.rubocop.configFilePath": ".rubocop.yml",
"ruby.rubocop.onSave": true
}

1704
CHANGELOG.md Normal file

File diff suppressed because it is too large Load Diff

77
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,77 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at conduct@stripe.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

25
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,25 @@
# Contributing
We welcome bug reports, feature requests, and code contributions in a pull request.
For most pull requests, we request that you identify or create an associated issue that has the necessary context. We use these issues to reach agreement on an approach and save the PR author from having to redo work. Fixing typos or documentation issues likely do not need an issue; for any issue that introduces substantial code changes, changes the public interface, or if you aren't sure, please find or [create an issue](https://www.github.com/stripe/stripe-ruby/issues/new/choose).
## Contributor License Agreement
All contributors must sign the Contributor License Agreement (CLA) before we can accept their contribution. If you have not yet signed the agreement, you will be given an option to do so when you open a pull request. You can then sign by clicking on the badge in the comment from @CLAassistant.
## Generated code
This project has a combination of manually maintained code and code generated from our private code generator. If your contribution involves changes to generated code, please call this out in the issue or pull request as we will likely need to make a change to our code generator before accepting the contribution.
To identify files with purely generated code, look for the comment `File generated from our OpenAPI spec.` at the start of the file. Generated blocks of code within hand-written files will be between comments that say `The beginning of the section generated from our OpenAPI spec` and `The end of the section generated from our OpenAPI spec`.
## Compatibility with supported language and runtime versions
This project supports [many different langauge and runtime versions](README.md#requirements) and we are unable to accept any contribution that does not work on _all_ supported versions. If, after discussing the approach in the associated issue, your change must use an API / feature that isn't available in all supported versions, please call this out explicitly in the issue or pull request so we can help figure out the best way forward.
## Set up your dev environment
Please refer to this project's [README.md](README.md#development) for instructions on how to set up your development environment.

39
Gemfile
View File

@ -1,2 +1,41 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec
group :development do
gem "mocha", "~> 1.16.0"
gem "rack", ">= 2.0.6"
gem "rake"
gem "shoulda-context", "2.0.0"
gem "test-unit"
# Version doesn't matter that much, but this one contains some fixes for Ruby
# 2.7 warnings that add noise to the test suite.
gem "webmock", ">= 3.8.0"
# Rubocop changes pretty quickly: new cops get added and old cops change
# names or go into new namespaces. This is a library and we don't have
# `Gemfile.lock` checked in, so to prevent good builds from suddenly going
# bad, pin to a specific version number here. Try to keep this relatively
# up-to-date, but it's not the end of the world if it's not.
#
# The latest version of rubocop is only compatible with Ruby 2.7+
gem "rubocop", "1.75.2" if RUBY_VERSION >= "2.7"
gem "sorbet"
gem "tapioca"
platforms :mri do
gem "byebug"
gem "pry"
gem "pry-byebug"
end
platforms :jruby do
gem "rbi", "0.2.4" # jruby does not support rbs, a new dependency in 0.3.0
end
end

View File

@ -1,34 +0,0 @@
PATH
remote: .
specs:
stripe (1.7.2)
multi_json (~> 1.1)
rest-client (~> 1.4)
GEM
remote: https://rubygems.org/
specs:
metaclass (0.0.1)
mime-types (1.19)
mocha (0.11.3)
metaclass (~> 0.0.1)
multi_json (1.3.6)
rake (0.9.2.2)
rest-client (1.6.7)
mime-types (>= 1.16)
shoulda (3.0.1)
shoulda-context (~> 1.0.0)
shoulda-matchers (~> 1.0.0)
shoulda-context (1.0.0)
shoulda-matchers (1.0.0)
test-unit (2.4.8)
PLATFORMS
ruby
DEPENDENCIES
mocha
rake
shoulda
stripe!
test-unit

View File

@ -1,72 +1 @@
=== 1.7.2 2012-08-31
* Add support for new pay and update methods for Invoice objects
=== 1.7.1 2012-08-15
* Add new Account API resource
=== 1.7.0 2012-05-17
* 3 major enhancements:
* Switch from vendored stripe-json to multi_json for all JSON
parsing and rendering. This should not impact programmatic usage
of the library, but may cause small rendering differences from,
e.g., StripeObject#inspect (github issue #22)
* Add new delete_discount method to Customer objects
* Add new Transfer API resource
* 2 minor enhancements:
* Switch from HTTP Basic auth to Bearer auth (Note: Stripe will
support Basic auth for the indefinite future, but recommends
Bearer auth when possible going forward)
* Numerous test suite improvements
=== 1.6.3 2012-03-22
* 1 bugfix:
* Encode GET query strings ourselves instead of using rest-client to
work around a bug
=== 1.6.2 2012-02-24
* 1 bugfix:
* Correct argument handling in StripeObject#as_json
=== 1.6.1 2012-02-22
* 1 bugfix:
* Fix StripeObject#inspect when ActiveSupport 3.0 is loaded
=== 1.6.0 2012-02-01
* A whole bunch of releases between 1.5.0 and 1.6.0, but few changes, mainly the addition of:
- plans
- coupons
- events
- tokens
* 1.6.0 also contains a new inspect/to_string implementation
=== 1.5.0 2011-05-09
* 1 major enhancement:
* Update for new RESTful API
=== 1.3.4 2011-01-07
* 1 major enhancement:
* Rename to Stripe
=== 1.2 2010-06-06
* 1 major enhancement:
* Support for the set_customer_subscription and delete_customer API methods
=== 1.1 2010-03-14
* 1 major enhancement:
* Support for recurring billing
=== 1.0 2010-01-05
* 1 major enhancement:
* Initial release
History.txt has been converted to a formal changelog. Please see CHANGELOG.md.

22
Makefile Normal file
View File

@ -0,0 +1,22 @@
# NOTE: this file is deprecated and slated for deletion; prefer using the equivalent `just` commands.
.PHONY: update-version codegen-format test ci-test
update-version:
@echo "$(VERSION)" > VERSION
@perl -pi -e 's|VERSION = "[.\-\w\d]+"|VERSION = "$(VERSION)"|' lib/stripe/version.rb
codegen-format:
bundle install --quiet
bundle exec rubocop -o /dev/null --autocorrect
ci-test:
bundle install && bundle exec rake test
@version=$$(ruby -e "puts RUBY_VERSION.split('.')[0..1].join.to_i"); \
if [ $$version -ge 27 ]; then \
echo "Ruby version >= 2.7, continue with srb tc"; \
bundle exec srb tc; \
else \
echo "Ruby version < 2.7, skipping srb tc"; \
fi
test: ci-test

1
OPENAPI_VERSION Normal file
View File

@ -0,0 +1 @@
v1773

460
README.md Normal file
View File

@ -0,0 +1,460 @@
# Stripe Ruby Library
[![Gem Version](https://badge.fury.io/rb/stripe.svg)](https://badge.fury.io/rb/stripe)
[![Build Status](https://github.com/stripe/stripe-ruby/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/stripe/stripe-ruby/actions?query=branch%3Amaster)
The Stripe Ruby library provides convenient access to the Stripe API from
applications written in the Ruby language. It includes a pre-defined set of
classes for API resources that initialize themselves dynamically from API
responses which makes it compatible with a wide range of versions of the Stripe
API.
The library also provides other features. For example:
- Easy configuration path for fast setup and use.
- Helpers for pagination.
- Built-in mechanisms for the serialization of parameters according to the
expectations of Stripe's API.
## Documentation
See the [Ruby API docs](https://stripe.com/docs/api?lang=ruby).
## Installation
You don't need this source code unless you want to modify the gem. If you just
want to use the package, just run:
```sh
gem install stripe
```
If you want to build the gem from source:
```sh
gem build stripe.gemspec
```
### Requirements
- Ruby 2.3+.
### Bundler
If you are installing via bundler, you should be sure to use the https rubygems
source in your Gemfile, as any gems fetched over http could potentially be
compromised in transit and alter the code of gems fetched securely over https:
```ruby
source 'https://rubygems.org'
gem 'rails'
gem 'stripe'
```
## Usage
The library needs to be configured with your account's secret key which is
available in your [Stripe Dashboard][api-keys]. Set `Stripe.api_key` to its
value:
```ruby
require 'stripe'
Stripe.api_key = 'sk_test_...'
# list customers
Stripe::Customer.list()
# retrieve single customer
Stripe::Customer.retrieve('cus_123456789')
```
### Per-request Configuration
For apps that need to use multiple keys during the lifetime of a process, like
one that uses [Stripe Connect][connect], it's also possible to set a
per-request key and/or account:
```ruby
require "stripe"
Stripe::Customer.list(
{},
{
api_key: 'sk_test_...',
stripe_account: 'acct_...',
stripe_version: '2018-02-28',
}
)
Stripe::Customer.retrieve(
'cus_123456789',
{
api_key: 'sk_test_...',
stripe_account: 'acct_...',
stripe_version: '2018-02-28',
}
)
Stripe::Customer.retrieve(
{
id: 'cus_123456789',
expand: %w(balance_transaction)
},
{
stripe_version: '2018-02-28',
api_key: 'sk_test_...',
}
)
Stripe::Customer.capture(
'cus_123456789',
{},
{
stripe_version: '2018-02-28',
api_key: 'sk_test_...',
}
)
```
Keep in mind that there are different method signatures depending on the action:
- When operating on a collection (e.g. `.list`, `.create`) the method signature is
`method(params, opts)`.
- When operating on resource (e.g. `.capture`, `.update`) the method signature is
`method(id, params, opts)`.
- One exception is that `retrieve`, despite being an operation on a resource, has the signature
`retrieve(id, opts)`. In addition, it will accept a Hash for the `id` param but will extract the
`id` key out and use the others as options.
### StripeClient vs legacy pattern
We introduced the `StripeClient` class in v13 of the Ruby SDK. The legacy pattern used prior to that version is still available to use but will be marked as deprecated soon. Review the [migration guide to use StripeClient](https://github.com/stripe/stripe-ruby/wiki/Migration-guide-for-v13) to move from the legacy pattern.
Once the legacy pattern is deprecated, new API endpoints will only be accessible in the StripeClient. While there are no current plans to remove the legacy pattern for existing API endpoints, this may change in the future.
### Accessing resource properties
Both indexer and accessors can be used to retrieve values of resource properties.
```ruby
customer = Stripe::Customer.retrieve('cus_123456789')
puts customer['id']
puts customer.id
```
NOTE: If the resource property is not defined, the accessors will raise an exception, while the indexer will return `nil`.
```ruby
customer = Stripe::Customer.retrieve('cus_123456789')
puts customer['unknown'] # nil
puts customer.unknown # raises NoMethodError
```
### Accessing a response object
Get access to response objects by using the `last_response` property of the returned resource:
```ruby
customer = Stripe::Customer.retrieve('cus_123456789')
print(customer.last_response.http_status) # to retrieve status code
print(customer.last_response.http_headers) # to retrieve headers
```
If you are accessing a response field with custom hashes provided by you, such as `Customer.metadata`,
please access your fields with the `[]` accessor.
### Configuring a proxy
A proxy can be configured with `Stripe.proxy`:
```ruby
Stripe.proxy = 'https://user:pass@example.com:1234'
```
### Configuring an API Version
By default, the library will use the API version pinned to the account making
a request. This can be overridden with this global option:
```ruby
Stripe.api_version = '2018-02-28'
```
See [versioning in the API reference][versioning] for more information.
### Configuring CA Bundles
By default, the library will use its own internal bundle of known CA
certificates, but it's possible to configure your own:
```ruby
Stripe.ca_bundle_path = 'path/to/ca/bundle'
```
### Configuring Automatic Retries
You can enable automatic retries on requests that fail due to a transient
problem by configuring the maximum number of retries:
```ruby
Stripe.max_network_retries = 2
```
Various errors can trigger a retry, like a connection error or a timeout, and
also certain API responses like HTTP status `409 Conflict`.
[Idempotency keys][idempotency-keys] are added to requests to guarantee that
retries are safe.
### Configuring Timeouts
Open, read and write timeouts are configurable:
```ruby
Stripe.open_timeout = 30 # in seconds
Stripe.read_timeout = 80
Stripe.write_timeout = 30 # only supported on Ruby 2.6+
```
Please take care to set conservative read timeouts. Some API requests can take
some time, and a short timeout increases the likelihood of a problem within our
servers.
### Logging
The library can be configured to emit logging that will give you better insight
into what it's doing. The `info` logging level is usually most appropriate for
production use, but `debug` is also available for more verbosity.
There are a few options for enabling it:
1. Set the environment variable `STRIPE_LOG` to the value `debug` or `info`:
```sh
$ export STRIPE_LOG=info
```
2. Set `Stripe.log_level`:
```ruby
Stripe.log_level = Stripe::LEVEL_INFO
```
### Instrumentation
The library has various hooks that user code can tie into by passing a block to
`Stripe::Instrumentation.subscribe` to be notified about specific events.
#### `request_begin`
Invoked when an HTTP request starts. Receives `RequestBeginEvent` with the
following properties:
- `method`: HTTP method. (`Symbol`)
- `path`: Request path. (`String`)
- `user_data`: A hash on which users can set arbitrary data, and which will be
passed through to `request_end` invocations. This could be used, for example,
to assign unique IDs to each request, and it'd work even if many requests are
running in parallel. All subscribers share the same object for any particular
request, so they must be careful to use unique keys that will not conflict
with other subscribers. (`Hash`)
#### `request_end`
Invoked when an HTTP request finishes, regardless of whether it terminated with
a success or error. Receives `RequestEndEvent` with the following properties:
- `duration`: Request duration in seconds. (`Float`)
- `http_status`: HTTP response code (`Integer`) if available, or `nil` in case
of a lower level network error.
- `method`: HTTP method. (`Symbol`)
- `num_retries`: The number of retries. (`Integer`)
- `path`: Request path. (`String`)
- `user_data`: A hash on which users may have set arbitrary data in
`request_begin`. See above for more information. (`Hash`)
- `request_id`: HTTP request identifier. (`String`)
- `response_header`: The response headers. (`Hash`)
- `response_body` = The response body. (`String`)
- `request_header` = The request headers. (`Hash`)
- `request_body` = The request body. (`String`)
#### Example
For example:
```ruby
Stripe::Instrumentation.subscribe(:request_end) do |request_event|
# Filter out high-cardinality ids from `path`
path_parts = request_event.path.split("/").drop(2)
resource = path_parts.map { |part| part.match?(/\A[a-z_]+\z/) ? part : ":id" }.join("/")
tags = {
method: request_event.method,
resource: resource,
code: request_event.http_status,
retries: request_event.num_retries
}
StatsD.distribution('stripe_request', request_event.duration, tags: tags)
end
```
### Writing a Plugin
If you're writing a plugin that uses the library, we'd appreciate it if you
identified using `#set_app_info`:
```ruby
Stripe.set_app_info('MyAwesomePlugin', version: '1.2.34', url: 'https://myawesomeplugin.info')
```
This information is passed along when the library makes calls to the Stripe
API.
### Telemetry
By default, the library sends telemetry to Stripe regarding request latency and feature usage. These
numbers help Stripe improve the overall latency of its API for all users, and
improve popular features.
You can disable this behavior if you prefer:
```ruby
Stripe.enable_telemetry = false
```
### Types
In [v14.0.0](https://github.com/stripe/stripe-python/releases/tag/v7.1.0) and newer, the library provides RBI
static type annotations. See [the wiki](https://github.com/stripe/stripe-ruby/wiki/Static-Type-Annotations)
for an detailed guide.
Please note that these types are available only for static analysis and we only support RBIs at the moment.
Please [report an issue](https://github.com/stripe/stripe-ruby/issues/new/choose)
if you find discrepancies or have issues using types.
The RBIs can be found in the `rbi/stripe/` directory, and to decrease `Tapioca` loading time we pack the gem with the
combined RBI at `rbi/stripe.rbi`.
#### Types and the Versioning Policy
We release type changes in minor releases. While stripe-ruby follows semantic versioning, our semantic
versions describe the runtime behavior of the library alone. Our type annotations are not reflected in the
semantic version. That is, upgrading to a new minor version of `stripe-ruby` might result in your type checker
producing a type error that it didn't before. You can use `~> x.x` or `x.x.x` constrain the version
of `stripe-ruby` in your Gemfile to a certain version or range of `stripe-ruby`.
#### Types and API Versions
The types describe the [Stripe API version](https://stripe.com/docs/api/versioning)
that was the latest at the time of release. This is the version that your library sends
by default. If you are overriding `Stripe.api_version` / `stripe_version` on the StripeClient,
or using a webhook endpoint tied to an older version, be aware that the data
you see at runtime may not match the types.
### Public Preview SDKs
Stripe has features in the [public preview phase](https://docs.stripe.com/release-phases) that can be accessed via versions of this package that have the `-beta.X` suffix like `11.2.0-beta.2`.
We would love for you to try these as we incrementally release new features and improve them based on your feedback.
To install, choose the version that includes support for the preview feature you are interested in by reviewing the [releases page](https://github.com/stripe/stripe-ruby/releases/) and use it in the `gem install` command:
```sh
gem install stripe -v <replace-with-the-version-of-your-choice>
```
You can find the latest version to use in this command from the [releases page](https://github.com/stripe/stripe-ruby/releases/)
> **Note**
> There can be breaking changes between two versions of the public preview SDKs without a bump in the major version. Therefore we recommend pinning the package version to a specific version in your Gemfile. This way you can install the same version each time without breaking changes unless you are intentionally looking for the latest version of the public preview SDK.
We highly recommend keeping an eye on when the beta feature you are interested in goes from beta to stable so that you can move from using a beta version of the SDK to the stable version.
Some preview features require a name and version to be set in the `Stripe-Version` header like `feature_beta=v3`. If your preview feature has this requirement, use the `Stripe.add_beta_version` function (available only in the public preview SDKs):
```python
Stripe.add_beta_version("feature_beta", "v3")
```
### Custom requests
If you:
- would like to send a request to an undocumented API (for example you are in a private beta)
- prefer to bypass the method definitions in the library and specify your request details directly,
- used the method `Stripe::APIResource.request(...)` to specify your own requests, which will soon be broken
you can now use the `raw_request` method on `StripeClient`.
```ruby
client = Stripe::StripeClient.new(...)
resp = client.raw_request(:post, "/v1/beta_endpoint", params: {param: 123}, opts: {stripe_version: "2022-11-15; feature_beta=v3"})
# (Optional) resp is a StripeResponse. You can use `Stripe.deserialize` to get a StripeObject.
deserialized_resp = client.deserialize(resp.http_body)
```
## Support
New features and bug fixes are released on the latest major version of the Stripe Ruby library. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.
## Development
[Contribution guidelines for this project](CONTRIBUTING.md)
The test suite depends on [stripe-mock], so make sure to fetch and run it from a background terminal ([stripe-mock's README][stripe-mock] also contains instructions for installing via Homebrew and other methods):
```sh
go install github.com/stripe/stripe-mock@latest
stripe-mock
```
We use [just](https://github.com/casey/just) for common development tasks. You can install it or run the underlying commands directly (by copying them from the `justfile`). Common tasks include:
Run all tests:
```sh
just test
# or: bundle exec rake test
```
Run a single test suite:
```sh
bundle exec ruby -Ilib/ test/stripe/util_test.rb
```
Run a single test:
```sh
bundle exec ruby -Ilib/ test/stripe/util_test.rb -n /should.convert.names.to.symbols/
```
Run the linter:
```sh
just lint
# or: bundle exec rubocop
```
Update bundled CA certificates from the [Mozilla cURL release][curl]:
```sh
just update-certs
# or: bundle exec rake update_certs
```
Update the bundled [stripe-mock] by editing the version number found in
`.travis.yml`.
[api-keys]: https://dashboard.stripe.com/account/apikeys
[connect]: https://stripe.com/connect
[curl]: http://curl.haxx.se/docs/caextract.html
[idempotency-keys]: https://stripe.com/docs/api/idempotent_requests?lang=ruby
[stripe-mock]: https://github.com/stripe/stripe-mock
[versioning]: https://stripe.com/docs/api/versioning?lang=ruby
<!--
# vim: set tw=79:
-->

View File

@ -1,28 +0,0 @@
= Stripe Ruby bindings {<img src="https://gemnasium.com/stripe/stripe-ruby.png" alt="Dependency Status" />}[https://gemnasium.com/stripe/stripe-ruby]
== Installation
You don't need this source code unless you want to modify the gem. If
you just want to use the Stripe Ruby bindings, you should run:
sudo gem install --source https://code.stripe.com stripe
If you want to build the gem from source:
sudo gem build stripe.gemspec
== Requirements
* Ruby 1.8.7 or above. (Ruby 1.8.6 may work if you load
ActiveSupport.)
* rest-client, multi_json
== Mirrors
The stripe gem is mirrored on Rubygems, so you should be able to
install it via <tt>gem install stripe</tt> if desired. We recommend using
the https://code.stripe.com mirror so all code is fetched over SSL.
== Development
Test cases can be run with: `bundle exec rake test`

View File

@ -1,9 +1,34 @@
task :default => [:test]
# frozen_string_literal: true
task :test do
ret = true
Dir["test/**/*.rb"].each do |f|
ret = ret && ruby(f, '')
end
exit(ret)
require "rake/testtask"
task default: %i[test rubocop]
Rake::TestTask.new do |t|
t.pattern = "./test/**/*_test.rb"
end
desc "Update bundled certs"
task :update_certs do
require "net/http"
require "uri"
fetch_file "https://curl.haxx.se/ca/cacert.pem",
File.expand_path("lib/data/ca-certificates.crt", __dir__)
end
#
# helpers
#
def fetch_file(uri, dest)
File.open(dest, "w") do |file|
resp = Net::HTTP.get_response(URI.parse(uri))
unless resp.code.to_i == 200
abort("bad response when fetching: #{uri}\n" \
"Status #{resp.code}: #{resp.body}")
end
file.write(resp.body)
puts "Successfully fetched: #{uri}"
end
end

View File

@ -1 +1 @@
1.7.2
15.2.1

View File

@ -1,7 +0,0 @@
#!/usr/bin/env ruby
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
libs = " -r irb/completion"
libs << " -r #{File.dirname(__FILE__) + '/../lib/stripe'}"
puts "Loading stripe gem"
exec "#{irb} #{libs} --simple-prompt"

27
bin/tapioca Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'tapioca' is installed as part of a gem, and
# this file is here to facilitate running it.
#
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
bundle_binstub = File.expand_path("bundle", __dir__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end
require "rubygems"
require "bundler/setup"
load Gem.bin_path("tapioca", "tapioca")

16
examples/README.md Normal file
View File

@ -0,0 +1,16 @@
## Running an example
From the examples folder, run:
`RUBYLIB=../lib ruby your_example.rb`
e.g.
`RUBYLIB=../lib ruby thinevent_webhook_handler.rb`
## Adding a new example
1. Clone new_example.rb
2. Implement your example
3. Fill out the file comment. Include a description and key steps that are being demonstrated.
4. Run it (as per above)
5. 👍

View File

@ -0,0 +1,36 @@
# frozen_string_literal: true
# example_template.py - This is a template for defining new examples. It is not intended to be used directly.
#
# <describe what this example does>
#
# In this example, we:
# - <key step 1>
# - <key step 2
# - ...
#
# <describe assumptions about the user's stripe account, environment, or configuration;
# or things to watch out for when running>
require "stripe"
require "date"
class ExampleTemplate
attr_accessor :api_key
def initialize(api_key)
@api_key = api_key
end
def do_something_great
puts "Hello World"
# client = Stripe::StripeClient.new(api_key)
# client.v1
end
end
# Send meter events
api_key = "{{API_KEY}}"
example = ExampleTemplate.new(api_key)
example.do_something_great

View File

@ -0,0 +1,57 @@
# frozen_string_literal: true
# meter_event_stream.py - use the high-throughput meter event stream to report create billing meter events.
#
# In this example, we:
# - create a meter event session and store the session's authentication token
# - define an event with a payload
# - use the meter_event_stream service accessor in StripeClient to create an event stream that reports this event
#
# This example expects a billing meter with an event_name of 'alpaca_ai_tokens'. If you have
# a different meter event name, you can change it before running this example.
require "stripe"
require "date"
class MeterEventManager
attr_accessor :api_key, :meter_event_session
def initialize(api_key)
@api_key = api_key
@meter_event_session = nil
end
def refresh_meter_event_session
return unless @meter_event_session.nil? || DateTime.parse(@meter_event_session.expires_at) <= DateTime.now
# Create a new meter event session in case the existing session expired
client = Stripe::StripeClient.new(api_key)
@meter_event_session = client.v2.billing.meter_event_session.create
end
def send_meter_event(meter_event)
# Refresh the meter event session if necessary
refresh_meter_event_session
# Create a meter event with the current session's authentication token
client = Stripe::StripeClient.new(meter_event_session.authentication_token)
client.v2.billing.meter_event_stream.create(
events: [meter_event]
)
end
end
# Send meter events
api_key = "{{API_KEY}}"
customer_id = "{{CUSTOMER_ID}}"
manager = MeterEventManager.new(api_key)
manager.send_meter_event(
{
event_name: "alpaca_ai_tokens",
payload: {
"stripe_customer_id" => customer_id,
"value" => "25",
},
}
)

View File

@ -0,0 +1,39 @@
# frozen_string_literal: true
# typed: false
# thinevent_webhook_handler.rb - receive and process thin events like the
# v1.billing.meter.error_report_triggered event.
#
# In this example, we:
# - create a StripeClient called client
# - use client.parse_thin_event to parse the received thin event webhook body
# - call client.v2.core.events.retrieve to retrieve the full event object
# - if it is a V1BillingMeterErrorReportTriggeredEvent event type, call
# event.fetchRelatedObject to retrieve the Billing Meter object associated
# with the event.
require "stripe"
require "sinatra"
api_key = ENV.fetch("STRIPE_API_KEY", nil)
# Retrieve the webhook secret from the environment variable
webhook_secret = ENV.fetch("WEBHOOK_SECRET", nil)
client = Stripe::StripeClient.new(api_key)
post "/webhook" do
webhook_body = request.body.read
sig_header = request.env["HTTP_STRIPE_SIGNATURE"]
thin_event = client.parse_thin_event(webhook_body, sig_header, webhook_secret)
# Fetch the event data to understand the failure
event = client.v2.core.events.retrieve(thin_event.id)
if event.instance_of? Stripe::V1BillingMeterErrorReportTriggeredEvent
meter = event.fetch_related_object
meter_id = meter.id
puts "Success!", meter_id
end
# Record the failures and alert your team
status 200
end

16
exe/stripe-console Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require "irb"
require "irb/completion"
require "#{File.dirname(__FILE__)}/../lib/stripe"
# Config IRB to enable --simple-prompt and auto indent
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:AUTO_INDENT] = true
puts "Loaded gem 'stripe'"
IRB.start

View File

@ -1,3 +0,0 @@
source "https://rubygems.org"
gemspec :path => File.join(File.dirname(__FILE__), "..")
gem "activesupport"

View File

@ -1,39 +0,0 @@
PATH
remote: /home/evan/src/stripe-ruby
specs:
stripe (1.7.0)
multi_json (~> 1.1)
rest-client (~> 1.4)
GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
i18n (0.6.0)
metaclass (0.0.1)
mime-types (1.18)
mocha (0.11.4)
metaclass (~> 0.0.1)
multi_json (1.3.4)
rake (0.9.2.2)
rest-client (1.6.7)
mime-types (>= 1.16)
shoulda (3.0.1)
shoulda-context (~> 1.0.0)
shoulda-matchers (~> 1.0.0)
shoulda-context (1.0.0)
shoulda-matchers (1.0.0)
test-unit (2.4.8)
PLATFORMS
ruby
DEPENDENCIES
activesupport
mocha
rake
shoulda
stripe!
test-unit

View File

@ -1,4 +0,0 @@
source "https://rubygems.org"
gemspec :path => File.join(File.dirname(__FILE__), "..")
gem "json"
gem "activesupport"

View File

@ -1,41 +0,0 @@
PATH
remote: /home/evan/src/stripe-ruby
specs:
stripe (1.7.0)
multi_json (~> 1.1)
rest-client (~> 1.4)
GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
i18n (0.6.0)
json (1.7.0)
metaclass (0.0.1)
mime-types (1.18)
mocha (0.11.3)
metaclass (~> 0.0.1)
multi_json (1.3.4)
rake (0.9.2.2)
rest-client (1.6.7)
mime-types (>= 1.16)
shoulda (3.0.1)
shoulda-context (~> 1.0.0)
shoulda-matchers (~> 1.0.0)
shoulda-context (1.0.0)
shoulda-matchers (1.0.0)
test-unit (2.4.8)
PLATFORMS
ruby
DEPENDENCIES
activesupport
json
mocha
rake
shoulda
stripe!
test-unit

View File

@ -1,4 +0,0 @@
source "https://rubygems.org"
gemspec :path => File.join(File.dirname(__FILE__), "..")
gem "yajl-ruby"
gem "activesupport"

View File

@ -1,41 +0,0 @@
PATH
remote: /home/evan/src/stripe-ruby
specs:
stripe (1.7.0)
multi_json (~> 1.1)
rest-client (~> 1.4)
GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
i18n (0.6.0)
metaclass (0.0.1)
mime-types (1.18)
mocha (0.11.3)
metaclass (~> 0.0.1)
multi_json (1.3.4)
rake (0.9.2.2)
rest-client (1.6.7)
mime-types (>= 1.16)
shoulda (3.0.1)
shoulda-context (~> 1.0.0)
shoulda-matchers (~> 1.0.0)
shoulda-context (1.0.0)
shoulda-matchers (1.0.0)
test-unit (2.4.8)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
activesupport
mocha
rake
shoulda
stripe!
test-unit
yajl-ruby

43
justfile Normal file
View File

@ -0,0 +1,43 @@
set quiet
import? '../sdk-codegen/utils.just'
_default:
just --list --unsorted
install *args:
bundle install {{ if is_dependency() == "true" {"--quiet"} else {""} }} {{ args }}
# ⭐ run all unit tests
test: install
bundle exec rake test
# check linting / formatting status of files
format-check *args: install
bundle exec rubocop {{ args }}
alias lint-check := format-check
# ⭐ check style & formatting for all files, fixing what we can
lint: (format-check "--autocorrect")
# NOTE: "-o /dev/null" is vital - rubocop has super noisy output and codegen will crash when formatting ruby if everything gets printed
# so, we send all its output to the void
# copy of `lint` with less output
format: (format-check "-o /dev/null --autocorrect")
update-certs: install
bundle exec rake update_certs
# run sorbet to check type definitions
typecheck: install
{{ if semver_matches(`ruby -e "puts RUBY_VERSION"`, ">=2.7") == "true" { \
"bundle exec srb tc" \
} else { \
"echo \"Ruby version < 2.7, skipping srb tc\"" \
} }}
# called by tooling
[private]
update-version version:
echo "{{ version }}" > VERSION
perl -pi -e 's|VERSION = "[.\-\w\d]+"|VERSION = "{{ version }}"|' lib/stripe/version.rb

File diff suppressed because it is too large Load Diff

View File

@ -1,242 +1,160 @@
# Stripe Ruby bindings
# API spec at http://stripe.com/api/spec
require 'cgi'
require 'set'
require 'rubygems'
require 'openssl'
# frozen_string_literal: true
gem 'rest-client', '~> 1.4'
require 'rest_client'
require 'multi_json'
# Stripe Ruby bindings
# API spec at https://stripe.com/docs/api
require "cgi"
require "json"
require "logger"
require "net/http"
require "openssl"
require "rbconfig"
require "securerandom"
require "set"
require "socket"
require "uri"
require "forwardable"
# Version
require 'stripe/version'
require "stripe/api_version"
require "stripe/version"
# API operations
require 'stripe/api_operations/create'
require 'stripe/api_operations/update'
require 'stripe/api_operations/delete'
require 'stripe/api_operations/list'
require "stripe/api_operations/create"
require "stripe/api_operations/delete"
require "stripe/api_operations/list"
require "stripe/api_operations/nested_resource"
require "stripe/api_operations/request"
require "stripe/api_operations/save"
require "stripe/api_operations/singleton_save"
require "stripe/api_operations/search"
# Resources
require 'stripe/util'
require 'stripe/json'
require 'stripe/stripe_object'
require 'stripe/api_resource'
require 'stripe/singleton_api_resource'
require 'stripe/account'
require 'stripe/customer'
require 'stripe/invoice'
require 'stripe/invoice_item'
require 'stripe/charge'
require 'stripe/plan'
require 'stripe/coupon'
require 'stripe/token'
require 'stripe/event'
require 'stripe/transfer'
# API resource support classes
require "stripe/errors"
require "stripe/object_types"
require "stripe/event_types"
require "stripe/request_options"
require "stripe/request_params"
require "stripe/util"
require "stripe/connection_manager"
require "stripe/multipart_encoder"
require "stripe/api_requestor"
require "stripe/stripe_service"
require "stripe/stripe_client"
require "stripe/stripe_object"
require "stripe/stripe_response"
require "stripe/list_object"
require "stripe/v2_list_object"
require "stripe/search_result_object"
require "stripe/error_object"
require "stripe/api_resource"
require "stripe/api_resource_test_helpers"
require "stripe/singleton_api_resource"
require "stripe/webhook"
require "stripe/stripe_configuration"
require "stripe/thin_event"
# Errors
require 'stripe/errors/stripe_error'
require 'stripe/errors/api_error'
require 'stripe/errors/api_connection_error'
require 'stripe/errors/card_error'
require 'stripe/errors/invalid_request_error'
require 'stripe/errors/authentication_error'
# Named API resources
require "stripe/resources"
require "stripe/services"
# OAuth
require "stripe/oauth"
require "stripe/services/oauth_service"
module Stripe
@@ssl_bundle_path = File.join(File.dirname(__FILE__), 'data/ca-certificates.crt')
@@api_key = nil
@@api_base = 'https://api.stripe.com/v1'
@@verify_ssl_certs = true
DEFAULT_CA_BUNDLE_PATH = __dir__ + "/data/ca-certificates.crt"
def self.api_url(url='')
@@api_base + url
# map to the same values as the standard library's logger
LEVEL_DEBUG = Logger::DEBUG
LEVEL_ERROR = Logger::ERROR
LEVEL_INFO = Logger::INFO
# API base constants
DEFAULT_API_BASE = "https://api.stripe.com"
DEFAULT_CONNECT_BASE = "https://connect.stripe.com"
DEFAULT_UPLOAD_BASE = "https://files.stripe.com"
DEFAULT_METER_EVENTS_BASE = "https://meter-events.stripe.com"
# Options that can be configured globally by users
USER_CONFIGURABLE_GLOBAL_OPTIONS = Set.new(%i[
api_key
api_version
stripe_account
api_base
uploads_base
connect_base
meter_events_base
open_timeout
read_timeout
write_timeout
proxy
verify_ssl_certs
ca_bundle_path
log_level
logger
max_network_retries
enable_telemetry
client_id
])
@app_info = nil
@config = Stripe::StripeConfiguration.setup
class << self
extend Forwardable
attr_reader :config
# User configurable options
def_delegators :@config, :api_key, :api_key=
def_delegators :@config, :api_version, :api_version=
def_delegators :@config, :stripe_account, :stripe_account=
def_delegators :@config, :api_base, :api_base=
def_delegators :@config, :uploads_base, :uploads_base=
def_delegators :@config, :connect_base, :connect_base=
def_delegators :@config, :meter_events_base, :meter_events_base=
def_delegators :@config, :open_timeout, :open_timeout=
def_delegators :@config, :read_timeout, :read_timeout=
def_delegators :@config, :write_timeout, :write_timeout=
def_delegators :@config, :proxy, :proxy=
def_delegators :@config, :verify_ssl_certs, :verify_ssl_certs=
def_delegators :@config, :ca_bundle_path, :ca_bundle_path=
def_delegators :@config, :log_level, :log_level=
def_delegators :@config, :logger, :logger=
def_delegators :@config, :max_network_retries, :max_network_retries=
def_delegators :@config, :enable_telemetry=, :enable_telemetry?
def_delegators :@config, :client_id=, :client_id
# Internal configurations
def_delegators :@config, :max_network_retry_delay
def_delegators :@config, :initial_network_retry_delay
def_delegators :@config, :ca_store
end
def self.api_key=(api_key)
@@api_key = api_key
# Gets the application for a plugin that's identified some. See
# #set_app_info.
def self.app_info
@app_info
end
def self.api_key
@@api_key
def self.app_info=(info)
@app_info = info
end
def self.api_base=(api_base)
@@api_base = api_base
end
def self.api_base
@@api_base
end
def self.verify_ssl_certs=(verify)
@@verify_ssl_certs = verify
end
def self.verify_ssl_certs
@@verify_ssl_certs
end
def self.request(method, url, api_key, params=nil, headers={})
api_key ||= @@api_key
raise AuthenticationError.new('No API key provided. (HINT: set your API key using "Stripe.api_key = <API-KEY>". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.)') unless api_key
if !verify_ssl_certs
unless @no_verify
$stderr.puts "WARNING: Running without SSL cert verification. Execute 'Stripe.verify_ssl_certs = true' to enable verification."
@no_verify = true
end
ssl_opts = { :verify_ssl => false }
elsif !Util.file_readable(@@ssl_bundle_path)
unless @no_bundle
$stderr.puts "WARNING: Running without SSL cert verification because #{@@ssl_bundle_path} isn't readable"
@no_bundle = true
end
ssl_opts = { :verify_ssl => false }
else
ssl_opts = {
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
:ssl_ca_file => @@ssl_bundle_path
}
end
uname = (@@uname ||= RUBY_PLATFORM =~ /linux|darwin/i ? `uname -a 2>/dev/null`.strip : nil)
lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
ua = {
:bindings_version => Stripe::VERSION,
:lang => 'ruby',
:lang_version => lang_version,
:platform => RUBY_PLATFORM,
:publisher => 'stripe',
:uname => uname
# Sets some basic information about the running application that's sent along
# with API requests. Useful for plugin authors to identify their plugin when
# communicating with Stripe.
#
# Takes a name and optional partner program ID, plugin URL, and version.
def self.set_app_info(name, partner_id: nil, url: nil, version: nil)
@app_info = {
name: name,
partner_id: partner_id,
url: url,
version: version,
}
params = Util.objects_to_ids(params)
url = self.api_url(url)
case method.to_s.downcase.to_sym
when :get, :head, :delete
# Make params into GET parameters
if params && params.count
query_string = Util.flatten_params(params).collect{|p| "#{p[0]}=#{p[1]}"}.join('&')
url += "?#{query_string}"
end
payload = nil
else
payload = params
end
begin
headers = { :x_stripe_client_user_agent => Stripe::JSON.dump(ua) }.merge(headers)
rescue => e
headers = {
:x_stripe_client_raw_user_agent => ua.inspect,
:error => "#{e} (#{e.class})"
}.merge(headers)
end
headers = {
:user_agent => "Stripe/v1 RubyBindings/#{Stripe::VERSION}",
:authorization => "Bearer #{api_key}"
}.merge(headers)
opts = {
:method => method,
:url => url,
:headers => headers,
:open_timeout => 30,
:payload => payload,
:timeout => 80
}.merge(ssl_opts)
begin
response = execute_request(opts)
rescue SocketError => e
self.handle_restclient_error(e)
rescue NoMethodError => e
# Work around RestClient bug
if e.message =~ /\WRequestFailed\W/
e = APIConnectionError.new('Unexpected HTTP response code')
self.handle_restclient_error(e)
else
raise
end
rescue RestClient::ExceptionWithResponse => e
if rcode = e.http_code and rbody = e.http_body
self.handle_api_error(rcode, rbody)
else
self.handle_restclient_error(e)
end
rescue RestClient::Exception, Errno::ECONNREFUSED => e
self.handle_restclient_error(e)
end
rbody = response.body
rcode = response.code
begin
# Would use :symbolize_names => true, but apparently there is
# some library out there that makes symbolize_names not work.
resp = Stripe::JSON.load(rbody)
rescue MultiJson::DecodeError
raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})", rcode, rbody)
end
resp = Util.symbolize_names(resp)
[resp, api_key]
end
private
def self.execute_request(opts)
RestClient::Request.execute(opts)
end
def self.handle_api_error(rcode, rbody)
begin
error_obj = Stripe::JSON.load(rbody)
error_obj = Util.symbolize_names(error_obj)
error = error_obj[:error] or raise StripeError.new # escape from parsing
rescue MultiJson::DecodeError, StripeError
raise APIError.new("Invalid response object from API: #{rbody.inspect} (HTTP response code was #{rcode})", rcode, rbody)
end
case rcode
when 400, 404 then
raise invalid_request_error(error, rcode, rbody, error_obj)
when 401
raise authentication_error(error, rcode, rbody, error_obj)
when 402
raise card_error(error, rcode, rbody, error_obj)
else
raise api_error(error, rcode, rbody, error_obj)
end
end
def self.invalid_request_error(error, rcode, rbody, error_obj)
InvalidRequestError.new(error[:message], error[:param], rcode, rbody, error_obj)
end
def self.authentication_error(error, rcode, rbody, error_obj)
AuthenticationError.new(error[:message], rcode, rbody, error_obj)
end
def self.card_error(error, rcode, rbody, error_obj)
CardError.new(error[:message], error[:param], error[:code], rcode, rbody, error_obj)
end
def self.api_error(error, rcode, rbody, error_obj)
APIError.new(error[:message], rcode, rbody, error_obj)
end
def self.handle_restclient_error(e)
case e
when RestClient::ServerBrokeConnection, RestClient::RequestTimeout
message = "Could not connect to Stripe (#{@@api_base}). Please check your internet connection and try again. If this problem persists, you should check Stripe's service status at https://twitter.com/stripestatus, or let us know at support@stripe.com."
when RestClient::SSLCertificateNotVerified
message = "Could not verify Stripe's SSL certificate. Please make sure that your network is not intercepting certificates. (Try going to https://api.stripe.com/v1 in your browser.) If this problem persists, let us know at support@stripe.com."
when SocketError
message = "Unexpected error communicating when trying to connect to Stripe. HINT: You may be seeing this message because your DNS is not working. To check, try running 'host stripe.com' from the command line."
else
message = "Unexpected error communicating with Stripe. If this problem persists, let us know at support@stripe.com."
end
message += "\n\n(Network error: #{e.message})"
raise APIConnectionError.new(message)
end
end
Stripe.log_level = ENV["STRIPE_LOG"] unless ENV["STRIPE_LOG"].nil?

View File

@ -1,4 +0,0 @@
module Stripe
class Account < SingletonAPIResource
end
end

View File

@ -1,15 +1,15 @@
# frozen_string_literal: true
module Stripe
module APIOperations
module Create
module ClassMethods
def create(params={}, api_key=nil)
response, api_key = Stripe.request(:post, self.url, api_key, params)
Util.convert_to_stripe_object(response, api_key)
end
end
def self.included(base)
base.extend(ClassMethods)
def create(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url,
params: params,
opts: opts
)
end
end
end

View File

@ -1,10 +1,43 @@
# frozen_string_literal: true
module Stripe
module APIOperations
module Delete
def delete
response, api_key = Stripe.request(:delete, url, @api_key)
refresh_from(response, api_key)
self
module ClassMethods
# Deletes an API resource
#
# Deletes the identified resource with the passed in parameters.
#
# ==== Attributes
#
# * +id+ - ID of the resource to delete.
# * +params+ - A hash of parameters to pass to the API
# * +opts+ - A Hash of additional options (separate from the params /
# object values) to be added to the request. E.g. to allow for an
# idempotency_key to be passed in the request headers, or for the
# api_key to be overwritten. See
# {APIOperations::Request.execute_resource_request}.
def delete(id, params = {}, opts = {})
request_stripe_object(
method: :delete,
path: "#{resource_url}/#{id}",
params: params,
opts: opts
)
end
end
def delete(params = {}, opts = {})
request_stripe_object(
method: :delete,
path: resource_url,
params: params,
opts: opts
)
end
def self.included(base)
base.extend(ClassMethods)
end
end
end

View File

@ -1,15 +1,15 @@
# frozen_string_literal: true
module Stripe
module APIOperations
module List
module ClassMethods
def all(filters={}, api_key=nil)
response, api_key = Stripe.request(:get, url, api_key, filters)
Util.convert_to_stripe_object(response, api_key)
end
end
def self.included(base)
base.extend(ClassMethods)
def list(filters = {}, opts = {})
request_stripe_object(
method: :get,
path: resource_url,
params: filters,
opts: opts
)
end
end
end

View File

@ -0,0 +1,101 @@
# frozen_string_literal: true
module Stripe
module APIOperations
# Adds methods to help manipulate a subresource from its parent resource so
# that it's possible to do so from a static context (i.e. without a
# pre-existing collection of subresources on the parent).
#
# For example, a transfer gains the static methods for reversals so that the
# methods `.create_reversal`, `.retrieve_reversal`, `.update_reversal`,
# etc. all become available.
module NestedResource
def nested_resource_class_methods(resource, path: nil, operations: nil,
resource_plural: nil)
resource_plural ||= "#{resource}s"
path ||= resource_plural
raise ArgumentError, "operations array required" if operations.nil?
resource_url_method = :"#{resource}s_url"
define_singleton_method(resource_url_method) do |id, nested_id = nil|
url = "#{resource_url}/#{CGI.escape(id)}/#{CGI.escape(path)}"
url += "/#{CGI.escape(nested_id)}" unless nested_id.nil?
url
end
operations.each do |operation|
define_operation(
resource,
operation,
resource_url_method,
resource_plural
)
end
end
private def define_operation(
resource,
operation,
resource_url_method,
resource_plural
)
case operation
when :create
define_singleton_method(:"create_#{resource}") \
do |id, params = {}, opts = {}|
request_stripe_object(
method: :post,
path: send(resource_url_method, id),
params: params,
opts: opts
)
end
when :retrieve
define_singleton_method(:"retrieve_#{resource}") \
do |id, nested_id, params = {}, opts = {}|
request_stripe_object(
method: :get,
path: send(resource_url_method, id, nested_id),
params: params,
opts: opts
)
end
when :update
define_singleton_method(:"update_#{resource}") \
do |id, nested_id, params = {}, opts = {}|
request_stripe_object(
method: :post,
path: send(resource_url_method, id, nested_id),
params: params,
opts: opts
)
end
when :delete
define_singleton_method(:"delete_#{resource}") \
do |id, nested_id, params = {}, opts = {}|
request_stripe_object(
method: :delete,
path: send(resource_url_method, id, nested_id),
params: params,
opts: opts
)
end
when :list
define_singleton_method(:"list_#{resource_plural}") \
do |id, params = {}, opts = {}|
request_stripe_object(
method: :get,
path: send(resource_url_method, id),
params: params,
opts: opts
)
end
else
raise ArgumentError, "Unknown operation: #{operation.inspect}"
end
end
end
end
end

View File

@ -0,0 +1,94 @@
# frozen_string_literal: true
module Stripe
module APIOperations
module Request
module ClassMethods
def execute_resource_request(method, url, base_address = :api,
params = {}, opts = {}, usage = [])
execute_resource_request_internal(
:execute_request, method, url, base_address, params, opts, usage
)
end
def execute_resource_request_stream(method, url, base_address = :api,
params = {}, opts = {}, usage = [],
&read_body_chunk_block)
execute_resource_request_internal(
:execute_request_stream,
method,
url,
base_address,
params,
opts,
usage,
&read_body_chunk_block
)
end
private def request_stripe_object(method:, path:, base_address: :api, params: {}, opts: {}, usage: [])
execute_resource_request(method, path, base_address, params, opts, usage)
end
private def execute_resource_request_internal(client_request_method_sym,
method, url, base_address,
params, opts, usage,
&read_body_chunk_block)
params = params.to_h if params.is_a?(Stripe::RequestParams)
params ||= {}
error_on_invalid_params(params)
warn_on_opts_in_params(params)
opts = Util.normalize_opts(opts)
req_opts = RequestOptions.extract_opts_from_hash(opts)
APIRequestor.active_requestor.send(
client_request_method_sym,
method, url,
base_address,
params: params, opts: req_opts, usage: usage,
&read_body_chunk_block
)
end
private def error_on_invalid_params(params)
return if params.nil? || params.is_a?(Hash)
raise ArgumentError,
"request params should be either a Hash or nil " \
"(was a #{params.class})"
end
private def warn_on_opts_in_params(params)
RequestOptions::OPTS_USER_SPECIFIED.each do |opt|
warn("WARNING: '#{opt}' should be in opts instead of params.") if params.key?(opt)
end
end
end
def self.included(base)
base.extend(ClassMethods)
end
protected def execute_resource_request(method, url, base_address = :api,
params = {}, opts = {}, usage = [])
opts = @opts.merge(Util.normalize_opts(opts))
self.class.execute_resource_request(method, url, base_address, params, opts, usage)
end
protected def execute_resource_request_stream(method, url, base_address = :api,
params = {}, opts = {}, usage = [],
&read_body_chunk_block)
opts = @opts.merge(Util.normalize_opts(opts))
self.class.execute_resource_request_stream(
method, url, base_address, params, opts, usage, &read_body_chunk_block
)
end
private def request_stripe_object(method:, path:, params:, base_address: :api, opts: {}, usage: [])
execute_resource_request(method, path, base_address, params, opts, usage)
end
end
end
end

View File

@ -0,0 +1,107 @@
# frozen_string_literal: true
module Stripe
module APIOperations
module Save
module ClassMethods
# Updates an API resource
#
# Updates the identified resource with the passed in parameters.
#
# ==== Attributes
#
# * +id+ - ID of the resource to update.
# * +params+ - A hash of parameters to pass to the API
# * +opts+ - A Hash of additional options (separate from the params /
# object values) to be added to the request. E.g. to allow for an
# idempotency_key to be passed in the request headers, or for the
# api_key to be overwritten. See
# {APIOperations::Request.execute_resource_request}.
def update(id, params = {}, opts = {})
params.each_key do |k|
raise ArgumentError, "Cannot update protected field: #{k}" if protected_fields.include?(k)
end
request_stripe_object(
method: :post,
path: "#{resource_url}/#{id}",
params: params,
opts: opts
)
end
end
# The `save` method is DEPRECATED and will be removed in a future major
# version of the library. Use the `update` method on the resource instead.
#
# Creates or updates an API resource.
#
# If the resource doesn't yet have an assigned ID and the resource is one
# that can be created, then the method attempts to create the resource.
# The resource is updated otherwise.
#
# ==== Attributes
#
# * +params+ - Overrides any parameters in the resource's serialized data
# and includes them in the create or update. If +:req_url:+ is included
# in the list, it overrides the update URL used for the create or
# update.
# * +opts+ - A Hash of additional options (separate from the params /
# object values) to be added to the request. E.g. to allow for an
# idempotency_key to be passed in the request headers, or for the
# api_key to be overwritten. See
# {APIOperations::Request.execute_resource_request}.
def save(params = {}, opts = {})
# We started unintentionally (sort of) allowing attributes sent to
# +save+ to override values used during the update. So as not to break
# the API, this makes that official here.
update_attributes(params)
# Now remove any parameters that look like object attributes.
params = params.reject { |k, _| respond_to?(k) }
values = serialize_params(self).merge(params)
# Please note that id gets removed here our call to #url above has already
# generated a uri for this object with an identifier baked in
values.delete(:id)
opts = Util.normalize_opts(opts)
APIRequestor.active_requestor.execute_request_initialize_from(:post, save_url, :api, self,
params: values,
opts: RequestOptions.extract_opts_from_hash(opts),
usage: ["save"])
end
extend Gem::Deprecate
deprecate :save, "the `update` class method (for examples " \
"see https://github.com/stripe/stripe-ruby" \
"/wiki/Migration-guide-for-v8)", 2022, 11
def self.included(base)
# Set `metadata` as additive so that when it's set directly we remember
# to clear keys that may have been previously set by sending empty
# values for them.
#
# It's possible that not every object with `Save` has `metadata`, but
# it's a close enough heuristic, and having this option set when there
# is no `metadata` field is not harmful.
base.additive_object_param(:metadata)
base.extend(ClassMethods)
end
private def save_url
# This switch essentially allows us "upsert"-like functionality. If the
# API resource doesn't have an ID set (suggesting that it's new) and
# its class responds to .create (which comes from
# Stripe::APIOperations::Create), then use the URL to create a new
# resource. Otherwise, generate a URL based on the object's identifier
# for a normal update.
if self[:id].nil? && self.class.respond_to?(:create)
self.class.resource_url
else
resource_url
end
end
end
end
end

View File

@ -0,0 +1,21 @@
# frozen_string_literal: true
module Stripe
module APIOperations
# The _search method via API Operations is deprecated.
# Please use the search method from within the resource instead.
module Search
def _search(search_url, filters = {}, opts = {})
request_stripe_object(
method: :get,
path: search_url,
params: filters,
opts: opts
)
end
extend Gem::Deprecate
deprecate :_search, "request_stripe_object", 2024, 1
end
end
end

View File

@ -0,0 +1,90 @@
# frozen_string_literal: true
module Stripe
module APIOperations
module SingletonSave
module ClassMethods
# Updates a singleton API resource
#
# Updates the identified resource with the passed in parameters.
#
# ==== Attributes
#
# * +params+ - A hash of parameters to pass to the API
# * +opts+ - A Hash of additional options (separate from the params /
# object values) to be added to the request. E.g. to allow for an
# idempotency_key to be passed in the request headers, or for the
# api_key to be overwritten. See
# {APIOperations::Request.execute_resource_request}.
def update(params = {}, opts = {})
params.each_key do |k|
raise ArgumentError, "Cannot update protected field: #{k}" if protected_fields.include?(k)
end
request_stripe_object(
method: :post,
path: resource_url,
params: params,
opts: opts
)
end
end
# The `save` method is DEPRECATED and will be removed in a future major
# version of the library. Use the `update` method on the resource instead.
#
# Updates a singleton API resource.
#
# If the resource doesn't yet have an assigned ID and the resource is one
# that can be created, then the method attempts to create the resource.
# The resource is updated otherwise.
#
# ==== Attributes
#
# * +params+ - Overrides any parameters in the resource's serialized data
# and includes them in the create or update. If +:req_url:+ is included
# in the list, it overrides the update URL used for the create or
# update.
# * +opts+ - A Hash of additional options (separate from the params /
# object values) to be added to the request. E.g. to allow for an
# idempotency_key to be passed in the request headers, or for the
# api_key to be overwritten. See
# {APIOperations::Request.execute_resource_request}.
def save(params = {}, opts = {})
# We started unintentionally (sort of) allowing attributes sent to
# +save+ to override values used during the update. So as not to break
# the API, this makes that official here.
update_attributes(params)
# Now remove any parameters that look like object attributes.
params = params.reject { |k, _| respond_to?(k) }
values = serialize_params(self).merge(params)
opts = Util.normalize_opts(opts)
APIRequestor.active_requestor.execute_request_initialize_from(:post, resource_url, :api, self,
params: values,
opts: RequestOptions.extract_opts_from_hash(opts),
usage: ["save"])
end
extend Gem::Deprecate
deprecate :save, "the `update` class method (for examples " \
"see https://github.com/stripe/stripe-ruby" \
"/wiki/Migration-guide-for-v8)", 2022, 11
def self.included(base)
# Set `metadata` as additive so that when it's set directly we remember
# to clear keys that may have been previously set by sending empty
# values for them.
#
# It's possible that not every object with `Save` has `metadata`, but
# it's a close enough heuristic, and having this option set when there
# is no `metadata` field is not harmful.
base.additive_object_param(:metadata)
base.extend(ClassMethods)
end
end
end
end

View File

@ -1,15 +0,0 @@
module Stripe
module APIOperations
module Update
def save
if @unsaved_values.length > 0
values = {}
@unsaved_values.each { |k| values[k] = @values[k] }
response, api_key = Stripe.request(:post, url, @api_key, values)
refresh_from(response, api_key)
end
self
end
end
end
end

1136
lib/stripe/api_requestor.rb Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,142 @@
# frozen_string_literal: true
module Stripe
class APIResource < StripeObject
include Stripe::APIOperations::Request
# A flag that can be set a behavior that will cause this resource to be
# encoded and sent up along with an update of its parent resource. This is
# usually not desirable because resources are updated individually on their
# own endpoints, but there are certain cases, replacing a customer's source
# for example, where this is allowed.
attr_accessor :save_with_parent
# TODO: (major) Remove OBJECT_NAME and stop using const_get here
# This is a workaround to avoid breaking users who have defined their own
# APIResource subclasses with a custom OBJECT_NAME. We should never fallback
# on this case otherwise.
OBJECT_NAME = ""
def self.object_name
const_get(:OBJECT_NAME)
end
def self.class_name
self.name.split('::')[-1]
name.split("::")[-1]
end
def self.url()
def self.resource_url
if name.include?("Stripe::V2")
raise NotImplementedError,
"V2 resources do not have a defined URL. Please use the StripeClient " \
"to make V2 requests"
end
if self == APIResource
raise NotImplementedError.new('APIResource is an abstract class. You should perform actions on its subclasses (Charge, Customer, etc.)')
raise NotImplementedError,
"APIResource is an abstract class. You should perform actions " \
"on its subclasses (Charge, Customer, etc.)"
end
"/#{CGI.escape(class_name.downcase)}s"
# Namespaces are separated in object names with periods (.) and in URLs
# with forward slashes (/), so replace the former with the latter.
"/v1/#{object_name.downcase.tr('.', '/')}s"
end
def url
unless id = self['id']
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", 'id')
# A metaprogramming call that specifies that a field of a resource can be
# its own type of API resource (say a nested card under an account for
# example), and if that resource is set, it should be transmitted to the
# API on a create or update. Doing so is not the default behavior because
# API resources should normally be persisted on their own RESTful
# endpoints.
def self.save_nested_resource(name)
define_method(:"#{name}=") do |value|
super(value)
# The parent setter will perform certain useful operations like
# converting to an APIResource if appropriate. Refresh our argument
# value to whatever it mutated to.
value = send(name)
# Note that the value may be subresource, but could also be a scalar
# (like a tokenized card's ID for example), so we check the type before
# setting #save_with_parent here.
value.save_with_parent = true if value.is_a?(APIResource)
value
end
"#{self.class.url}/#{CGI.escape(id)}"
end
# Adds a custom method to a resource class. This is used to add support for
# non-CRUDL API requests, e.g. capturing charges. custom_method takes the
# following parameters:
# - name: the name of the custom method to create (as a symbol)
# - http_verb: the HTTP verb for the API request (:get, :post, or :delete)
# - http_path: the path to append to the resource's URL. If not provided,
# the name is used as the path
#
# For example, this call:
# custom_method :capture, http_verb: post
# adds a `capture` class method to the resource class that, when called,
# will send a POST request to `/v1/<object_name>/capture`.
def self.custom_method(name, http_verb:, http_path: nil)
Util.custom_method self, self, name, http_verb, http_path
end
def resource_url
unless (id = self["id"])
raise InvalidRequestError.new(
"Could not determine which URL to request: #{self.class} instance " \
"has invalid ID: #{id.inspect}",
"id"
)
end
"#{self.class.resource_url}/#{CGI.escape(id)}"
end
def refresh
response, api_key = Stripe.request(:get, url, @api_key)
refresh_from(response, api_key)
self
if self.class.name.include?("Stripe::V2")
raise NotImplementedError,
"It is not possible to refresh v2 objects. Please retrieve the object using the StripeClient instead."
end
opts = RequestOptions.extract_opts_from_hash(@retrieve_opts || {})
@retrieve_opts = {} # Make sure to clear the retrieve options
@obj = @requestor.execute_request_initialize_from(:get, resource_url, :api, self, params: @retrieve_params,
opts: opts)
initialize_from(
@obj.last_response.data,
@obj.instance_variable_get(:@opts),
@obj.last_response,
api_mode: :v1,
requestor: @requestor
)
end
def self.retrieve(id, api_key=nil)
instance = self.new(id, api_key)
def self.retrieve(id, opts = {})
if name.include?("Stripe::V2")
raise NotImplementedError,
"It is not possible to retrieve v2 objects on the resource. Please use the StripeClient instead."
end
instance = new(id)
# Explicitly send options for the retrieve call, to preserve custom headers
# This is so we can pass custom headers from this static function
# to the instance variable method call
# The custom headers will be cleaned up with the rest of the RequestOptions
instance.instance_variable_set(:@retrieve_opts, Util.normalize_opts(opts))
instance.refresh
instance
end
def request_stripe_object(method:, path:, params:, base_address: :api, opts: {})
APIRequestor.active_requestor.execute_request_initialize_from(method, path, base_address, self,
params: params, opts: opts)
end
protected def request_stream(method:, path:, params:, base_address: :api, opts: {},
&read_body_chunk_block)
resp, = execute_resource_request_stream(
method, path, base_address, params, opts, &read_body_chunk_block
)
resp
end
end
end

View File

@ -0,0 +1,53 @@
# frozen_string_literal: true
module Stripe
# The base class for nested TestHelpers classes in resource objects.
# The APIResourceTestHelpers handles URL generation and custom method
# support for test-helper methods.
#
# class MyAPIResource < APIResource
# class TestHelpers < APIResourceTestHelpers
class APIResourceTestHelpers
include Stripe::APIOperations::Request
def initialize(resource)
@resource = resource
end
def self.resource_class
nil
end
# Adds a custom method to a test helper. This is used to add support for
# non-CRUDL API requests, e.g. capturing charges. custom_method takes the
# following parameters:
# - name: the name of the custom method to create (as a symbol)
# - http_verb: the HTTP verb for the API request (:get, :post, or :delete)
# - http_path: the path to append to the resource's URL. If not provided,
# the name is used as the path
#
# For example, this call:
# custom_method :capture, http_verb: post
# adds a `capture` class method to the resource class that, when called,
# will send a POST request to `/v1/<object_name>/capture`.
def self.custom_method(name, http_verb:, http_path: nil)
Util.custom_method resource_class, self, name, http_verb, http_path
end
def self.resource_url
"/v1/test_helpers/" \
"#{resource_class.object_name.downcase.tr('.', '/')}s"
end
def resource_url
unless (id = @resource["id"])
raise InvalidRequestError.new(
"Could not determine which URL to request: #{self.class} instance " \
"has invalid ID: #{id.inspect}",
"id"
)
end
"#{self.class.resource_url}/#{CGI.escape(id)}"
end
end
end

View File

@ -0,0 +1,8 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
module ApiVersion
CURRENT = "2025-05-28.basil"
end
end

View File

@ -1,29 +0,0 @@
module Stripe
class Charge < APIResource
include Stripe::APIOperations::List
include Stripe::APIOperations::Create
include Stripe::APIOperations::Update
def refund(params={})
response, api_key = Stripe.request(:post, refund_url, @api_key, params)
refresh_from(response, api_key)
self
end
def capture(params={})
response, api_key = Stripe.request(:post, capture_url, @api_key, params)
refresh_from(response, api_key)
self
end
private
def refund_url
url + '/refund'
end
def capture_url
url + '/capture'
end
end
end

View File

@ -0,0 +1,196 @@
# frozen_string_literal: true
module Stripe
# Manages connections across multiple hosts which is useful because the
# library may connect to multiple hosts during a typical session (main API,
# Connect, Uploads). Ruby doesn't provide an easy way to make this happen
# easily, so this class is designed to track what we're connected to and
# manage the lifecycle of those connections.
#
# Note that this class in itself is *not* thread safe. We expect it to be
# instantiated once per thread.
class ConnectionManager
# Timestamp (in seconds procured from the system's monotonic clock)
# indicating when the connection manager last made a request. This is used
# by `APIRequestor` to determine whether a connection manager should be
# garbage collected or not.
attr_reader :last_used
attr_reader :config
def initialize(config = Stripe.config)
@config = config
@active_connections = {}
@last_used = Util.monotonic_time
# A connection manager may be accessed across threads as one thread makes
# requests on it while another is trying to clear it (either because it's
# trying to garbage collect the manager or trying to clear it because a
# configuration setting has changed). That's probably thread-safe already
# because of Ruby's GIL, but just in case the library's running on JRuby
# or the like, use a mutex to synchronize access in this connection
# manager.
@mutex = Mutex.new
end
# Finishes any active connections by closing their TCP connection and
# clears them from internal tracking.
def clear
@mutex.synchronize do
@active_connections.each_value(&:finish)
@active_connections = {}
end
end
# Gets a connection for a given URI. This is for internal use only as it's
# subject to change (we've moved between HTTP client schemes in the past
# and may do it again).
#
# `uri` is expected to be a string.
def connection_for(uri)
@mutex.synchronize do
u = URI.parse(uri)
connection = @active_connections[[u.host, u.port]]
if connection.nil?
connection = create_connection(u)
connection.start
@active_connections[[u.host, u.port]] = connection
end
connection
end
end
# Executes an HTTP request to the given URI with the given method. Also
# allows a request body, headers, and query string to be specified.
def execute_request(method, uri, body: nil, headers: nil, query: nil,
&block)
# Perform some basic argument validation because it's easy to get
# confused between strings and hashes for things like body and query
# parameters.
raise ArgumentError, "method should be a symbol" \
unless method.is_a?(Symbol)
raise ArgumentError, "uri should be a string" \
unless uri.is_a?(String)
raise ArgumentError, "body should be a string" \
if body && !body.is_a?(String)
raise ArgumentError, "headers should be a hash" \
if headers && !headers.is_a?(Hash)
raise ArgumentError, "query should be a string" \
if query && !query.is_a?(String)
@last_used = Util.monotonic_time
connection = connection_for(uri)
u = URI.parse(uri)
path = if query
u.path + "?" + query
else
u.path
end
method_name = method.to_s.upcase
has_response_body = method_name != "HEAD"
request = Net::HTTPGenericRequest.new(
method_name,
(body ? true : false),
has_response_body,
path,
headers
)
Util.log_debug("ConnectionManager starting request",
method_name: method_name,
path: path,
process_id: Process.pid,
thread_object_id: Thread.current.object_id,
connection_manager_object_id: object_id,
connection_object_id: connection.object_id,
log_timestamp: Util.monotonic_time)
resp = @mutex.synchronize do
# The block parameter is special here. If a block is provided, the block
# is invoked with the Net::HTTPResponse. However, the body will not have
# been read yet in the block, and can be streamed by calling
# HTTPResponse#read_body.
connection.request(request, body, &block)
end
Util.log_debug("ConnectionManager request complete",
method_name: method_name,
path: path,
process_id: Process.pid,
thread_object_id: Thread.current.object_id,
connection_manager_object_id: object_id,
connection_object_id: connection.object_id,
response_object_id: resp.object_id,
log_timestamp: Util.monotonic_time)
resp
end
#
# private
#
# `uri` should be a parsed `URI` object.
private def create_connection(uri)
# These all come back as `nil` if no proxy is configured.
proxy_host, proxy_port, proxy_user, proxy_pass = proxy_parts
connection = Net::HTTP.new(uri.host, uri.port,
proxy_host, proxy_port,
proxy_user, proxy_pass)
# Time in seconds within which Net::HTTP will try to reuse an already
# open connection when issuing a new operation. Outside this window, Ruby
# will transparently close and re-open the connection without trying to
# reuse it.
#
# Ruby's default of 2 seconds is almost certainly too short. Here I've
# reused Go's default for `DefaultTransport`.
connection.keep_alive_timeout = 30
connection.open_timeout = config.open_timeout
connection.read_timeout = config.read_timeout
connection.write_timeout = config.write_timeout if connection.respond_to?(:write_timeout=)
connection.use_ssl = uri.scheme == "https"
if config.verify_ssl_certs
connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
connection.cert_store = config.ca_store
else
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
warn_ssl_verify_none
end
connection
end
# `Net::HTTP` somewhat awkwardly requires each component of a proxy URI
# (host, port, etc.) rather than the URI itself. This method simply parses
# out those pieces to make passing them into a new connection a little less
# ugly.
private def proxy_parts
if config.proxy.nil?
[nil, nil, nil, nil]
else
u = URI.parse(config.proxy)
[u.host, u.port, u.user, u.password]
end
end
private def warn_ssl_verify_none
return if @verify_ssl_warned
@verify_ssl_warned = true
warn("WARNING: Running without SSL cert verification. " \
"You should never do this in production. " \
"Execute `Stripe.verify_ssl_certs = true` to enable " \
"verification.")
end
end
end

View File

@ -1,7 +0,0 @@
module Stripe
class Coupon < APIResource
include Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
include Stripe::APIOperations::List
end
end

View File

@ -1,51 +0,0 @@
module Stripe
class Customer < APIResource
include Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
include Stripe::APIOperations::Update
include Stripe::APIOperations::List
def add_invoice_item(params)
InvoiceItem.create(params.merge(:customer => id), @api_key)
end
def invoices
Invoice.all({ :customer => id }, @api_key)
end
def invoice_items
InvoiceItem.all({ :customer => id }, @api_key)
end
def charges
Charge.all({ :customer => id }, @api_key)
end
def cancel_subscription(params={})
response, api_key = Stripe.request(:delete, subscription_url, @api_key, params)
refresh_from({ :subscription => response }, api_key, true)
subscription
end
def update_subscription(params)
response, api_key = Stripe.request(:post, subscription_url, @api_key, params)
refresh_from({ :subscription => response }, api_key, true)
subscription
end
def delete_discount
Stripe.request(:delete, discount_url, @api_key)
refresh_from({ :discount => nil }, api_key, true)
end
private
def discount_url
url + '/discount'
end
def subscription_url
url + '/subscription'
end
end
end

View File

@ -0,0 +1,93 @@
# frozen_string_literal: true
module Stripe
# Represents an error object as returned by the API.
#
# @see https://stripe.com/docs/api/errors
class ErrorObject < StripeObject
# Unlike other objects, we explicitly declare getter methods here. This
# is because the API doesn't return `null` values for fields on this
# object, rather the fields are omitted entirely. Not declaring the getter
# methods would cause users to run into `NoMethodError` exceptions and
# get in the way of generic error handling.
# For card errors, the ID of the failed charge.
def charge
@values[:charge]
end
# For some errors that could be handled programmatically, a short string
# indicating the error code reported.
def code
@values[:code]
end
# For card errors resulting from a card issuer decline, a short string
# indicating the card issuer's reason for the decline if they provide one.
def decline_code
@values[:decline_code]
end
# A URL to more information about the error code reported.
def doc_url
@values[:doc_url]
end
# A human-readable message providing more details about the error. For card
# errors, these messages can be shown to your users.
def message
@values[:message]
end
# If the error is parameter-specific, the parameter related to the error.
# For example, you can use this to display a message near the correct form
# field.
def param
@values[:param]
end
# The PaymentIntent object for errors returned on a request involving a
# PaymentIntent.
def payment_intent
@values[:payment_intent]
end
# The PaymentMethod object for errors returned on a request involving a
# PaymentMethod.
def payment_method
@values[:payment_method]
end
# The SetupIntent object for errors returned on a request involving a
# SetupIntent.
def setup_intent
@values[:setup_intent]
end
# The source object for errors returned on a request involving a source.
def source
@values[:source]
end
# The type of error returned. One of `api_error`, `card_error`,
# `idempotency_error`, or `invalid_request_error`.
def type
@values[:type]
end
end
# Represents on OAuth error returned by the OAuth API.
#
# @see https://stripe.com/docs/connect/oauth-reference#post-token-errors
class OAuthErrorObject < StripeObject
# A unique error code per error type.
def error
@values[:error]
end
# A human readable description of the error.
def error_description
@values[:error_description]
end
end
end

168
lib/stripe/errors.rb Normal file
View File

@ -0,0 +1,168 @@
# frozen_string_literal: true
module Stripe
# StripeError is the base error from which all other more specific Stripe
# errors derive.
class StripeError < StandardError
attr_reader :message, :code, :error, :http_body, :http_headers, :http_status, :json_body, :request_id
# Response contains a StripeResponse object that has some basic information
# about the response that conveyed the error.
attr_accessor :response # equivalent to #data
# Initializes a StripeError.
def initialize(message = nil, http_status: nil, http_body: nil, # rubocop:todo Lint/MissingSuper
json_body: nil, http_headers: nil, code: nil)
@message = message
@http_status = http_status
@http_body = http_body
@http_headers = http_headers || {}
@idempotent_replayed = @http_headers["idempotent-replayed"] == "true"
@json_body = json_body
@code = code
@request_id = @http_headers["request-id"]
@error = construct_error_object
end
def construct_error_object
return nil if @json_body.nil? || !@json_body.key?(:error)
# ErrorObject is shared between v1 and v2, so use original object_classes to find
ErrorObject.construct_from(@json_body[:error], {}, nil, :v1)
end
def to_s
status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
id_string = @request_id.nil? ? "" : "(Request #{@request_id}) "
"#{status_string}#{id_string}#{@message}"
end
end
# AuthenticationError is raised when invalid credentials are used to connect
# to Stripe's servers.
class AuthenticationError < StripeError
end
# APIConnectionError is raised in the event that the SDK can't connect to
# Stripe's servers. That can be for a variety of different reasons from a
# downed network to a bad TLS certificate.
class APIConnectionError < StripeError
end
# APIError is a generic error that may be raised in cases where none of the
# other named errors cover the problem. It could also be raised in the case
# that a new error has been introduced in the API, but this version of the
# Ruby SDK doesn't know how to handle it.
class APIError < StripeError
end
# CardError is raised when a user enters a card that can't be charged for
# some reason.
class CardError < StripeError
attr_reader :param
def initialize(message, param, code: nil, http_status: nil, http_body: nil,
json_body: nil, http_headers: nil)
super(message, http_status: http_status, http_body: http_body,
json_body: json_body, http_headers: http_headers,
code: code)
@param = param
end
end
# IdempotencyError is raised in cases where an idempotency key was used
# improperly.
class IdempotencyError < StripeError
end
# InvalidRequestError is raised when a request is initiated with invalid
# parameters.
class InvalidRequestError < StripeError
attr_accessor :param
def initialize(message, param, http_status: nil, http_body: nil,
json_body: nil, http_headers: nil, code: nil)
super(message, http_status: http_status, http_body: http_body,
json_body: json_body, http_headers: http_headers,
code: code)
@param = param
end
end
# PermissionError is raised in cases where access was attempted on a resource
# that wasn't allowed.
class PermissionError < StripeError
end
# RateLimitError is raised in cases where an account is putting too much load
# on Stripe's API servers (usually by performing too many requests). Please
# back off on request rate.
class RateLimitError < StripeError
end
# SignatureVerificationError is raised when the signature verification for a
# webhook fails
class SignatureVerificationError < StripeError
attr_accessor :sig_header
def initialize(message, sig_header, http_body: nil)
super(message, http_body: http_body)
@sig_header = sig_header
end
end
module OAuth
# OAuthError is raised when the OAuth API returns an error.
class OAuthError < StripeError
def initialize(code, description, http_status: nil, http_body: nil,
json_body: nil, http_headers: nil)
super(description, http_status: http_status, http_body: http_body,
json_body: json_body, http_headers: http_headers,
code: code)
end
def construct_error_object
return nil if @json_body.nil?
OAuthErrorObject.construct_from(@json_body, {}, nil, :v1)
end
end
# InvalidClientError is raised when the client doesn't belong to you, or
# the API key mode (live or test) doesn't match the client mode. Or the
# stripe_user_id doesn't exist or isn't connected to your application.
class InvalidClientError < OAuthError
end
# InvalidGrantError is raised when a specified code doesn't exist, is
# expired, has been used, or doesn't belong to you; a refresh token doesn't
# exist, or doesn't belong to you; or if an API key's mode (live or test)
# doesn't match the mode of a code or refresh token.
class InvalidGrantError < OAuthError
end
# InvalidRequestError is raised when a code, refresh token, or grant type
# parameter is not provided, but was required.
class InvalidRequestError < OAuthError
end
# InvalidScopeError is raised when an invalid scope parameter is provided.
class InvalidScopeError < OAuthError
end
# UnsupportedGrantTypeError is raised when an unuspported grant type
# parameter is specified.
class UnsupportedGrantTypeError < OAuthError
end
# UnsupportedResponseTypeError is raised when an unsupported response type
# parameter is specified.
class UnsupportedResponseTypeError < OAuthError
end
end
# class definitions: The beginning of the section generated from our OpenAPI spec
class TemporarySessionExpiredError < StripeError
end
# class definitions: The end of the section generated from our OpenAPI spec
end

View File

@ -1,4 +0,0 @@
module Stripe
class APIConnectionError < StripeError
end
end

View File

@ -1,4 +0,0 @@
module Stripe
class APIError < StripeError
end
end

View File

@ -1,4 +0,0 @@
module Stripe
class AuthenticationError < StripeError
end
end

View File

@ -1,11 +0,0 @@
module Stripe
class CardError < StripeError
attr_reader :param, :code
def initialize(message, param, code, http_status=nil, http_body=nil, json_body=nil)
super(message, http_status, http_body, json_body)
@param = param
@code = code
end
end
end

View File

@ -1,10 +0,0 @@
module Stripe
class InvalidRequestError < StripeError
attr_accessor :param
def initialize(message, param, http_status=nil, http_body=nil, json_body=nil)
super(message, http_status, http_body, json_body)
@param = param
end
end
end

View File

@ -1,20 +0,0 @@
module Stripe
class StripeError < StandardError
attr_reader :message
attr_reader :http_status
attr_reader :http_body
attr_reader :json_body
def initialize(message=nil, http_status=nil, http_body=nil, json_body=nil)
@message = message
@http_status = http_status
@http_body = http_body
@json_body = json_body
end
def to_s
status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
"#{status_string}#{@message}"
end
end
end

View File

@ -1,5 +0,0 @@
module Stripe
class Event < APIResource
include Stripe::APIOperations::List
end
end

15
lib/stripe/event_types.rb Normal file
View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
module Stripe
module EventTypes
def self.thin_event_names_to_classes
{
# The beginning of the section generated from our OpenAPI spec
V1BillingMeterErrorReportTriggeredEvent.lookup_type => V1BillingMeterErrorReportTriggeredEvent,
V1BillingMeterNoMeterFoundEvent.lookup_type => V1BillingMeterNoMeterFoundEvent,
V2CoreEventDestinationPingEvent.lookup_type => V2CoreEventDestinationPingEvent,
# The end of the section generated from our OpenAPI spec
}
end
end
end

View File

@ -0,0 +1,23 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# Occurs when a Meter has invalid async usage events.
class V1BillingMeterErrorReportTriggeredEvent < Stripe::V2::Event
def self.lookup_type
"v1.billing.meter.error_report_triggered"
end
# There is additional data present for this event, accessible with the `data` property.
# See the Stripe API docs for more information.
# Retrieves the related object from the API. Make an API request on every call.
def fetch_related_object
_request(
method: :get,
path: related_object.url,
base_address: :api,
opts: { stripe_account: context }
)
end
end
end

View File

@ -0,0 +1,13 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# Occurs when a Meter's id is missing or invalid in async usage events.
class V1BillingMeterNoMeterFoundEvent < Stripe::V2::Event
def self.lookup_type
"v1.billing.meter.no_meter_found"
end
# There is additional data present for this event, accessible with the `data` property.
# See the Stripe API docs for more information.
end
end

View File

@ -0,0 +1,21 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# A ping event used to test the connection to an event destination.
class V2CoreEventDestinationPingEvent < Stripe::V2::Event
def self.lookup_type
"v2.core.event_destination.ping"
end
# Retrieves the related object from the API. Make an API request on every call.
def fetch_related_object
_request(
method: :get,
path: related_object.url,
base_address: :api,
opts: { stripe_account: context }
)
end
end
end

View File

@ -0,0 +1,106 @@
# frozen_string_literal: true
module Stripe
class Instrumentation
# Event emitted on `request_begin` callback.
class RequestBeginEvent
attr_reader :method, :path
# Arbitrary user-provided data in the form of a Ruby hash that's passed
# from subscribers on `request_begin` to subscribers on `request_end`.
# `request_begin` subscribers can set keys which will then be available
# in `request_end`.
#
# Note that all subscribers of `request_begin` share the same object, so
# they must be careful to set unique keys so as to not conflict with data
# set by other subscribers.
attr_reader :user_data
def initialize(method:, path:, user_data:)
@method = method
@path = path
@user_data = user_data
freeze
end
end
# Event emitted on `request_end` callback.
class RequestEndEvent
attr_reader :duration, :http_status, :method, :num_retries, :path, :request_id, :response_header, :response_body,
:request_header, :request_body
# Arbitrary user-provided data in the form of a Ruby hash that's passed
# from subscribers on `request_begin` to subscribers on `request_end`.
# `request_begin` subscribers can set keys which will then be available
# in `request_end`.
attr_reader :user_data
def initialize(request_context:, response_context:,
num_retries:, user_data: nil)
@duration = request_context.duration
@http_status = response_context.http_status
@method = request_context.method
@num_retries = num_retries
@path = request_context.path
@request_id = request_context.request_id
@user_data = user_data
@response_header = response_context.header
@response_body = response_context.body
@request_header = request_context.header
@request_body = request_context.body
freeze
end
end
class RequestContext
attr_reader :duration, :method, :path, :request_id, :body, :header
def initialize(duration:, context:, header:)
@duration = duration
@method = context.method
@path = context.path
@request_id = context.request_id
@body = context.body
@header = header
end
end
class ResponseContext
attr_reader :http_status, :body, :header
def initialize(http_status:, response:)
@http_status = http_status
@header = response ? response.to_hash : nil
@body = response ? response.body : nil
end
end
# This class was renamed for consistency. This alias is here for backwards
# compatibility.
RequestEvent = RequestEndEvent
# Returns true if there are a non-zero number of subscribers on the given
# topic, and false otherwise.
def self.any_subscribers?(topic)
!subscribers[topic].empty?
end
def self.subscribe(topic, name = rand, &block)
subscribers[topic][name] = block
name
end
def self.unsubscribe(topic, name)
subscribers[topic].delete(name)
end
def self.notify(topic, event)
subscribers[topic].each_value { |subscriber| subscriber.call(event) }
end
def self.subscribers
@subscribers ||= Hash.new { |hash, key| hash[key] = {} }
end
private_class_method :subscribers
end
end

View File

@ -1,27 +0,0 @@
module Stripe
class Invoice < APIResource
include Stripe::APIOperations::List
include Stripe::APIOperations::Update
def self.upcoming(params)
response, api_key = Stripe.request(:get, upcoming_url, @api_key, params)
Util.convert_to_stripe_object(response, api_key)
end
def pay
response, api_key = Stripe.request(:post, pay_url, @api_key)
refresh_from(response, api_key)
self
end
private
def self.upcoming_url
url + '/upcoming'
end
def pay_url
url + '/pay'
end
end
end

View File

@ -1,8 +0,0 @@
module Stripe
class InvoiceItem < APIResource
include Stripe::APIOperations::List
include Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
include Stripe::APIOperations::Update
end
end

View File

@ -1,21 +0,0 @@
module Stripe
module JSON
if MultiJson.respond_to?(:dump)
def self.dump(*args)
MultiJson.dump(*args)
end
def self.load(*args)
MultiJson.load(*args)
end
else
def self.dump(*args)
MultiJson.encode(*args)
end
def self.load(*args)
MultiJson.decode(*args)
end
end
end
end

141
lib/stripe/list_object.rb Normal file
View File

@ -0,0 +1,141 @@
# frozen_string_literal: true
module Stripe
class ListObject < StripeObject
include Enumerable
include Stripe::APIOperations::List
include Stripe::APIOperations::Request
include Stripe::APIOperations::Create
OBJECT_NAME = "list"
def self.object_name
"list"
end
# This accessor allows a `ListObject` to inherit various filters that were
# given to a predecessor. This allows for things like consistent limits,
# expansions, and predicates as a user pages through resources.
attr_accessor :filters
# An empty list object. This is returned from +next+ when we know that
# there isn't a next page in order to replicate the behavior of the API
# when it attempts to return a page beyond the last.
def self.empty_list(opts = {})
ListObject.construct_from({ data: [] }, opts, nil, :v1)
end
def initialize(*args)
super
self.filters = {}
end
def [](key)
case key
when String, Symbol
super
else
raise ArgumentError,
"You tried to access the #{key.inspect} index, but ListObject " \
"types only support String keys. (HINT: List calls return an " \
"object with a 'data' (which is the data array). You likely " \
"want to call #data[#{key.inspect}])"
end
end
# Iterates through each resource in the page represented by the current
# `ListObject`.
#
# Note that this method makes no effort to fetch a new page when it gets to
# the end of the current page's resources. See also +auto_paging_each+.
def each(&blk)
data.each(&blk)
end
# Iterates through each resource in all pages, making additional fetches to
# the API as necessary.
#
# The default iteration direction is forwards according to Stripe's API
# "natural" ordering direction -- newer objects first, and moving towards
# older objects.
#
# However, if the initial list object was fetched using an `ending_before`
# cursor (and only `ending_before`, `starting_after` cannot also be
# included), the method assumes that the user is trying to iterate
# backwards compared to natural ordering and returns results that way --
# older objects first, and moving towards newer objects.
#
# Note that this method will make as many API calls as necessary to fetch
# all resources. For more granular control, please see +each+ and
# +next_page+.
def auto_paging_each(&blk)
return enum_for(:auto_paging_each) unless block_given?
page = self
loop do
# Backward iterating activates if we have an `ending_before` constraint
# and _just_ an `ending_before` constraint. If `starting_after` was
# also used, we iterate forwards normally.
if filters.include?(:ending_before) &&
!filters.include?(:starting_after)
page.reverse_each(&blk)
page = page.previous_page
else
page.each(&blk)
page = page.next_page
end
break if page.empty?
end
end
# Returns true if the page object contains no elements.
def empty?
data.empty?
end
def retrieve(id, opts = {})
id, retrieve_params = Util.normalize_id(id)
url = "#{resource_url}/#{CGI.escape(id)}"
execute_resource_request(:get, url, :api, retrieve_params, opts)
end
# Fetches the next page in the resource list (if there is one).
#
# This method will try to respect the limit of the current page. If none
# was given, the default limit will be fetched again.
def next_page(params = {}, opts = {})
return self.class.empty_list(opts) unless has_more
last_id = data.last.id
params = filters.merge(starting_after: last_id).merge(params)
list(params, opts)
end
# Fetches the previous page in the resource list (if there is one).
#
# This method will try to respect the limit of the current page. If none
# was given, the default limit will be fetched again.
def previous_page(params = {}, opts = {})
return self.class.empty_list(opts) unless has_more
first_id = data.first.id
params = filters.merge(ending_before: first_id).merge(params)
list(params, opts)
end
def resource_url
url ||
raise(ArgumentError, "List object does not contain a 'url' field.")
end
# Iterates through each resource in the page represented by the current
# `ListObject` in reverse.
def reverse_each(&blk)
data.reverse_each(&blk)
end
end
end

View File

@ -0,0 +1,131 @@
# frozen_string_literal: true
require "securerandom"
require "tempfile"
module Stripe
# Encodes parameters into a `multipart/form-data` payload as described by RFC
# 2388:
#
# https://tools.ietf.org/html/rfc2388
#
# This is most useful for transferring file-like objects.
#
# Parameters should be added with `#encode`. When ready, use `#body` to get
# the encoded result and `#content_type` to get the value that should be
# placed in the `Content-Type` header of a subsequent request (which includes
# a boundary value).
class MultipartEncoder
MULTIPART_FORM_DATA = "multipart/form-data"
# A shortcut for encoding a single set of parameters and finalizing a
# result.
#
# Returns an encoded body and the value that should be set in the content
# type header of a subsequent request.
def self.encode(params)
encoder = MultipartEncoder.new
encoder.encode(params)
encoder.close
[encoder.body, encoder.content_type]
end
# Gets the object's randomly generated boundary string.
attr_reader :boundary
# Initializes a new multipart encoder.
def initialize
# Kind of weird, but required by Rubocop because the unary plus operator
# is considered faster than `Stripe.new`.
@body = +""
# Chose the same number of random bytes that Go uses in its standard
# library implementation. Easily enough entropy to ensure that it won't
# be present in a file we're sending.
@boundary = SecureRandom.hex(30)
@closed = false
@first_field = true
end
# Gets the encoded body. `#close` must be called first.
def body
raise "object must be closed before getting body" unless @closed
@body
end
# Finalizes the object by writing the final boundary.
def close
raise "object already closed" if @closed
@body << "\r\n"
@body << "--#{@boundary}--"
@closed = true
nil
end
# Gets the value including boundary that should be put into a multipart
# request's `Content-Type`.
def content_type
"#{MULTIPART_FORM_DATA}; boundary=#{@boundary}"
end
# Encodes a set of parameters to the body.
#
# Note that parameters are expected to be a hash, but a "flat" hash such
# that complex substructures like hashes and arrays have already been
# appropriately Stripe-encoded. Pass a complex structure through
# `Util.flatten_params` first before handing it off to this method.
def encode(params)
raise "no more parameters can be written to closed object" if @closed
params.each do |name, val|
if val.is_a?(::File) || val.is_a?(::Tempfile)
write_field(name, val.read, filename: ::File.basename(val.path))
elsif val.respond_to?(:read)
write_field(name, val.read, filename: "blob")
else
write_field(name, val, filename: nil)
end
end
nil
end
#
# private
#
# Escapes double quotes so that the given value can be used in a
# double-quoted string and replaces any linebreak characters with spaces.
private def escape(str)
str.gsub('"', "%22").tr("\n", " ").tr("\r", " ")
end
private def write_field(name, data, filename:)
if @first_field
@first_field = false
else
@body << "\r\n"
end
@body << "--#{@boundary}\r\n"
if filename
@body << (%(Content-Disposition: form-data) +
%(; name="#{escape(name.to_s)}") +
%(; filename="#{escape(filename)}"\r\n))
@body << %(Content-Type: application/octet-stream\r\n)
else
@body << (%(Content-Disposition: form-data) +
%(; name="#{escape(name.to_s)}"\r\n))
end
@body << "\r\n"
@body << data.to_s
end
end
end

58
lib/stripe/oauth.rb Normal file
View File

@ -0,0 +1,58 @@
# frozen_string_literal: true
module Stripe
module OAuth
module OAuthOperations
extend APIOperations::Request::ClassMethods
def self.execute_resource_request(method, url, base_address, params, opts)
opts = Util.normalize_opts(opts)
super
end
end
def self.get_client_id(params = {})
client_id = params[:client_id] || Stripe.client_id
unless client_id
raise AuthenticationError, "No client_id provided. " \
'Set your client_id using "Stripe.client_id = <CLIENT-ID>". ' \
"You can find your client_ids in your Stripe dashboard at " \
"https://dashboard.stripe.com/account/applications/settings, " \
"after registering your account as a platform. See " \
"https://stripe.com/docs/connect/standalone-accounts for details, " \
"or email support@stripe.com if you have any questions."
end
client_id
end
def self.authorize_url(params = {}, opts = {})
base = opts[:connect_base] || APIRequestor.active_requestor.config.connect_base
path = "/oauth/authorize"
path = "/express" + path if opts[:express]
params[:client_id] = get_client_id(params)
params[:response_type] ||= "code"
query = Util.encode_parameters(params, :v1)
"#{base}#{path}?#{query}"
end
def self.token(params = {}, opts = {})
opts = Util.normalize_opts(opts)
opts[:api_key] = params[:client_secret] if params[:client_secret]
OAuthOperations.execute_resource_request(
:post, "/oauth/token", :connect, params, opts
)
end
def self.deauthorize(params = {}, opts = {})
opts = Util.normalize_opts(opts)
params[:client_id] = get_client_id(params)
OAuthOperations.execute_resource_request(
:post, "/oauth/deauthorize", :connect, params, opts
)
end
end
end

173
lib/stripe/object_types.rb Normal file
View File

@ -0,0 +1,173 @@
# frozen_string_literal: true
# rubocop:disable Metrics/MethodLength
module Stripe
module ObjectTypes
def self.object_names_to_classes
{
# data structures
ListObject.object_name => ListObject,
SearchResultObject.object_name => SearchResultObject,
File.object_name_alt => File,
# object classes: The beginning of the section generated from our OpenAPI spec
Account.object_name => Account,
AccountLink.object_name => AccountLink,
AccountSession.object_name => AccountSession,
ApplePayDomain.object_name => ApplePayDomain,
Application.object_name => Application,
ApplicationFee.object_name => ApplicationFee,
ApplicationFeeRefund.object_name => ApplicationFeeRefund,
Apps::Secret.object_name => Apps::Secret,
Balance.object_name => Balance,
BalanceTransaction.object_name => BalanceTransaction,
BankAccount.object_name => BankAccount,
Billing::Alert.object_name => Billing::Alert,
Billing::AlertTriggered.object_name => Billing::AlertTriggered,
Billing::CreditBalanceSummary.object_name => Billing::CreditBalanceSummary,
Billing::CreditBalanceTransaction.object_name => Billing::CreditBalanceTransaction,
Billing::CreditGrant.object_name => Billing::CreditGrant,
Billing::Meter.object_name => Billing::Meter,
Billing::MeterEvent.object_name => Billing::MeterEvent,
Billing::MeterEventAdjustment.object_name => Billing::MeterEventAdjustment,
Billing::MeterEventSummary.object_name => Billing::MeterEventSummary,
BillingPortal::Configuration.object_name => BillingPortal::Configuration,
BillingPortal::Session.object_name => BillingPortal::Session,
Capability.object_name => Capability,
Card.object_name => Card,
CashBalance.object_name => CashBalance,
Charge.object_name => Charge,
Checkout::Session.object_name => Checkout::Session,
Climate::Order.object_name => Climate::Order,
Climate::Product.object_name => Climate::Product,
Climate::Supplier.object_name => Climate::Supplier,
ConfirmationToken.object_name => ConfirmationToken,
ConnectCollectionTransfer.object_name => ConnectCollectionTransfer,
CountrySpec.object_name => CountrySpec,
Coupon.object_name => Coupon,
CreditNote.object_name => CreditNote,
CreditNoteLineItem.object_name => CreditNoteLineItem,
Customer.object_name => Customer,
CustomerBalanceTransaction.object_name => CustomerBalanceTransaction,
CustomerCashBalanceTransaction.object_name => CustomerCashBalanceTransaction,
CustomerSession.object_name => CustomerSession,
Discount.object_name => Discount,
Dispute.object_name => Dispute,
Entitlements::ActiveEntitlement.object_name => Entitlements::ActiveEntitlement,
Entitlements::ActiveEntitlementSummary.object_name => Entitlements::ActiveEntitlementSummary,
Entitlements::Feature.object_name => Entitlements::Feature,
EphemeralKey.object_name => EphemeralKey,
Event.object_name => Event,
ExchangeRate.object_name => ExchangeRate,
File.object_name => File,
FileLink.object_name => FileLink,
FinancialConnections::Account.object_name => FinancialConnections::Account,
FinancialConnections::AccountOwner.object_name => FinancialConnections::AccountOwner,
FinancialConnections::AccountOwnership.object_name => FinancialConnections::AccountOwnership,
FinancialConnections::Session.object_name => FinancialConnections::Session,
FinancialConnections::Transaction.object_name => FinancialConnections::Transaction,
Forwarding::Request.object_name => Forwarding::Request,
FundingInstructions.object_name => FundingInstructions,
Identity::VerificationReport.object_name => Identity::VerificationReport,
Identity::VerificationSession.object_name => Identity::VerificationSession,
Invoice.object_name => Invoice,
InvoiceItem.object_name => InvoiceItem,
InvoiceLineItem.object_name => InvoiceLineItem,
InvoicePayment.object_name => InvoicePayment,
InvoiceRenderingTemplate.object_name => InvoiceRenderingTemplate,
Issuing::Authorization.object_name => Issuing::Authorization,
Issuing::Card.object_name => Issuing::Card,
Issuing::Cardholder.object_name => Issuing::Cardholder,
Issuing::Dispute.object_name => Issuing::Dispute,
Issuing::PersonalizationDesign.object_name => Issuing::PersonalizationDesign,
Issuing::PhysicalBundle.object_name => Issuing::PhysicalBundle,
Issuing::Token.object_name => Issuing::Token,
Issuing::Transaction.object_name => Issuing::Transaction,
LineItem.object_name => LineItem,
LoginLink.object_name => LoginLink,
Mandate.object_name => Mandate,
PaymentIntent.object_name => PaymentIntent,
PaymentLink.object_name => PaymentLink,
PaymentMethod.object_name => PaymentMethod,
PaymentMethodConfiguration.object_name => PaymentMethodConfiguration,
PaymentMethodDomain.object_name => PaymentMethodDomain,
Payout.object_name => Payout,
Person.object_name => Person,
Plan.object_name => Plan,
Price.object_name => Price,
Product.object_name => Product,
ProductFeature.object_name => ProductFeature,
PromotionCode.object_name => PromotionCode,
Quote.object_name => Quote,
Radar::EarlyFraudWarning.object_name => Radar::EarlyFraudWarning,
Radar::ValueList.object_name => Radar::ValueList,
Radar::ValueListItem.object_name => Radar::ValueListItem,
Refund.object_name => Refund,
Reporting::ReportRun.object_name => Reporting::ReportRun,
Reporting::ReportType.object_name => Reporting::ReportType,
ReserveTransaction.object_name => ReserveTransaction,
Reversal.object_name => Reversal,
Review.object_name => Review,
SetupAttempt.object_name => SetupAttempt,
SetupIntent.object_name => SetupIntent,
ShippingRate.object_name => ShippingRate,
Sigma::ScheduledQueryRun.object_name => Sigma::ScheduledQueryRun,
Source.object_name => Source,
SourceMandateNotification.object_name => SourceMandateNotification,
SourceTransaction.object_name => SourceTransaction,
Subscription.object_name => Subscription,
SubscriptionItem.object_name => SubscriptionItem,
SubscriptionSchedule.object_name => SubscriptionSchedule,
Tax::Calculation.object_name => Tax::Calculation,
Tax::CalculationLineItem.object_name => Tax::CalculationLineItem,
Tax::Registration.object_name => Tax::Registration,
Tax::Settings.object_name => Tax::Settings,
Tax::Transaction.object_name => Tax::Transaction,
Tax::TransactionLineItem.object_name => Tax::TransactionLineItem,
TaxCode.object_name => TaxCode,
TaxDeductedAtSource.object_name => TaxDeductedAtSource,
TaxId.object_name => TaxId,
TaxRate.object_name => TaxRate,
Terminal::Configuration.object_name => Terminal::Configuration,
Terminal::ConnectionToken.object_name => Terminal::ConnectionToken,
Terminal::Location.object_name => Terminal::Location,
Terminal::Reader.object_name => Terminal::Reader,
TestHelpers::TestClock.object_name => TestHelpers::TestClock,
Token.object_name => Token,
Topup.object_name => Topup,
Transfer.object_name => Transfer,
Treasury::CreditReversal.object_name => Treasury::CreditReversal,
Treasury::DebitReversal.object_name => Treasury::DebitReversal,
Treasury::FinancialAccount.object_name => Treasury::FinancialAccount,
Treasury::FinancialAccountFeatures.object_name => Treasury::FinancialAccountFeatures,
Treasury::InboundTransfer.object_name => Treasury::InboundTransfer,
Treasury::OutboundPayment.object_name => Treasury::OutboundPayment,
Treasury::OutboundTransfer.object_name => Treasury::OutboundTransfer,
Treasury::ReceivedCredit.object_name => Treasury::ReceivedCredit,
Treasury::ReceivedDebit.object_name => Treasury::ReceivedDebit,
Treasury::Transaction.object_name => Treasury::Transaction,
Treasury::TransactionEntry.object_name => Treasury::TransactionEntry,
WebhookEndpoint.object_name => WebhookEndpoint,
# object classes: The end of the section generated from our OpenAPI spec
}
end
def self.v2_object_names_to_classes
{
V2::ListObject.object_name => V2::ListObject,
# v2 object classes: The beginning of the section generated from our OpenAPI spec
V2::Billing::MeterEvent.object_name => V2::Billing::MeterEvent,
V2::Billing::MeterEventAdjustment.object_name => V2::Billing::MeterEventAdjustment,
V2::Billing::MeterEventSession.object_name => V2::Billing::MeterEventSession,
V2::Event.object_name => V2::Event,
V2::EventDestination.object_name => V2::EventDestination,
# v2 object classes: The end of the section generated from our OpenAPI spec
}
end
end
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength

View File

@ -1,8 +0,0 @@
module Stripe
class Plan < APIResource
include Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
include Stripe::APIOperations::List
include Stripe::APIOperations::Update
end
end

View File

@ -0,0 +1,129 @@
# frozen_string_literal: true
# typed: true
module Stripe
# RequestOptions is a class that encapsulates configurable options
# for requests made to the Stripe API. It is used by the APIRequestor
# to set per-request options.
#
# For internal use only. Does not provide a stable API and may be broken
# with future non-major changes.
module RequestOptions
# Options that a user is allowed to specify.
OPTS_USER_SPECIFIED = Set[
:api_key,
:idempotency_key,
:stripe_account,
:stripe_context,
:stripe_version
].freeze
# Options that should be copyable from one StripeObject to another
# including options that may be internal.
OPTS_COPYABLE = (
OPTS_USER_SPECIFIED + Set[:api_base]
).freeze
# Options that should be persisted between API requests.
OPTS_PERSISTABLE = (
OPTS_USER_SPECIFIED - Set[:idempotency_key, :stripe_context]
).freeze
# Merges requestor options on a StripeConfiguration object
# with a per-request options hash, giving precedence
# to the per-request options. Expects StripeConfiguration and hash.
def self.merge_config_and_opts(config, req_opts)
# Raise an error if config is not a StripeConfiguration object
unless config.is_a?(StripeConfiguration)
raise ArgumentError, "config must be a Stripe::StripeConfiguration object"
end
merged_opts = {
api_key: req_opts[:api_key] || config.api_key,
idempotency_key: req_opts[:idempotency_key],
stripe_account: req_opts[:stripe_account] || config.stripe_account,
stripe_context: req_opts[:stripe_context] || config.stripe_context,
stripe_version: req_opts[:stripe_version] || config.api_version,
headers: req_opts[:headers] || {},
}
# Remove nil values from headers
merged_opts.delete_if { |_, v| v.nil? }
merged_opts
end
# Merges requestor options hash on a StripeObject
# with a per-request options hash, giving precedence
# to the per-request options. Returns the merged request options.
# Expects two hashes, expects extract_opts_from_hash to be called first!!!
def self.combine_opts(object_opts, req_opts)
merged_opts = {
api_key: req_opts[:api_key] || object_opts[:api_key],
idempotency_key: req_opts[:idempotency_key],
stripe_account: req_opts[:stripe_account] || object_opts[:stripe_account],
stripe_context: req_opts[:stripe_context] || object_opts[:stripe_context],
stripe_version: req_opts[:stripe_version] || object_opts[:stripe_version],
headers: req_opts[:headers] || {},
}
# Remove nil values from headers
merged_opts.delete_if { |_, v| v.nil? }
merged_opts
end
# Extracts options from a user-provided hash, returning a new request options hash
# containing the recognized request options and a `headers` entry for the remaining options.
def self.extract_opts_from_hash(opts)
req_opts = {}
normalized_opts = Util.normalize_opts(opts.clone)
RequestOptions.error_on_non_string_user_opts(normalized_opts)
OPTS_USER_SPECIFIED.each do |opt|
req_opts[opt] = normalized_opts[opt] if normalized_opts.key?(opt)
normalized_opts.delete(opt)
end
# Remaining user-provided opts should be treated as headers
req_opts[:headers] = Util.normalize_headers(normalized_opts) if normalized_opts.any?
req_opts
end
# Validates a normalized opts hash.
def self.error_on_non_string_user_opts(normalized_opts)
OPTS_USER_SPECIFIED.each do |opt|
next unless normalized_opts.key?(opt)
val = normalized_opts[opt]
next if val.nil?
next if val.is_a?(String)
raise ArgumentError,
"request option '#{opt}' should be a string value " \
"(was a #{val.class})"
end
end
# Get options that persist between requests
def self.persistable(req_opts)
opts_to_persist = {}
# Hash#select returns an array before 1.9
req_opts.each do |k, v|
opts_to_persist[k] = v if RequestOptions::OPTS_PERSISTABLE.include?(k)
end
opts_to_persist
end
# Get options that are copyable from StripeObject to StripeObject
def self.copyable(req_opts)
req_opts.select do |k, _v|
RequestOptions::OPTS_COPYABLE.include?(k)
end
end
end
end

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
# typed: true
module Stripe
# For internal use only. Does not provide a stable API and may be broken
# with future non-major changes.
class RequestParams
def to_h
instance_variables.each_with_object({}) do |var, hash|
key = var.to_s.delete("@").to_sym
value = instance_variable_get(var)
hash[key] = if value.is_a?(RequestParams)
value.to_h
# Check if value is an array and contains RequestParams objects
elsif value.is_a?(Array)
value.map { |item| item.is_a?(RequestParams) ? item.to_h : item }
else
value
end
end
end
end
end

148
lib/stripe/resources.rb Normal file
View File

@ -0,0 +1,148 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
require "stripe/resources/account"
require "stripe/resources/account_link"
require "stripe/resources/account_session"
require "stripe/resources/apple_pay_domain"
require "stripe/resources/application"
require "stripe/resources/application_fee"
require "stripe/resources/application_fee_refund"
require "stripe/resources/apps/secret"
require "stripe/resources/balance"
require "stripe/resources/balance_transaction"
require "stripe/resources/bank_account"
require "stripe/resources/billing/alert"
require "stripe/resources/billing/alert_triggered"
require "stripe/resources/billing/credit_balance_summary"
require "stripe/resources/billing/credit_balance_transaction"
require "stripe/resources/billing/credit_grant"
require "stripe/resources/billing/meter"
require "stripe/resources/billing/meter_event"
require "stripe/resources/billing/meter_event_adjustment"
require "stripe/resources/billing/meter_event_summary"
require "stripe/resources/billing_portal/configuration"
require "stripe/resources/billing_portal/session"
require "stripe/resources/capability"
require "stripe/resources/card"
require "stripe/resources/cash_balance"
require "stripe/resources/charge"
require "stripe/resources/checkout/session"
require "stripe/resources/climate/order"
require "stripe/resources/climate/product"
require "stripe/resources/climate/supplier"
require "stripe/resources/confirmation_token"
require "stripe/resources/connect_collection_transfer"
require "stripe/resources/country_spec"
require "stripe/resources/coupon"
require "stripe/resources/credit_note"
require "stripe/resources/credit_note_line_item"
require "stripe/resources/customer"
require "stripe/resources/customer_balance_transaction"
require "stripe/resources/customer_cash_balance_transaction"
require "stripe/resources/customer_session"
require "stripe/resources/discount"
require "stripe/resources/dispute"
require "stripe/resources/entitlements/active_entitlement"
require "stripe/resources/entitlements/active_entitlement_summary"
require "stripe/resources/entitlements/feature"
require "stripe/resources/ephemeral_key"
require "stripe/resources/event"
require "stripe/resources/exchange_rate"
require "stripe/resources/file"
require "stripe/resources/file_link"
require "stripe/resources/financial_connections/account"
require "stripe/resources/financial_connections/account_owner"
require "stripe/resources/financial_connections/account_ownership"
require "stripe/resources/financial_connections/session"
require "stripe/resources/financial_connections/transaction"
require "stripe/resources/forwarding/request"
require "stripe/resources/funding_instructions"
require "stripe/resources/identity/verification_report"
require "stripe/resources/identity/verification_session"
require "stripe/resources/invoice"
require "stripe/resources/invoice_item"
require "stripe/resources/invoice_line_item"
require "stripe/resources/invoice_payment"
require "stripe/resources/invoice_rendering_template"
require "stripe/resources/issuing/authorization"
require "stripe/resources/issuing/card"
require "stripe/resources/issuing/cardholder"
require "stripe/resources/issuing/dispute"
require "stripe/resources/issuing/personalization_design"
require "stripe/resources/issuing/physical_bundle"
require "stripe/resources/issuing/token"
require "stripe/resources/issuing/transaction"
require "stripe/resources/line_item"
require "stripe/resources/login_link"
require "stripe/resources/mandate"
require "stripe/resources/payment_intent"
require "stripe/resources/payment_link"
require "stripe/resources/payment_method"
require "stripe/resources/payment_method_configuration"
require "stripe/resources/payment_method_domain"
require "stripe/resources/payout"
require "stripe/resources/person"
require "stripe/resources/plan"
require "stripe/resources/price"
require "stripe/resources/product"
require "stripe/resources/product_feature"
require "stripe/resources/promotion_code"
require "stripe/resources/quote"
require "stripe/resources/radar/early_fraud_warning"
require "stripe/resources/radar/value_list"
require "stripe/resources/radar/value_list_item"
require "stripe/resources/refund"
require "stripe/resources/reporting/report_run"
require "stripe/resources/reporting/report_type"
require "stripe/resources/reserve_transaction"
require "stripe/resources/reversal"
require "stripe/resources/review"
require "stripe/resources/setup_attempt"
require "stripe/resources/setup_intent"
require "stripe/resources/shipping_rate"
require "stripe/resources/sigma/scheduled_query_run"
require "stripe/resources/source"
require "stripe/resources/source_mandate_notification"
require "stripe/resources/source_transaction"
require "stripe/resources/subscription"
require "stripe/resources/subscription_item"
require "stripe/resources/subscription_schedule"
require "stripe/resources/tax/calculation"
require "stripe/resources/tax/calculation_line_item"
require "stripe/resources/tax/registration"
require "stripe/resources/tax/settings"
require "stripe/resources/tax/transaction"
require "stripe/resources/tax/transaction_line_item"
require "stripe/resources/tax_code"
require "stripe/resources/tax_deducted_at_source"
require "stripe/resources/tax_id"
require "stripe/resources/tax_rate"
require "stripe/resources/terminal/configuration"
require "stripe/resources/terminal/connection_token"
require "stripe/resources/terminal/location"
require "stripe/resources/terminal/reader"
require "stripe/resources/test_helpers/test_clock"
require "stripe/resources/token"
require "stripe/resources/topup"
require "stripe/resources/transfer"
require "stripe/resources/treasury/credit_reversal"
require "stripe/resources/treasury/debit_reversal"
require "stripe/resources/treasury/financial_account"
require "stripe/resources/treasury/financial_account_features"
require "stripe/resources/treasury/inbound_transfer"
require "stripe/resources/treasury/outbound_payment"
require "stripe/resources/treasury/outbound_transfer"
require "stripe/resources/treasury/received_credit"
require "stripe/resources/treasury/received_debit"
require "stripe/resources/treasury/transaction"
require "stripe/resources/treasury/transaction_entry"
require "stripe/resources/v2/billing/meter_event"
require "stripe/resources/v2/billing/meter_event_adjustment"
require "stripe/resources/v2/billing/meter_event_session"
require "stripe/resources/v2/event"
require "stripe/resources/v2/event_destination"
require "stripe/resources/webhook_endpoint"
require "stripe/events/v1_billing_meter_error_report_triggered_event"
require "stripe/events/v1_billing_meter_no_meter_found_event"
require "stripe/events/v2_core_event_destination_ping_event"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,76 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# Account Links are the means by which a Connect platform grants a connected account permission to access
# Stripe-hosted applications, such as Connect Onboarding.
#
# Related guide: [Connect Onboarding](https://stripe.com/docs/connect/custom/hosted-onboarding)
class AccountLink < APIResource
extend Stripe::APIOperations::Create
OBJECT_NAME = "account_link"
def self.object_name
"account_link"
end
class CreateParams < Stripe::RequestParams
class CollectionOptions < Stripe::RequestParams
# Specifies whether the platform collects only currently_due requirements (`currently_due`) or both currently_due and eventually_due requirements (`eventually_due`). If you don't specify `collection_options`, the default value is `currently_due`.
attr_accessor :fields
# Specifies whether the platform collects future_requirements in addition to requirements in Connect Onboarding. The default value is `omit`.
attr_accessor :future_requirements
def initialize(fields: nil, future_requirements: nil)
@fields = fields
@future_requirements = future_requirements
end
end
# The identifier of the account to create an account link for.
attr_accessor :account
# The collect parameter is deprecated. Use `collection_options` instead.
attr_accessor :collect
# Specifies the requirements that Stripe collects from connected accounts in the Connect Onboarding flow.
attr_accessor :collection_options
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# The URL the user will be redirected to if the account link is expired, has been previously-visited, or is otherwise invalid. The URL you specify should attempt to generate a new account link with the same parameters used to create the original account link, then redirect the user to the new account link's URL so they can continue with Connect Onboarding. If a new account link cannot be generated or the redirect fails you should display a useful error to the user.
attr_accessor :refresh_url
# The URL that the user will be redirected to upon leaving or completing the linked flow.
attr_accessor :return_url
# The type of account link the user is requesting. Possible values are `account_onboarding` or `account_update`.
attr_accessor :type
def initialize(
account: nil,
collect: nil,
collection_options: nil,
expand: nil,
refresh_url: nil,
return_url: nil,
type: nil
)
@account = account
@collect = collect
@collection_options = collection_options
@expand = expand
@refresh_url = refresh_url
@return_url = return_url
@type = type
end
end
# Time at which the object was created. Measured in seconds since the Unix epoch.
attr_reader :created
# The timestamp at which this account link will expire.
attr_reader :expires_at
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# The URL for the account link.
attr_reader :url
# Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/account_links", params: params, opts: opts)
end
end
end

View File

@ -0,0 +1,868 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# An AccountSession allows a Connect platform to grant access to a connected account in Connect embedded components.
#
# We recommend that you create an AccountSession each time you need to display an embedded component
# to your user. Do not save AccountSessions to your database as they expire relatively
# quickly, and cannot be used more than once.
#
# Related guide: [Connect embedded components](https://stripe.com/docs/connect/get-started-connect-embedded-components)
class AccountSession < APIResource
extend Stripe::APIOperations::Create
OBJECT_NAME = "account_session"
def self.object_name
"account_session"
end
class Components < Stripe::StripeObject
class AccountManagement < Stripe::StripeObject
class Features < Stripe::StripeObject
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_reader :disable_stripe_user_authentication
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_reader :external_account_collection
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class AccountOnboarding < Stripe::StripeObject
class Features < Stripe::StripeObject
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_reader :disable_stripe_user_authentication
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_reader :external_account_collection
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class Balances < Stripe::StripeObject
class Features < Stripe::StripeObject
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_reader :disable_stripe_user_authentication
# Whether to allow payout schedule to be changed. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_reader :edit_payout_schedule
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_reader :external_account_collection
# Whether to allow creation of instant payouts. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_reader :instant_payouts
# Whether to allow creation of standard payouts. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_reader :standard_payouts
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class DisputesList < Stripe::StripeObject
class Features < Stripe::StripeObject
# Whether to allow capturing and cancelling payment intents. This is `true` by default.
attr_reader :capture_payments
# Whether to allow connected accounts to manage destination charges that are created on behalf of them. This is `false` by default.
attr_reader :destination_on_behalf_of_charge_management
# Whether to allow responding to disputes, including submitting evidence and accepting disputes. This is `true` by default.
attr_reader :dispute_management
# Whether to allow sending refunds. This is `true` by default.
attr_reader :refund_management
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class Documents < Stripe::StripeObject
class Features < Stripe::StripeObject; end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class FinancialAccount < Stripe::StripeObject
class Features < Stripe::StripeObject
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_reader :disable_stripe_user_authentication
# Whether to allow external accounts to be linked for money transfer.
attr_reader :external_account_collection
# Whether to allow sending money.
attr_reader :send_money
# Whether to allow transferring balance.
attr_reader :transfer_balance
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class FinancialAccountTransactions < Stripe::StripeObject
class Features < Stripe::StripeObject
# Whether to allow card spend dispute management features.
attr_reader :card_spend_dispute_management
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class IssuingCard < Stripe::StripeObject
class Features < Stripe::StripeObject
# Whether to allow card management features.
attr_reader :card_management
# Whether to allow card spend dispute management features.
attr_reader :card_spend_dispute_management
# Whether to allow cardholder management features.
attr_reader :cardholder_management
# Whether to allow spend control management features.
attr_reader :spend_control_management
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class IssuingCardsList < Stripe::StripeObject
class Features < Stripe::StripeObject
# Whether to allow card management features.
attr_reader :card_management
# Whether to allow card spend dispute management features.
attr_reader :card_spend_dispute_management
# Whether to allow cardholder management features.
attr_reader :cardholder_management
# Disables Stripe user authentication for this embedded component. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts.
attr_reader :disable_stripe_user_authentication
# Whether to allow spend control management features.
attr_reader :spend_control_management
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class NotificationBanner < Stripe::StripeObject
class Features < Stripe::StripeObject
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_reader :disable_stripe_user_authentication
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_reader :external_account_collection
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class PaymentDetails < Stripe::StripeObject
class Features < Stripe::StripeObject
# Whether to allow capturing and cancelling payment intents. This is `true` by default.
attr_reader :capture_payments
# Whether to allow connected accounts to manage destination charges that are created on behalf of them. This is `false` by default.
attr_reader :destination_on_behalf_of_charge_management
# Whether to allow responding to disputes, including submitting evidence and accepting disputes. This is `true` by default.
attr_reader :dispute_management
# Whether to allow sending refunds. This is `true` by default.
attr_reader :refund_management
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class PaymentDisputes < Stripe::StripeObject
class Features < Stripe::StripeObject
# Whether to allow connected accounts to manage destination charges that are created on behalf of them. This is `false` by default.
attr_reader :destination_on_behalf_of_charge_management
# Whether to allow responding to disputes, including submitting evidence and accepting disputes. This is `true` by default.
attr_reader :dispute_management
# Whether to allow sending refunds. This is `true` by default.
attr_reader :refund_management
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class Payments < Stripe::StripeObject
class Features < Stripe::StripeObject
# Whether to allow capturing and cancelling payment intents. This is `true` by default.
attr_reader :capture_payments
# Whether to allow connected accounts to manage destination charges that are created on behalf of them. This is `false` by default.
attr_reader :destination_on_behalf_of_charge_management
# Whether to allow responding to disputes, including submitting evidence and accepting disputes. This is `true` by default.
attr_reader :dispute_management
# Whether to allow sending refunds. This is `true` by default.
attr_reader :refund_management
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class Payouts < Stripe::StripeObject
class Features < Stripe::StripeObject
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_reader :disable_stripe_user_authentication
# Whether to allow payout schedule to be changed. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_reader :edit_payout_schedule
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_reader :external_account_collection
# Whether to allow creation of instant payouts. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_reader :instant_payouts
# Whether to allow creation of standard payouts. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_reader :standard_payouts
end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class PayoutsList < Stripe::StripeObject
class Features < Stripe::StripeObject; end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class TaxRegistrations < Stripe::StripeObject
class Features < Stripe::StripeObject; end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
class TaxSettings < Stripe::StripeObject
class Features < Stripe::StripeObject; end
# Whether the embedded component is enabled.
attr_reader :enabled
# Attribute for field features
attr_reader :features
end
# Attribute for field account_management
attr_reader :account_management
# Attribute for field account_onboarding
attr_reader :account_onboarding
# Attribute for field balances
attr_reader :balances
# Attribute for field disputes_list
attr_reader :disputes_list
# Attribute for field documents
attr_reader :documents
# Attribute for field financial_account
attr_reader :financial_account
# Attribute for field financial_account_transactions
attr_reader :financial_account_transactions
# Attribute for field issuing_card
attr_reader :issuing_card
# Attribute for field issuing_cards_list
attr_reader :issuing_cards_list
# Attribute for field notification_banner
attr_reader :notification_banner
# Attribute for field payment_details
attr_reader :payment_details
# Attribute for field payment_disputes
attr_reader :payment_disputes
# Attribute for field payments
attr_reader :payments
# Attribute for field payouts
attr_reader :payouts
# Attribute for field payouts_list
attr_reader :payouts_list
# Attribute for field tax_registrations
attr_reader :tax_registrations
# Attribute for field tax_settings
attr_reader :tax_settings
end
class CreateParams < Stripe::RequestParams
class Components < Stripe::RequestParams
class AccountManagement < Stripe::RequestParams
class Features < Stripe::RequestParams
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_accessor :disable_stripe_user_authentication
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_accessor :external_account_collection
def initialize(
disable_stripe_user_authentication: nil,
external_account_collection: nil
)
@disable_stripe_user_authentication = disable_stripe_user_authentication
@external_account_collection = external_account_collection
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class AccountOnboarding < Stripe::RequestParams
class Features < Stripe::RequestParams
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_accessor :disable_stripe_user_authentication
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_accessor :external_account_collection
def initialize(
disable_stripe_user_authentication: nil,
external_account_collection: nil
)
@disable_stripe_user_authentication = disable_stripe_user_authentication
@external_account_collection = external_account_collection
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class Balances < Stripe::RequestParams
class Features < Stripe::RequestParams
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_accessor :disable_stripe_user_authentication
# Whether to allow payout schedule to be changed. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_accessor :edit_payout_schedule
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_accessor :external_account_collection
# Whether to allow creation of instant payouts. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_accessor :instant_payouts
# Whether to allow creation of standard payouts. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_accessor :standard_payouts
def initialize(
disable_stripe_user_authentication: nil,
edit_payout_schedule: nil,
external_account_collection: nil,
instant_payouts: nil,
standard_payouts: nil
)
@disable_stripe_user_authentication = disable_stripe_user_authentication
@edit_payout_schedule = edit_payout_schedule
@external_account_collection = external_account_collection
@instant_payouts = instant_payouts
@standard_payouts = standard_payouts
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class DisputesList < Stripe::RequestParams
class Features < Stripe::RequestParams
# Whether to allow capturing and cancelling payment intents. This is `true` by default.
attr_accessor :capture_payments
# Whether to allow connected accounts to manage destination charges that are created on behalf of them. This is `false` by default.
attr_accessor :destination_on_behalf_of_charge_management
# Whether to allow responding to disputes, including submitting evidence and accepting disputes. This is `true` by default.
attr_accessor :dispute_management
# Whether to allow sending refunds. This is `true` by default.
attr_accessor :refund_management
def initialize(
capture_payments: nil,
destination_on_behalf_of_charge_management: nil,
dispute_management: nil,
refund_management: nil
)
@capture_payments = capture_payments
@destination_on_behalf_of_charge_management = destination_on_behalf_of_charge_management
@dispute_management = dispute_management
@refund_management = refund_management
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class Documents < Stripe::RequestParams
class Features < Stripe::RequestParams; end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class FinancialAccount < Stripe::RequestParams
class Features < Stripe::RequestParams
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_accessor :disable_stripe_user_authentication
# Whether to allow external accounts to be linked for money transfer.
attr_accessor :external_account_collection
# Whether to allow sending money.
attr_accessor :send_money
# Whether to allow transferring balance.
attr_accessor :transfer_balance
def initialize(
disable_stripe_user_authentication: nil,
external_account_collection: nil,
send_money: nil,
transfer_balance: nil
)
@disable_stripe_user_authentication = disable_stripe_user_authentication
@external_account_collection = external_account_collection
@send_money = send_money
@transfer_balance = transfer_balance
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class FinancialAccountTransactions < Stripe::RequestParams
class Features < Stripe::RequestParams
# Whether to allow card spend dispute management features.
attr_accessor :card_spend_dispute_management
def initialize(card_spend_dispute_management: nil)
@card_spend_dispute_management = card_spend_dispute_management
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class IssuingCard < Stripe::RequestParams
class Features < Stripe::RequestParams
# Whether to allow card management features.
attr_accessor :card_management
# Whether to allow card spend dispute management features.
attr_accessor :card_spend_dispute_management
# Whether to allow cardholder management features.
attr_accessor :cardholder_management
# Whether to allow spend control management features.
attr_accessor :spend_control_management
def initialize(
card_management: nil,
card_spend_dispute_management: nil,
cardholder_management: nil,
spend_control_management: nil
)
@card_management = card_management
@card_spend_dispute_management = card_spend_dispute_management
@cardholder_management = cardholder_management
@spend_control_management = spend_control_management
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class IssuingCardsList < Stripe::RequestParams
class Features < Stripe::RequestParams
# Whether to allow card management features.
attr_accessor :card_management
# Whether to allow card spend dispute management features.
attr_accessor :card_spend_dispute_management
# Whether to allow cardholder management features.
attr_accessor :cardholder_management
# Disables Stripe user authentication for this embedded component. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts.
attr_accessor :disable_stripe_user_authentication
# Whether to allow spend control management features.
attr_accessor :spend_control_management
def initialize(
card_management: nil,
card_spend_dispute_management: nil,
cardholder_management: nil,
disable_stripe_user_authentication: nil,
spend_control_management: nil
)
@card_management = card_management
@card_spend_dispute_management = card_spend_dispute_management
@cardholder_management = cardholder_management
@disable_stripe_user_authentication = disable_stripe_user_authentication
@spend_control_management = spend_control_management
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class NotificationBanner < Stripe::RequestParams
class Features < Stripe::RequestParams
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_accessor :disable_stripe_user_authentication
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_accessor :external_account_collection
def initialize(
disable_stripe_user_authentication: nil,
external_account_collection: nil
)
@disable_stripe_user_authentication = disable_stripe_user_authentication
@external_account_collection = external_account_collection
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class PaymentDetails < Stripe::RequestParams
class Features < Stripe::RequestParams
# Whether to allow capturing and cancelling payment intents. This is `true` by default.
attr_accessor :capture_payments
# Whether to allow connected accounts to manage destination charges that are created on behalf of them. This is `false` by default.
attr_accessor :destination_on_behalf_of_charge_management
# Whether to allow responding to disputes, including submitting evidence and accepting disputes. This is `true` by default.
attr_accessor :dispute_management
# Whether to allow sending refunds. This is `true` by default.
attr_accessor :refund_management
def initialize(
capture_payments: nil,
destination_on_behalf_of_charge_management: nil,
dispute_management: nil,
refund_management: nil
)
@capture_payments = capture_payments
@destination_on_behalf_of_charge_management = destination_on_behalf_of_charge_management
@dispute_management = dispute_management
@refund_management = refund_management
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class PaymentDisputes < Stripe::RequestParams
class Features < Stripe::RequestParams
# Whether to allow connected accounts to manage destination charges that are created on behalf of them. This is `false` by default.
attr_accessor :destination_on_behalf_of_charge_management
# Whether to allow responding to disputes, including submitting evidence and accepting disputes. This is `true` by default.
attr_accessor :dispute_management
# Whether to allow sending refunds. This is `true` by default.
attr_accessor :refund_management
def initialize(
destination_on_behalf_of_charge_management: nil,
dispute_management: nil,
refund_management: nil
)
@destination_on_behalf_of_charge_management = destination_on_behalf_of_charge_management
@dispute_management = dispute_management
@refund_management = refund_management
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class Payments < Stripe::RequestParams
class Features < Stripe::RequestParams
# Whether to allow capturing and cancelling payment intents. This is `true` by default.
attr_accessor :capture_payments
# Whether to allow connected accounts to manage destination charges that are created on behalf of them. This is `false` by default.
attr_accessor :destination_on_behalf_of_charge_management
# Whether to allow responding to disputes, including submitting evidence and accepting disputes. This is `true` by default.
attr_accessor :dispute_management
# Whether to allow sending refunds. This is `true` by default.
attr_accessor :refund_management
def initialize(
capture_payments: nil,
destination_on_behalf_of_charge_management: nil,
dispute_management: nil,
refund_management: nil
)
@capture_payments = capture_payments
@destination_on_behalf_of_charge_management = destination_on_behalf_of_charge_management
@dispute_management = dispute_management
@refund_management = refund_management
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class Payouts < Stripe::RequestParams
class Features < Stripe::RequestParams
# Disables Stripe user authentication for this embedded component. This value can only be true for accounts where `controller.requirement_collection` is `application`. The default value is the opposite of the `external_account_collection` value. For example, if you dont set `external_account_collection`, it defaults to true and `disable_stripe_user_authentication` defaults to false.
attr_accessor :disable_stripe_user_authentication
# Whether to allow payout schedule to be changed. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_accessor :edit_payout_schedule
# Whether to allow platforms to control bank account collection for their connected accounts. This feature can only be false for accounts where youre responsible for collecting updated information when requirements are due or change, like custom accounts. Otherwise, bank account collection is determined by compliance requirements. The default value for this feature is `true`.
attr_accessor :external_account_collection
# Whether to allow creation of instant payouts. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_accessor :instant_payouts
# Whether to allow creation of standard payouts. Default `true` when Stripe owns Loss Liability, default `false` otherwise.
attr_accessor :standard_payouts
def initialize(
disable_stripe_user_authentication: nil,
edit_payout_schedule: nil,
external_account_collection: nil,
instant_payouts: nil,
standard_payouts: nil
)
@disable_stripe_user_authentication = disable_stripe_user_authentication
@edit_payout_schedule = edit_payout_schedule
@external_account_collection = external_account_collection
@instant_payouts = instant_payouts
@standard_payouts = standard_payouts
end
end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class PayoutsList < Stripe::RequestParams
class Features < Stripe::RequestParams; end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class TaxRegistrations < Stripe::RequestParams
class Features < Stripe::RequestParams; end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
class TaxSettings < Stripe::RequestParams
class Features < Stripe::RequestParams; end
# Whether the embedded component is enabled.
attr_accessor :enabled
# The list of features enabled in the embedded component.
attr_accessor :features
def initialize(enabled: nil, features: nil)
@enabled = enabled
@features = features
end
end
# Configuration for the account management embedded component.
attr_accessor :account_management
# Configuration for the account onboarding embedded component.
attr_accessor :account_onboarding
# Configuration for the balances embedded component.
attr_accessor :balances
# Configuration for the disputes list embedded component.
attr_accessor :disputes_list
# Configuration for the documents embedded component.
attr_accessor :documents
# Configuration for the financial account embedded component.
attr_accessor :financial_account
# Configuration for the financial account transactions embedded component.
attr_accessor :financial_account_transactions
# Configuration for the issuing card embedded component.
attr_accessor :issuing_card
# Configuration for the issuing cards list embedded component.
attr_accessor :issuing_cards_list
# Configuration for the notification banner embedded component.
attr_accessor :notification_banner
# Configuration for the payment details embedded component.
attr_accessor :payment_details
# Configuration for the payment disputes embedded component.
attr_accessor :payment_disputes
# Configuration for the payments embedded component.
attr_accessor :payments
# Configuration for the payouts embedded component.
attr_accessor :payouts
# Configuration for the payouts list embedded component.
attr_accessor :payouts_list
# Configuration for the tax registrations embedded component.
attr_accessor :tax_registrations
# Configuration for the tax settings embedded component.
attr_accessor :tax_settings
def initialize(
account_management: nil,
account_onboarding: nil,
balances: nil,
disputes_list: nil,
documents: nil,
financial_account: nil,
financial_account_transactions: nil,
issuing_card: nil,
issuing_cards_list: nil,
notification_banner: nil,
payment_details: nil,
payment_disputes: nil,
payments: nil,
payouts: nil,
payouts_list: nil,
tax_registrations: nil,
tax_settings: nil
)
@account_management = account_management
@account_onboarding = account_onboarding
@balances = balances
@disputes_list = disputes_list
@documents = documents
@financial_account = financial_account
@financial_account_transactions = financial_account_transactions
@issuing_card = issuing_card
@issuing_cards_list = issuing_cards_list
@notification_banner = notification_banner
@payment_details = payment_details
@payment_disputes = payment_disputes
@payments = payments
@payouts = payouts
@payouts_list = payouts_list
@tax_registrations = tax_registrations
@tax_settings = tax_settings
end
end
# The identifier of the account to create an Account Session for.
attr_accessor :account
# Each key of the dictionary represents an embedded component, and each embedded component maps to its configuration (e.g. whether it has been enabled or not).
attr_accessor :components
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(account: nil, components: nil, expand: nil)
@account = account
@components = components
@expand = expand
end
end
# The ID of the account the AccountSession was created for
attr_reader :account
# The client secret of this AccountSession. Used on the client to set up secure access to the given `account`.
#
# The client secret can be used to provide access to `account` from your frontend. It should not be stored, logged, or exposed to anyone other than the connected account. Make sure that you have TLS enabled on any page that includes the client secret.
#
# Refer to our docs to [setup Connect embedded components](https://stripe.com/docs/connect/get-started-connect-embedded-components) and learn about how `client_secret` should be handled.
attr_reader :client_secret
# Attribute for field components
attr_reader :components
# The timestamp at which this AccountSession will expire.
attr_reader :expires_at
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
attr_reader :livemode
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# Creates a AccountSession object that includes a single-use token that the platform can use on their front-end to grant client-side API access.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/account_sessions", params: params, opts: opts)
end
end
end

View File

@ -0,0 +1,34 @@
# frozen_string_literal: true
module Stripe
class AlipayAccount < APIResource
include Stripe::APIOperations::Save
include Stripe::APIOperations::Delete
OBJECT_NAME = "alipay_account"
def resource_url
if !respond_to?(:customer) || customer.nil?
raise NotImplementedError,
"Alipay accounts cannot be accessed without a customer ID."
end
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources" \
"/#{CGI.escape(id)}"
end
def self.update(_id, _params = nil, _opts = nil)
raise NotImplementedError,
"Alipay accounts cannot be updated without a customer ID. " \
"Update an Alipay account using `Customer.update_source(" \
"'customer_id', 'alipay_account_id', update_params)`"
end
def self.retrieve(_id, _opts = nil)
raise NotImplementedError,
"Alipay accounts cannot be retrieved without a customer ID. " \
"Retrieve an Alipay account using `Customer.retrieve_source(" \
"'customer_id', 'alipay_account_id')`"
end
end
end

View File

@ -0,0 +1,108 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# Domains registered for Apple Pay on the Web
class ApplePayDomain < APIResource
extend Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
extend Stripe::APIOperations::List
OBJECT_NAME = "apple_pay_domain"
def self.object_name
"apple_pay_domain"
end
class DeleteParams < Stripe::RequestParams; end
class ListParams < Stripe::RequestParams
# Attribute for param field domain_name
attr_accessor :domain_name
# A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
attr_accessor :ending_before
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
attr_accessor :limit
# A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
attr_accessor :starting_after
def initialize(
domain_name: nil,
ending_before: nil,
expand: nil,
limit: nil,
starting_after: nil
)
@domain_name = domain_name
@ending_before = ending_before
@expand = expand
@limit = limit
@starting_after = starting_after
end
end
class CreateParams < Stripe::RequestParams
# Attribute for param field domain_name
attr_accessor :domain_name
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(domain_name: nil, expand: nil)
@domain_name = domain_name
@expand = expand
end
end
# Time at which the object was created. Measured in seconds since the Unix epoch.
attr_reader :created
# Attribute for field domain_name
attr_reader :domain_name
# Unique identifier for the object.
attr_reader :id
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
attr_reader :livemode
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# Always true for a deleted object
attr_reader :deleted
# Create an apple pay domain.
def self.create(params = {}, opts = {})
request_stripe_object(
method: :post,
path: "/v1/apple_pay/domains",
params: params,
opts: opts
)
end
# Delete an apple pay domain.
def self.delete(domain, params = {}, opts = {})
request_stripe_object(
method: :delete,
path: format("/v1/apple_pay/domains/%<domain>s", { domain: CGI.escape(domain) }),
params: params,
opts: opts
)
end
# Delete an apple pay domain.
def delete(params = {}, opts = {})
request_stripe_object(
method: :delete,
path: format("/v1/apple_pay/domains/%<domain>s", { domain: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
# List apple pay domains.
def self.list(params = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/apple_pay/domains", params: params, opts: opts)
end
def self.resource_url
"/v1/apple_pay/domains"
end
end
end

View File

@ -0,0 +1,20 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
class Application < APIResource
OBJECT_NAME = "application"
def self.object_name
"application"
end
# Unique identifier for the object.
attr_reader :id
# The name of the application.
attr_reader :name
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# Always true for a deleted object
attr_reader :deleted
end
end

View File

@ -0,0 +1,108 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
class ApplicationFee < APIResource
extend Stripe::APIOperations::List
extend Stripe::APIOperations::NestedResource
OBJECT_NAME = "application_fee"
def self.object_name
"application_fee"
end
nested_resource_class_methods :refund, operations: %i[create retrieve update list]
class FeeSource < Stripe::StripeObject
# Charge ID that created this application fee.
attr_reader :charge
# Payout ID that created this application fee.
attr_reader :payout
# Type of object that created the application fee.
attr_reader :type
end
class ListParams < Stripe::RequestParams
class Created < Stripe::RequestParams
# Minimum value to filter by (exclusive)
attr_accessor :gt
# Minimum value to filter by (inclusive)
attr_accessor :gte
# Maximum value to filter by (exclusive)
attr_accessor :lt
# Maximum value to filter by (inclusive)
attr_accessor :lte
def initialize(gt: nil, gte: nil, lt: nil, lte: nil)
@gt = gt
@gte = gte
@lt = lt
@lte = lte
end
end
# Only return application fees for the charge specified by this charge ID.
attr_accessor :charge
# Only return applications fees that were created during the given date interval.
attr_accessor :created
# A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
attr_accessor :ending_before
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
attr_accessor :limit
# A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
attr_accessor :starting_after
def initialize(
charge: nil,
created: nil,
ending_before: nil,
expand: nil,
limit: nil,
starting_after: nil
)
@charge = charge
@created = created
@ending_before = ending_before
@expand = expand
@limit = limit
@starting_after = starting_after
end
end
# ID of the Stripe account this fee was taken from.
attr_reader :account
# Amount earned, in cents (or local equivalent).
attr_reader :amount
# Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the fee if a partial refund was issued)
attr_reader :amount_refunded
# ID of the Connect application that earned the fee.
attr_reader :application
# Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).
attr_reader :balance_transaction
# ID of the charge that the application fee was taken from.
attr_reader :charge
# Time at which the object was created. Measured in seconds since the Unix epoch.
attr_reader :created
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# Polymorphic source of the application fee. Includes the ID of the object the application fee was created from.
attr_reader :fee_source
# Unique identifier for the object.
attr_reader :id
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
attr_reader :livemode
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# ID of the corresponding charge on the platform account, if this fee was the result of a charge using the `destination` parameter.
attr_reader :originating_transaction
# Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false.
attr_reader :refunded
# A list of refunds that have been applied to the fee.
attr_reader :refunds
# Returns a list of application fees you've previously collected. The application fees are returned in sorted order, with the most recent fees appearing first.
def self.list(params = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/application_fees", params: params, opts: opts)
end
end
end

View File

@ -0,0 +1,55 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# `Application Fee Refund` objects allow you to refund an application fee that
# has previously been created but not yet refunded. Funds will be refunded to
# the Stripe account from which the fee was originally collected.
#
# Related guide: [Refunding application fees](https://stripe.com/docs/connect/destination-charges#refunding-app-fee)
class ApplicationFeeRefund < APIResource
include Stripe::APIOperations::Save
OBJECT_NAME = "fee_refund"
def self.object_name
"fee_refund"
end
# Amount, in cents (or local equivalent).
attr_reader :amount
# Balance transaction that describes the impact on your account balance.
attr_reader :balance_transaction
# Time at which the object was created. Measured in seconds since the Unix epoch.
attr_reader :created
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# ID of the application fee that was refunded.
attr_reader :fee
# Unique identifier for the object.
attr_reader :id
# Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
attr_reader :metadata
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
def resource_url
"#{ApplicationFee.resource_url}/#{CGI.escape(fee)}/refunds" \
"/#{CGI.escape(id)}"
end
def self.update(_id, _params = nil, _opts = nil)
raise NotImplementedError,
"Application fee refunds cannot be updated without an " \
"application fee ID. Update an application fee refund using " \
"`ApplicationFee.update_refund('fee_id', 'refund_id', " \
"update_params)`"
end
def self.retrieve(_id, _api_key = nil)
raise NotImplementedError,
"Application fee refunds cannot be retrieved without an " \
"application fee ID. Retrieve an application fee refund using " \
"`ApplicationFee.retrieve_refund('fee_id', 'refund_id')`"
end
end
end

View File

@ -0,0 +1,196 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
module Apps
# Secret Store is an API that allows Stripe Apps developers to securely persist secrets for use by UI Extensions and app backends.
#
# The primary resource in Secret Store is a `secret`. Other apps can't view secrets created by an app. Additionally, secrets are scoped to provide further permission control.
#
# All Dashboard users and the app backend share `account` scoped secrets. Use the `account` scope for secrets that don't change per-user, like a third-party API key.
#
# A `user` scoped secret is accessible by the app backend and one specific Dashboard user. Use the `user` scope for per-user secrets like per-user OAuth tokens, where different users might have different permissions.
#
# Related guide: [Store data between page reloads](https://stripe.com/docs/stripe-apps/store-auth-data-custom-objects)
class Secret < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
OBJECT_NAME = "apps.secret"
def self.object_name
"apps.secret"
end
class Scope < Stripe::StripeObject
# The secret scope type.
attr_reader :type
# The user ID, if type is set to "user"
attr_reader :user
end
class ListParams < Stripe::RequestParams
class Scope < Stripe::RequestParams
# The secret scope type.
attr_accessor :type
# The user ID. This field is required if `type` is set to `user`, and should not be provided if `type` is set to `account`.
attr_accessor :user
def initialize(type: nil, user: nil)
@type = type
@user = user
end
end
# A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
attr_accessor :ending_before
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
attr_accessor :limit
# Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.
attr_accessor :scope
# A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
attr_accessor :starting_after
def initialize(ending_before: nil, expand: nil, limit: nil, scope: nil, starting_after: nil)
@ending_before = ending_before
@expand = expand
@limit = limit
@scope = scope
@starting_after = starting_after
end
end
class CreateParams < Stripe::RequestParams
class Scope < Stripe::RequestParams
# The secret scope type.
attr_accessor :type
# The user ID. This field is required if `type` is set to `user`, and should not be provided if `type` is set to `account`.
attr_accessor :user
def initialize(type: nil, user: nil)
@type = type
@user = user
end
end
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# The Unix timestamp for the expiry time of the secret, after which the secret deletes.
attr_accessor :expires_at
# A name for the secret that's unique within the scope.
attr_accessor :name
# The plaintext secret value to be stored.
attr_accessor :payload
# Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.
attr_accessor :scope
def initialize(expand: nil, expires_at: nil, name: nil, payload: nil, scope: nil)
@expand = expand
@expires_at = expires_at
@name = name
@payload = payload
@scope = scope
end
end
class FindParams < Stripe::RequestParams
class Scope < Stripe::RequestParams
# The secret scope type.
attr_accessor :type
# The user ID. This field is required if `type` is set to `user`, and should not be provided if `type` is set to `account`.
attr_accessor :user
def initialize(type: nil, user: nil)
@type = type
@user = user
end
end
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A name for the secret that's unique within the scope.
attr_accessor :name
# Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.
attr_accessor :scope
def initialize(expand: nil, name: nil, scope: nil)
@expand = expand
@name = name
@scope = scope
end
end
class DeleteWhereParams < Stripe::RequestParams
class Scope < Stripe::RequestParams
# The secret scope type.
attr_accessor :type
# The user ID. This field is required if `type` is set to `user`, and should not be provided if `type` is set to `account`.
attr_accessor :user
def initialize(type: nil, user: nil)
@type = type
@user = user
end
end
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A name for the secret that's unique within the scope.
attr_accessor :name
# Specifies the scoping of the secret. Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user.
attr_accessor :scope
def initialize(expand: nil, name: nil, scope: nil)
@expand = expand
@name = name
@scope = scope
end
end
# Time at which the object was created. Measured in seconds since the Unix epoch.
attr_reader :created
# If true, indicates that this secret has been deleted
attr_reader :deleted
# The Unix timestamp for the expiry time of the secret, after which the secret deletes.
attr_reader :expires_at
# Unique identifier for the object.
attr_reader :id
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
attr_reader :livemode
# A name for the secret that's unique within the scope.
attr_reader :name
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# The plaintext secret value to be stored.
attr_reader :payload
# Attribute for field scope
attr_reader :scope
# Create or replace a secret in the secret store.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/apps/secrets", params: params, opts: opts)
end
# Deletes a secret from the secret store by name and scope.
def self.delete_where(params = {}, opts = {})
request_stripe_object(
method: :post,
path: "/v1/apps/secrets/delete",
params: params,
opts: opts
)
end
# Finds a secret in the secret store by name and scope.
def self.find(params = {}, opts = {})
request_stripe_object(
method: :get,
path: "/v1/apps/secrets/find",
params: params,
opts: opts
)
end
# List all secrets stored on the given scope.
def self.list(params = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/apps/secrets", params: params, opts: opts)
end
end
end
end

View File

@ -0,0 +1,186 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# This is an object representing your Stripe balance. You can retrieve it to see
# the balance currently on your Stripe account.
#
# You can also retrieve the balance history, which contains a list of
# [transactions](https://stripe.com/docs/reporting/balance-transaction-types) that contributed to the balance
# (charges, payouts, and so forth).
#
# The available and pending amounts for each currency are broken down further by
# payment source types.
#
# Related guide: [Understanding Connect account balances](https://stripe.com/docs/connect/account-balances)
class Balance < SingletonAPIResource
OBJECT_NAME = "balance"
def self.object_name
"balance"
end
class Available < Stripe::StripeObject
class SourceTypes < Stripe::StripeObject
# Amount coming from [legacy US ACH payments](https://docs.stripe.com/ach-deprecated).
attr_reader :bank_account
# Amount coming from most payment methods, including cards as well as [non-legacy bank debits](https://docs.stripe.com/payments/bank-debits).
attr_reader :card
# Amount coming from [FPX](https://docs.stripe.com/payments/fpx), a Malaysian payment method.
attr_reader :fpx
end
# Balance amount.
attr_reader :amount
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# Attribute for field source_types
attr_reader :source_types
end
class ConnectReserved < Stripe::StripeObject
class SourceTypes < Stripe::StripeObject
# Amount coming from [legacy US ACH payments](https://docs.stripe.com/ach-deprecated).
attr_reader :bank_account
# Amount coming from most payment methods, including cards as well as [non-legacy bank debits](https://docs.stripe.com/payments/bank-debits).
attr_reader :card
# Amount coming from [FPX](https://docs.stripe.com/payments/fpx), a Malaysian payment method.
attr_reader :fpx
end
# Balance amount.
attr_reader :amount
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# Attribute for field source_types
attr_reader :source_types
end
class InstantAvailable < Stripe::StripeObject
class NetAvailable < Stripe::StripeObject
class SourceTypes < Stripe::StripeObject
# Amount coming from [legacy US ACH payments](https://docs.stripe.com/ach-deprecated).
attr_reader :bank_account
# Amount coming from most payment methods, including cards as well as [non-legacy bank debits](https://docs.stripe.com/payments/bank-debits).
attr_reader :card
# Amount coming from [FPX](https://docs.stripe.com/payments/fpx), a Malaysian payment method.
attr_reader :fpx
end
# Net balance amount, subtracting fees from platform-set pricing.
attr_reader :amount
# ID of the external account for this net balance (not expandable).
attr_reader :destination
# Attribute for field source_types
attr_reader :source_types
end
class SourceTypes < Stripe::StripeObject
# Amount coming from [legacy US ACH payments](https://docs.stripe.com/ach-deprecated).
attr_reader :bank_account
# Amount coming from most payment methods, including cards as well as [non-legacy bank debits](https://docs.stripe.com/payments/bank-debits).
attr_reader :card
# Amount coming from [FPX](https://docs.stripe.com/payments/fpx), a Malaysian payment method.
attr_reader :fpx
end
# Balance amount.
attr_reader :amount
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# Breakdown of balance by destination.
attr_reader :net_available
# Attribute for field source_types
attr_reader :source_types
end
class Issuing < Stripe::StripeObject
class Available < Stripe::StripeObject
class SourceTypes < Stripe::StripeObject
# Amount coming from [legacy US ACH payments](https://docs.stripe.com/ach-deprecated).
attr_reader :bank_account
# Amount coming from most payment methods, including cards as well as [non-legacy bank debits](https://docs.stripe.com/payments/bank-debits).
attr_reader :card
# Amount coming from [FPX](https://docs.stripe.com/payments/fpx), a Malaysian payment method.
attr_reader :fpx
end
# Balance amount.
attr_reader :amount
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# Attribute for field source_types
attr_reader :source_types
end
# Funds that are available for use.
attr_reader :available
end
class Pending < Stripe::StripeObject
class SourceTypes < Stripe::StripeObject
# Amount coming from [legacy US ACH payments](https://docs.stripe.com/ach-deprecated).
attr_reader :bank_account
# Amount coming from most payment methods, including cards as well as [non-legacy bank debits](https://docs.stripe.com/payments/bank-debits).
attr_reader :card
# Amount coming from [FPX](https://docs.stripe.com/payments/fpx), a Malaysian payment method.
attr_reader :fpx
end
# Balance amount.
attr_reader :amount
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# Attribute for field source_types
attr_reader :source_types
end
class RefundAndDisputePrefunding < Stripe::StripeObject
class Available < Stripe::StripeObject
class SourceTypes < Stripe::StripeObject
# Amount coming from [legacy US ACH payments](https://docs.stripe.com/ach-deprecated).
attr_reader :bank_account
# Amount coming from most payment methods, including cards as well as [non-legacy bank debits](https://docs.stripe.com/payments/bank-debits).
attr_reader :card
# Amount coming from [FPX](https://docs.stripe.com/payments/fpx), a Malaysian payment method.
attr_reader :fpx
end
# Balance amount.
attr_reader :amount
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# Attribute for field source_types
attr_reader :source_types
end
class Pending < Stripe::StripeObject
class SourceTypes < Stripe::StripeObject
# Amount coming from [legacy US ACH payments](https://docs.stripe.com/ach-deprecated).
attr_reader :bank_account
# Amount coming from most payment methods, including cards as well as [non-legacy bank debits](https://docs.stripe.com/payments/bank-debits).
attr_reader :card
# Amount coming from [FPX](https://docs.stripe.com/payments/fpx), a Malaysian payment method.
attr_reader :fpx
end
# Balance amount.
attr_reader :amount
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# Attribute for field source_types
attr_reader :source_types
end
# Funds that are available for use.
attr_reader :available
# Funds that are pending
attr_reader :pending
end
# Available funds that you can transfer or pay out automatically by Stripe or explicitly through the [Transfers API](https://stripe.com/docs/api#transfers) or [Payouts API](https://stripe.com/docs/api#payouts). You can find the available balance for each currency and payment type in the `source_types` property.
attr_reader :available
# Funds held due to negative balances on connected accounts where [account.controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `application`, which includes Custom accounts. You can find the connect reserve balance for each currency and payment type in the `source_types` property.
attr_reader :connect_reserved
# Funds that you can pay out using Instant Payouts.
attr_reader :instant_available
# Attribute for field issuing
attr_reader :issuing
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
attr_reader :livemode
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# Funds that aren't available in the balance yet. You can find the pending balance for each currency and each payment type in the `source_types` property.
attr_reader :pending
# Attribute for field refund_and_dispute_prefunding
attr_reader :refund_and_dispute_prefunding
end
end

View File

@ -0,0 +1,134 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# Balance transactions represent funds moving through your Stripe account.
# Stripe creates them for every type of transaction that enters or leaves your Stripe account balance.
#
# Related guide: [Balance transaction types](https://stripe.com/docs/reports/balance-transaction-types)
class BalanceTransaction < APIResource
extend Stripe::APIOperations::List
OBJECT_NAME = "balance_transaction"
def self.object_name
"balance_transaction"
end
class FeeDetail < Stripe::StripeObject
# Amount of the fee, in cents.
attr_reader :amount
# ID of the Connect application that earned the fee.
attr_reader :application
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# An arbitrary string attached to the object. Often useful for displaying to users.
attr_reader :description
# Type of the fee, one of: `application_fee`, `payment_method_passthrough_fee`, `stripe_fee` or `tax`.
attr_reader :type
end
class ListParams < Stripe::RequestParams
class Created < Stripe::RequestParams
# Minimum value to filter by (exclusive)
attr_accessor :gt
# Minimum value to filter by (inclusive)
attr_accessor :gte
# Maximum value to filter by (exclusive)
attr_accessor :lt
# Maximum value to filter by (inclusive)
attr_accessor :lte
def initialize(gt: nil, gte: nil, lt: nil, lte: nil)
@gt = gt
@gte = gte
@lt = lt
@lte = lte
end
end
# Only return transactions that were created during the given date interval.
attr_accessor :created
# Only return transactions in a certain currency. Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_accessor :currency
# A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
attr_accessor :ending_before
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
attr_accessor :limit
# For automatic Stripe payouts only, only returns transactions that were paid out on the specified payout ID.
attr_accessor :payout
# Only returns the original transaction.
attr_accessor :source
# A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
attr_accessor :starting_after
# Only returns transactions of the given type. One of: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_outbound`, `obligation_reversal_inbound`, `payment`, `payment_failure_refund`, `payment_network_reserve_hold`, `payment_network_reserve_release`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `payout_minimum_balance_hold`, `payout_minimum_balance_release`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `stripe_balance_payment_debit`, `stripe_balance_payment_debit_reversal`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`.
attr_accessor :type
def initialize(
created: nil,
currency: nil,
ending_before: nil,
expand: nil,
limit: nil,
payout: nil,
source: nil,
starting_after: nil,
type: nil
)
@created = created
@currency = currency
@ending_before = ending_before
@expand = expand
@limit = limit
@payout = payout
@source = source
@starting_after = starting_after
@type = type
end
end
# Gross amount of this transaction (in cents (or local equivalent)). A positive value represents funds charged to another party, and a negative value represents funds sent to another party.
attr_reader :amount
# The date that the transaction's net funds become available in the Stripe balance.
attr_reader :available_on
# The balance that this transaction impacts.
attr_reader :balance_type
# Time at which the object was created. Measured in seconds since the Unix epoch.
attr_reader :created
# Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
attr_reader :currency
# An arbitrary string attached to the object. Often useful for displaying to users.
attr_reader :description
# If applicable, this transaction uses an exchange rate. If money converts from currency A to currency B, then the `amount` in currency A, multipled by the `exchange_rate`, equals the `amount` in currency B. For example, if you charge a customer 10.00 EUR, the PaymentIntent's `amount` is `1000` and `currency` is `eur`. If this converts to 12.34 USD in your Stripe account, the BalanceTransaction's `amount` is `1234`, its `currency` is `usd`, and the `exchange_rate` is `1.234`.
attr_reader :exchange_rate
# Fees (in cents (or local equivalent)) paid for this transaction. Represented as a positive integer when assessed.
attr_reader :fee
# Detailed breakdown of fees (in cents (or local equivalent)) paid for this transaction.
attr_reader :fee_details
# Unique identifier for the object.
attr_reader :id
# Net impact to a Stripe balance (in cents (or local equivalent)). A positive value represents incrementing a Stripe balance, and a negative value decrementing a Stripe balance. You can calculate the net impact of a transaction on a balance by `amount` - `fee`
attr_reader :net
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# Learn more about how [reporting categories](https://stripe.com/docs/reports/reporting-categories) can help you understand balance transactions from an accounting perspective.
attr_reader :reporting_category
# This transaction relates to the Stripe object.
attr_reader :source
# The transaction's net funds status in the Stripe balance, which are either `available` or `pending`.
attr_reader :status
# Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_outbound`, `obligation_reversal_inbound`, `payment`, `payment_failure_refund`, `payment_network_reserve_hold`, `payment_network_reserve_release`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `payout_minimum_balance_hold`, `payout_minimum_balance_release`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `stripe_balance_payment_debit`, `stripe_balance_payment_debit_reversal`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`. Learn more about [balance transaction types and what they represent](https://stripe.com/docs/reports/balance-transaction-types). To classify transactions for accounting purposes, consider `reporting_category` instead.
attr_reader :type
# Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.
#
# Note that this endpoint was previously called “Balance history” and used the path /v1/balance/history.
def self.list(params = {}, opts = {})
request_stripe_object(
method: :get,
path: "/v1/balance_transactions",
params: params,
opts: opts
)
end
end
end

View File

@ -0,0 +1,174 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
# These bank accounts are payment methods on `Customer` objects.
#
# On the other hand [External Accounts](https://docs.stripe.com/api#external_accounts) are transfer
# destinations on `Account` objects for connected accounts.
# They can be bank accounts or debit cards as well, and are documented in the links above.
#
# Related guide: [Bank debits and transfers](https://docs.stripe.com/payments/bank-debits-transfers)
class BankAccount < APIResource
include Stripe::APIOperations::Delete
extend Stripe::APIOperations::List
include Stripe::APIOperations::Save
OBJECT_NAME = "bank_account"
def self.object_name
"bank_account"
end
class FutureRequirements < Stripe::StripeObject
class Error < Stripe::StripeObject
# The code for the type of error.
attr_reader :code
# An informative message that indicates the error type and provides additional details about the error.
attr_reader :reason
# The specific user onboarding requirement field (in the requirements hash) that needs to be resolved.
attr_reader :requirement
end
# Fields that need to be collected to keep the external account enabled. If not collected by `current_deadline`, these fields appear in `past_due` as well, and the account is disabled.
attr_reader :currently_due
# Fields that are `currently_due` and need to be collected again because validation or verification failed.
attr_reader :errors
# Fields that weren't collected by `current_deadline`. These fields need to be collected to enable the external account.
attr_reader :past_due
# Fields that might become required depending on the results of verification or review. It's an empty array unless an asynchronous verification is pending. If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. Fields might appear in `eventually_due`, `currently_due`, or `past_due` and in `pending_verification` if verification fails but another verification is still pending.
attr_reader :pending_verification
end
class Requirements < Stripe::StripeObject
class Error < Stripe::StripeObject
# The code for the type of error.
attr_reader :code
# An informative message that indicates the error type and provides additional details about the error.
attr_reader :reason
# The specific user onboarding requirement field (in the requirements hash) that needs to be resolved.
attr_reader :requirement
end
# Fields that need to be collected to keep the external account enabled. If not collected by `current_deadline`, these fields appear in `past_due` as well, and the account is disabled.
attr_reader :currently_due
# Fields that are `currently_due` and need to be collected again because validation or verification failed.
attr_reader :errors
# Fields that weren't collected by `current_deadline`. These fields need to be collected to enable the external account.
attr_reader :past_due
# Fields that might become required depending on the results of verification or review. It's an empty array unless an asynchronous verification is pending. If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. Fields might appear in `eventually_due`, `currently_due`, or `past_due` and in `pending_verification` if verification fails but another verification is still pending.
attr_reader :pending_verification
end
# The account this bank account belongs to. Only applicable on Accounts (not customers or recipients) This property is only available when returned as an [External Account](/api/external_account_bank_accounts/object) where [controller.is_controller](/api/accounts/object#account_object-controller-is_controller) is `true`.
attr_reader :account
# The name of the person or business that owns the bank account.
attr_reader :account_holder_name
# The type of entity that holds the account. This can be either `individual` or `company`.
attr_reader :account_holder_type
# The bank account type. This can only be `checking` or `savings` in most countries. In Japan, this can only be `futsu` or `toza`.
attr_reader :account_type
# A set of available payout methods for this bank account. Only values from this set should be passed as the `method` when creating a payout.
attr_reader :available_payout_methods
# Name of the bank associated with the routing number (e.g., `WELLS FARGO`).
attr_reader :bank_name
# Two-letter ISO code representing the country the bank account is located in.
attr_reader :country
# Three-letter [ISO code for the currency](https://stripe.com/docs/payouts) paid out to the bank account.
attr_reader :currency
# The ID of the customer that the bank account is associated with.
attr_reader :customer
# Whether this bank account is the default external account for its currency.
attr_reader :default_for_currency
# Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
attr_reader :fingerprint
# Information about the [upcoming new requirements for the bank account](https://stripe.com/docs/connect/custom-accounts/future-requirements), including what information needs to be collected, and by when.
attr_reader :future_requirements
# Unique identifier for the object.
attr_reader :id
# The last four digits of the bank account number.
attr_reader :last4
# Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
attr_reader :metadata
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# Information about the requirements for the bank account, including what information needs to be collected.
attr_reader :requirements
# The routing transit number for the bank account.
attr_reader :routing_number
# For bank accounts, possible values are `new`, `validated`, `verified`, `verification_failed`, or `errored`. A bank account that hasn't had any activity or validation performed is `new`. If Stripe can determine that the bank account exists, its status will be `validated`. Note that there often isnt enough information to know (e.g., for smaller credit unions), and the validation is not always run. If customer bank account verification has succeeded, the bank account status will be `verified`. If the verification failed for any reason, such as microdeposit failure, the status will be `verification_failed`. If a payout sent to this bank account fails, we'll set the status to `errored` and will not continue to send [scheduled payouts](https://stripe.com/docs/payouts#payout-schedule) until the bank details are updated.
#
# For external accounts, possible values are `new`, `errored` and `verification_failed`. If a payout fails, the status is set to `errored` and scheduled payouts are stopped until account details are updated. In the US and India, if we can't [verify the owner of the bank account](https://support.stripe.com/questions/bank-account-ownership-verification), we'll set the status to `verification_failed`. Other validations aren't run against external accounts because they're only used for payouts. This means the other statuses don't apply.
attr_reader :status
# Always true for a deleted object
attr_reader :deleted
def verify(params = {}, opts = {})
request_stripe_object(
method: :post,
path: "#{Customer.resource_url}/#{customer}/sources/#{id}/verify",
params: params,
opts: opts
)
end
def self.verify(customer, id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: "#{Customer.resource_url}/#{customer}/sources/#{id}/verify",
params: params,
opts: opts
)
end
def resource_url
if !customer.nil?
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
elsif !account.nil?
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
else
raise InvalidRequestError, "Could not determine which URL to request: [account, customer] fields are all null"
end
end
def self.update(_id, _params = nil, _opts = nil)
raise NotImplementedError,
"Bank accounts cannot be updated without a customer ID or an " \
"account ID. Update a bank account using " \
"`Customer.update_source('customer_id', 'bank_account_id', " \
"update_params)` or `Account.update_external_account(" \
"'account_id', 'bank_account_id', update_params)`"
end
def self.retrieve(_id, _opts = nil)
raise NotImplementedError,
"Bank accounts cannot be retrieve without a customer ID or an " \
"account ID. Retrieve a bank account using " \
"`Customer.retrieve_source('customer_id', 'bank_account_id')` " \
"or `Account.retrieve_external_account('account_id', " \
"'bank_account_id')`"
end
def self.delete(id, params = {}, opts = {})
raise NotImplementedError,
"Bank accounts cannot be deleted without a customer ID or an " \
"account ID. Delete a bank account using " \
"`Customer.delete_source('customer_id', 'bank_account_id')` " \
"or `Account.delete_external_account('account_id', " \
"'bank_account_id')`"
end
def delete(params = {}, opts = {})
request_stripe_object(
method: :delete,
path: resource_url.to_s,
params: params,
opts: opts
)
end
def self.list(params = {}, opts = {})
raise NotImplementedError,
"Bank accounts cannot be listed without a customer ID or an " \
"account ID. List bank accounts using " \
"`Customer.list_sources('customer_id')` " \
"or `Account.list_external_accounts('account_id')`"
end
end
end

View File

@ -0,0 +1,222 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
module Billing
# A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests.
class Alert < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
OBJECT_NAME = "billing.alert"
def self.object_name
"billing.alert"
end
class UsageThreshold < Stripe::StripeObject
class Filter < Stripe::StripeObject
# Limit the scope of the alert to this customer ID
attr_reader :customer
# Attribute for field type
attr_reader :type
end
# The filters allow limiting the scope of this usage alert. You can only specify up to one filter at this time.
attr_reader :filters
# The value at which this alert will trigger.
attr_reader :gte
# The [Billing Meter](/api/billing/meter) ID whose usage is monitored.
attr_reader :meter
# Defines how the alert will behave.
attr_reader :recurrence
end
class ListParams < Stripe::RequestParams
# Filter results to only include this type of alert.
attr_accessor :alert_type
# A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
attr_accessor :ending_before
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
attr_accessor :limit
# Filter results to only include alerts with the given meter.
attr_accessor :meter
# A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
attr_accessor :starting_after
def initialize(
alert_type: nil,
ending_before: nil,
expand: nil,
limit: nil,
meter: nil,
starting_after: nil
)
@alert_type = alert_type
@ending_before = ending_before
@expand = expand
@limit = limit
@meter = meter
@starting_after = starting_after
end
end
class CreateParams < Stripe::RequestParams
class UsageThreshold < Stripe::RequestParams
class Filter < Stripe::RequestParams
# Limit the scope to this usage alert only to this customer.
attr_accessor :customer
# What type of filter is being applied to this usage alert.
attr_accessor :type
def initialize(customer: nil, type: nil)
@customer = customer
@type = type
end
end
# The filters allows limiting the scope of this usage alert. You can only specify up to one filter at this time.
attr_accessor :filters
# Defines at which value the alert will fire.
attr_accessor :gte
# The [Billing Meter](/api/billing/meter) ID whose usage is monitored.
attr_accessor :meter
# Whether the alert should only fire only once, or once per billing cycle.
attr_accessor :recurrence
def initialize(filters: nil, gte: nil, meter: nil, recurrence: nil)
@filters = filters
@gte = gte
@meter = meter
@recurrence = recurrence
end
end
# The type of alert to create.
attr_accessor :alert_type
# Specifies which fields in the response should be expanded.
attr_accessor :expand
# The title of the alert.
attr_accessor :title
# The configuration of the usage threshold.
attr_accessor :usage_threshold
def initialize(alert_type: nil, expand: nil, title: nil, usage_threshold: nil)
@alert_type = alert_type
@expand = expand
@title = title
@usage_threshold = usage_threshold
end
end
class ActivateParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(expand: nil)
@expand = expand
end
end
class ArchiveParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(expand: nil)
@expand = expand
end
end
class DeactivateParams < Stripe::RequestParams
# Specifies which fields in the response should be expanded.
attr_accessor :expand
def initialize(expand: nil)
@expand = expand
end
end
# Defines the type of the alert.
attr_reader :alert_type
# Unique identifier for the object.
attr_reader :id
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
attr_reader :livemode
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# Status of the alert. This can be active, inactive or archived.
attr_reader :status
# Title of the alert.
attr_reader :title
# Encapsulates configuration of the alert to monitor usage on a specific [Billing Meter](https://stripe.com/docs/api/billing/meter).
attr_reader :usage_threshold
# Reactivates this alert, allowing it to trigger again.
def activate(params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/billing/alerts/%<id>s/activate", { id: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
# Reactivates this alert, allowing it to trigger again.
def self.activate(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/billing/alerts/%<id>s/activate", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
# Archives this alert, removing it from the list view and APIs. This is non-reversible.
def archive(params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/billing/alerts/%<id>s/archive", { id: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
# Archives this alert, removing it from the list view and APIs. This is non-reversible.
def self.archive(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/billing/alerts/%<id>s/archive", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
# Creates a billing alert
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/billing/alerts", params: params, opts: opts)
end
# Deactivates this alert, preventing it from triggering.
def deactivate(params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/billing/alerts/%<id>s/deactivate", { id: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end
# Deactivates this alert, preventing it from triggering.
def self.deactivate(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/billing/alerts/%<id>s/deactivate", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
# Lists billing active and inactive alerts
def self.list(params = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/billing/alerts", params: params, opts: opts)
end
end
end
end

View File

@ -0,0 +1,26 @@
# File generated from our OpenAPI spec
# frozen_string_literal: true
module Stripe
module Billing
class AlertTriggered < APIResource
OBJECT_NAME = "billing.alert_triggered"
def self.object_name
"billing.alert_triggered"
end
# A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests.
attr_reader :alert
# Time at which the object was created. Measured in seconds since the Unix epoch.
attr_reader :created
# ID of customer for which the alert triggered
attr_reader :customer
# Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
attr_reader :livemode
# String representing the object's type. Objects of the same type share the same value.
attr_reader :object
# The value triggering the alert
attr_reader :value
end
end
end

Some files were not shown because too many files have changed in this diff Show More