Skip to content

Commit 3a5109b

Browse files
authored
Add warnings for Stripe obj returns, and change connection token endpoint (stripe#16)
As the warnings say, our example code creates a direct dependency between the server's `Stripe.api_version` and the clients that consume the example backend responses. This means clients must also be prepared for Backwards-compatible changes at any time https://stripe.com/docs/upgrades#what-changes-does-stripe-consider-to-be-backwards-compatible And it means that for the server to adopt a breaking change, all of their clients must also be prepared for it. Changing the `/connection_token` so that it is *not* dependent on the Stripe response, and putting notes on the other two.
1 parent 61d2108 commit 3a5109b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

web.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def validateApiKey
7171
log_info("Reader registered: #{reader.id}")
7272

7373
status 200
74+
# Note that returning the Stripe reader object directly creates a dependency between your
75+
# backend's Stripe.api_version and your clients, making future upgrades more complicated.
76+
# All clients must also be ready for backwards-compatible changes at any time:
77+
# https://stripe.com/docs/upgrades#what-changes-does-stripe-consider-to-be-backwards-compatible
7478
return reader.to_json
7579
end
7680

@@ -95,7 +99,7 @@ def validateApiKey
9599

96100
content_type :json
97101
status 200
98-
token.to_json
102+
return {:secret => token.secret}.to_json
99103
end
100104

101105
# This endpoint creates a PaymentIntent.
@@ -106,7 +110,7 @@ def validateApiKey
106110
status 400
107111
return log_info(validationError)
108112
end
109-
113+
110114
begin
111115
payment_intent = Stripe::PaymentIntent.create(
112116
:payment_method_types => ['card_present'],
@@ -179,5 +183,9 @@ def lookupOrCreateExampleCustomer
179183
log_info("Attached PaymentMethod to Customer: #{customer.id}")
180184

181185
status 200
186+
# Note that returning the Stripe payment_method object directly creates a dependency between your
187+
# backend's Stripe.api_version and your clients, making future upgrades more complicated.
188+
# All clients must also be ready for backwards-compatible changes at any time:
189+
# https://stripe.com/docs/upgrades#what-changes-does-stripe-consider-to-be-backwards-compatible
182190
return payment_method.to_json
183191
end

0 commit comments

Comments
 (0)