Skip to content
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

Support CollectData feature #765

Merged
merged 6 commits into from
Aug 8, 2024
Merged

Support CollectData feature #765

merged 6 commits into from
Aug 8, 2024

Conversation

EricLin-BBpos
Copy link
Collaborator

Summary

Add collectData feature in sdk

Motivation

Support new collectData feature

Testing

  • I tested this manually
  • I added automated tests

Documentation

Select one:

  • I have added relevant documentation for my changes.
  • This PR does not result in any developer-facing changes.

Copy link

@ebarrenechea-stripe ebarrenechea-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on the Android and TS side of things. @bric-stripe could you check the iOS changes? 🙇

switch type {
case "unknown": return CollectDataType.unknown
case "magstripe": return CollectDataType.magstripe
default: return CollectDataType.unknown
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preference for unknown default so we get warnings/errors when new enum values are added in the native SDK

and I think we should return nil for the default case since this is marked nullable and null is handled in the caller

Suggested change
default: return CollectDataType.unknown
@unknown default: return nil

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emm..it seems that @unknown cannot be used here because it can only be utilized in switch statements within enumeration types.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that makes sense I didn't think about that since this is going back from strings. ignore that bit then 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its still worth returning nil though so we get a RN side error when the input is validated

Comment on lines 1016 to 1018
} else {
resolve(collectedData != nil ? Mappers.mapFromCollectedData(collectedData!) : [:])
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but I think this reads a little better and avoids the force unwrap

Suggested change
} else {
resolve(collectedData != nil ? Mappers.mapFromCollectedData(collectedData!) : [:])
}
} else if let collectedData {
resolve(Mappers.mapFromCollectedData(collectedData))
} else {
// Unexpected
resolve([:])
}

Copy link
Collaborator

@mindy-stripe mindy-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requesting changes for minor formatting and typos


fun mapFromCollectedData(collectData: CollectedData): ReadableMap {
return nativeMapOf {
putString("stripeId",collectData.id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting nit:

Suggested change
putString("stripeId",collectData.id)
putString("stripeId", collectData.id)

}

fun mapFromCollectDataType(type: String): CollectDataType? {
return when(type) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting nit:

Suggested change
return when(type) {
return when (type) {

val collectDataType = requireParam(mapFromCollectDataType(collectDataTypeParam)) {
"Unknown collectDataType: $collectDataTypeParam"
}
val enableCustomerCancellation = getBoolean(params,"enableCustomerCancellation")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting nit:

Suggested change
val enableCustomerCancellation = getBoolean(params,"enableCustomerCancellation")
val enableCustomerCancellation = getBoolean(params, "enableCustomerCancellation")


let collectDataType = Mappers.mapToCollectDataType(collectDataTypeParam)
guard let collectDataType else {
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide correct collectDataType parameter."))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would recommend keeping this the same as android

Suggested change
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide correct collectDataType parameter."))
resolve(Errors.createError(code: CommonErrorType.InvalidRequiredParameter, message: "You must provide a collectDataType"))


let collectDataConfig: CollectDataConfiguration
do {
collectDataConfig = try CollectDataConfigurationBuilder().setCollectDataType(collectDataType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enableCustomerCancellation is missing here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enableCustomerCancellation seem have not support in IOS SDK yet

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! thanks for pointing that out 👍


export enum CollectDataType {
MAGSTRIPE = 'magstripe',
UNKNOW = 'unknown',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo:

Suggested change
UNKNOW = 'unknown',
UNKNOWN = 'unknown',

@@ -490,3 +490,29 @@ export type AmountDetails = {
export type Amount = {
amount: number;
};

export type CollectData = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - this should match the iOS and Android types:

Suggested change
export type CollectData = {
export type CollectedData = {

Copy link
Collaborator

@mindy-stripe mindy-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for addressing feedback!

@nazli-stripe nazli-stripe merged commit b3fa9df into main Aug 8, 2024
3 checks passed
@nazli-stripe nazli-stripe deleted the bbpos/support-collectData branch September 7, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants