-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use sdk_uuid for payment and setup intents #551
Conversation
src/functions.ts
Outdated
): Promise<SetupIntentResultType> { | ||
return Logger.traceSdkMethod(async (innerSetupIntentId) => { | ||
return Logger.traceSdkMethod(async (innerSetupInten) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, should be innerSetupIntent
paymentIntentId: string | ||
paymentIntentJson: PaymentIntent.Type | ||
): Promise<PaymentIntentResultType>; | ||
// Create Setup Intent | ||
createSetupIntent( | ||
params: CreateSetupIntentParams | ||
): Promise<SetupIntentResultType>; | ||
// Cancel Payment Intent | ||
cancelPaymentIntent( | ||
paymentIntentId: string | ||
paymentIntent: PaymentIntent.Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need these updates for cancelSetupIntent
and confirmSetupIntent
as well
src/StripeTerminalSdk.tsx
Outdated
@@ -108,11 +108,15 @@ export interface StripeTerminalSdkType { | |||
clearReaderDisplay(): Promise<ClearReaderDisplayResultType>; | |||
retrieveSetupIntent(clientSecret: string): Promise<SetupIntentResultType>; | |||
// Cancel Setup Intent | |||
cancelSetupIntent(paymentIntentId: string): Promise<SetupIntentResultType>; | |||
cancelSetupIntent( | |||
paymentIntent: PaymentIntent.Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be setupIntent: SetupIntent.Type
src/StripeTerminalSdk.tsx
Outdated
// List of locations belonging to the merchant | ||
getLocations(params: GetLocationsParams): Promise<GetLocationsResultType>; | ||
// Confirm Setup Intent | ||
confirmSetupIntent(paymentIntentId: string): Promise<SetupIntentResultType>; | ||
confirmSetupIntent( | ||
paymentIntent: PaymentIntent.Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS changes LGTM aside from a non-blocking request to improve the error messaging on the UUID checks to make those a little friendlier since the UUID is an internal detail
ios/StripeTerminalReactNative.swift
Outdated
guard let uuid = paymentIntentJSON["sdk_uuid"] as? String else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide sdk_uuid.")) | ||
return | ||
} | ||
guard let paymentIntent = self.paymentIntents[Optional(id)] else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "There is no associated paymentIntent with id \(id)")) | ||
guard let paymentIntent = self.paymentIntents[uuid] else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "There is no associated paymentIntent with uuid \(uuid)")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit-ish: We should probably improve the error messaging here since the UUID is an internal detail that a user wouldn't know how to debug without digging in to the SDK more.
suggestion for if no UUID in the dictionary:
Unexpected PaymentIntent. collectPaymentMethod requires you to use the PaymentIntent that was returned from either createPaymentIntent or retrievePaymentIntent.
suggestion for if it has a UUID but we don't have a matching entry:
Unexpected PaymentIntent. The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent. This can happen if the reader disconnected, another PaymentIntent was confirmed, or the PaymentIntent was canceled.
^ got there from reviewing when we clear out self.paymentIntents and disconnect, post confirm, and cancel are the when we do that. So if someone
- created a PI A
- created a PI B
- collected and confirmed PI A
- attempted to collect PI B the SDK would error with the miss on paymentIntents[uuid] and they'd get this second error message telling to re-retrieve or create a new PI. (if I understand correctly this shouldn't be a new problem...before they would have gotten the "There is no associated paymentIntent with id (id)" error)
(and if we do improve the error messages we should do the same in the android layer too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even though it's an internal detail I feel like it is good for users to know exactly what is wrong with the PI they provided. We often get user inquiries on parameters due to vague error messages that don't tell which param or field caused the issue.
The PaymentIntent is missing sdk_uuid field.
No PaymentIntent was found with the sdk_uuid {some_uuid}. The PaymentIntent provided must be re-retrieved with retrievePaymentIntent or a new PaymentIntent must be created with createPaymentIntent.
would you be okay if we changed it to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, sounds good to me
ios/StripeTerminalReactNative.swift
Outdated
guard let uuid = paymentIntentJson["sdk_uuid"] as? String else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide sdk_uuid.")) | ||
return | ||
} | ||
|
||
guard let paymentIntent = paymentIntents[Optional(id)] else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "There is no associated paymentIntent with id \(id)")) | ||
guard let paymentIntent = self.paymentIntents[uuid] else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "There is no associated paymentIntent with uuid \(uuid)")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar request for improved error messaging here
ios/StripeTerminalReactNative.swift
Outdated
guard let uuid = paymentIntentJson["sdk_uuid"] as? String else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide sdk_uuid.")) | ||
return | ||
} | ||
guard let paymentIntent = paymentIntents[Optional(id)] else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "There is no associated paymentIntent with id \(id)")) | ||
guard let paymentIntent = self.paymentIntents[uuid] else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "There is no associated paymentIntent with uuid \(uuid)")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
ios/StripeTerminalReactNative.swift
Outdated
guard let uuid = setupIntentJson["sdk_uuid"] as? String else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide sdk_uuid.")) | ||
return | ||
} | ||
guard let setupIntent = setupIntents[id] else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "There is no associated setupIntentId with id \(id)")) | ||
guard let setupIntent = self.setupIntents[uuid] else { | ||
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "There is no associated setupIntentId with id \(uuid)")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and for the 3 SetupIntent ones too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 lgtm, thanks for the updates!
Summary
Updates PaymentIntent and SetupIntent methods to take the whole model and identify the PI based on a newly generated UUID.
Motivation
Offline mode prep
Testing
Documentation
Select one: