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

StripeSetupIntent.isSuccess coming back as false in iOS #130

Open
jonsabogal opened this issue May 26, 2021 · 11 comments
Open

StripeSetupIntent.isSuccess coming back as false in iOS #130

jonsabogal opened this issue May 26, 2021 · 11 comments

Comments

@jonsabogal
Copy link

I followed the demo angular tutorial to allow user to store payment method (credit card) on stripe and it works successfully in both iOS and android - I can see the card becoming visible in stripe dashboard and all event logs as expected with a "succeeded" on all statuses that I can see.
However on the last call I am using StripeSetupInten.isSuccess property as a signal that everything went ok to close my modal that has CreditCardView in it. In android this is coming back as true, but in iOS it's coming back as false, and I'm not sure why given everything went fine behind the scenes.

Below is snippet of relevant code. The method at the bottom handles the last bit of the process and you can see where I depend on the isSuccess property. Like I said all logs I see from these calls in stripe are good and the card is being added as expected, but isSuccess is coming back false in iOS. Once I close out of my modal manually and refresh a list view I have as the parent I can actually retrieve the credit card that was just added.

If there's no immediate fix, is there any other indicator I can use to ensure everything went ok in iOS?

`onSave(cardView: CreditCardView) {
this.creditCardView = cardView;
this.setupIntentSecret$ = this.paymentFormService.getPaymentMethodSetupIntentSecret(this.user.userId);
this.subscribeToSetupIntent();
}

subscribeToSetupIntent() {
  this.setupIntentSecret$.subscribe(
    secret => {
        if (!this.helperMethods.isStringNullOrEmpty(secret)) {
            this.setupIntentSecret = secret;
            this.confirmPaymentMethodSetupIntent();
        }
    })  
}

confirmPaymentMethodSetupIntent() {
  let stripe = new Stripe(this.publishableKey);
  stripe.createPaymentMethod(this.creditCardView.cardParams, (error, pm) => {
    stripe.confirmSetupIntent(pm.id, this.setupIntentSecret, (error, setupIntent) => {        
      if (setupIntent.isSuccess) {
        this.modalParams.closeCallback(1);
      }
    });
  });
}`

Screen Shot 2021-05-25 at 11 32 19 PM

my package.json
{
"name": "@nativescript/template-tab-navigation-ng",
"main": "main.js",
"displayName": "Tabs",
"templateType": "App template",
"version": "7.0.6",
"description": "NativeScript Application",
"author": "NativeScript Team [email protected]",
"license": "SEE LICENSE IN ",
"publishConfig": {
"access": "public"
},
"keywords": [
"nstudio",
"nativescript",
"mobile",
"angular",
"{N}",
"tns",
"template",
"tab",
"navigation",
"category-general"
],
"repository": "",
"homepage": "https://github.com/NativeScript/nativescript-app-templates",
"bugs": {
"url": "https://github.com/NativeScript/NativeScript/issues"
},
"scripts": {
"lint": "tslint "src/**/*.ts""
},
"dependencies": {
"@angular/animations": "~11.0.0",
"@angular/common": "~11.0.0",
"@angular/compiler": "~11.0.0",
"@angular/core": "~11.0.0",
"@angular/forms": "~11.0.0",
"@angular/platform-browser": "~11.0.0",
"@angular/platform-browser-dynamic": "~11.0.0",
"@angular/router": "~11.0.0",
"@nativescript/angular": "~11.0.0",
"@nativescript/camera": "^5.0.8",
"@nativescript/core": "~7.1.0",
"@nativescript/firebase": "^11.1.3",
"@nativescript/theme": "~2.3.0",
"@triniwiz/nativescript-stripe": "^7.0.0-alpha13",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.6.0",
"zone.js": "~0.11.1"
},
"devDependencies": {
"@angular/compiler-cli": "~11.0.0",
"@nativescript/android": "7.0.1",
"@nativescript/ios": "7.1.1",
"@nativescript/webpack": "~4.0.0",
"@ngtools/webpack": "~11.0.0",
"codelyzer": "~6.0.0",
"node-sass": "^4.14.1",
"tslint": "~6.1.3",
"typescript": "~4.0.0"
},
"private": "true",
"readme": "NativeScript Application"
}

@triniwiz
Copy link
Owner

Can you try @triniwiz/[email protected] an lmk

@jonsabogal
Copy link
Author

@triniwiz I removed the old version node module folder and upgraded to that version and the issue is still there in iOS

@triniwiz
Copy link
Owner

Ok @triniwiz/[email protected] should be it

@jonsabogal
Copy link
Author

upgraded to beta-1 and get this error on ns run ios:

ERROR in ../node_modules/@triniwiz/nativescript-stripe/angular/index.ts
Module build failed (from ../node_modules/@ngtools/webpack/src/index.js):
Error: /Users/gonzalo/Repos/BoxGo-customer-mobile/node_modules/@triniwiz/nativescript-stripe/angular/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
at NativeScriptAngularCompilerPlugin.getCompiledFile (/Users/gonzalo/Repos/BoxGo-customer-mobile/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:951:23)
at NativeScriptAngularCompilerPlugin.getCompiledFile (/Users/gonzalo/Repos/BoxGo-customer-mobile/node_modules/@nativescript/webpack/plugins/NativeScriptAngularCompilerPlugin.js:29:26)
at /Users/gonzalo/Repos/BoxGo-customer-mobile/node_modules/@ngtools/webpack/src/loader.js:43:31
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:93:5)
@ ./app/app.module.ts 3:0-77 19:12-32 26:8-28 39:20-40
@ ./main.ts

ERROR in ../node_modules/@triniwiz/nativescript-stripe/index.ts
Module build failed (from ../node_modules/@ngtools/webpack/src/index.js):
Error: /Users/gonzalo/Repos/BoxGo-customer-mobile/node_modules/@triniwiz/nativescript-stripe/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
at NativeScriptAngularCompilerPlugin.getCompiledFile (/Users/gonzalo/Repos/BoxGo-customer-mobile/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:951:23)
at NativeScriptAngularCompilerPlugin.getCompiledFile (/Users/gonzalo/Repos/BoxGo-customer-mobile/node_modules/@nativescript/webpack/plugins/NativeScriptAngularCompilerPlugin.js:29:26)
at /Users/gonzalo/Repos/BoxGo-customer-mobile/node_modules/@ngtools/webpack/src/loader.js:43:31
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:93:5)
@ ./app/account/payment-method-form/payment-method-form.component.ts 5:0-55 63:25-31
@ ./app/account/account.module.ts
@ ./app/tabs/tabs-routing.module.ts
@ ./app/tabs/tabs.module.ts
@ ./app/app-routing.module.ts
@ ./app/app.module.ts
@ ./main.ts

@triniwiz
Copy link
Owner

That one was on me 😂 use @triniwiz/[email protected]

@jonsabogal
Copy link
Author

@triniwiz I updated to beta 2 and now I get this error on ns run ios (it never deploys to my iphone)

error: There is no XCFramework found at '/Users/gonzalo/Repos/BoxGo-customer-mobile/node_modules/@triniwiz/nativescript-stripe/platforms/ios/Stripe.xcframework'.

** ARCHIVE FAILED **

I then went back to alpha13 and same error (alpha13 used to work just fine). then I noticed beta 3 is out but getting the same error. I am not sure if it's my environment somehow or the plug in. I didn't change anything other than the plug in version..

@jonsabogal
Copy link
Author

@triniwiz nevermind my comment above, I wiped out all npm modules to start from scratch and beta 3 builds and runs fine. However the issue about isSuccess coming back as false is still there in iOS.

@triniwiz
Copy link
Owner

Can you try console.dir(theIntent.native) an paste the results here

@jonsabogal
Copy link
Author

@triniwiz A snippet of what I am doing

stripe.createPaymentMethod(this.creditCardView.cardParams, (error, pm) => {
stripe.confirmSetupIntent(pm.id, this.setupIntentSecret, (error, setupIntent) => {
console.dir(setupIntent.native);
this.modalParams.closeCallback(1);
//}
});
});

And the console output: (this is a stripe test env so I didn't bother to remove any of the tokens..)

`==== object dump start ====
clientSecret: "seti_1IwCtvDhGQo0NJV9wZFLbZSH_secret_JZLbYnbYeiwmRtwJfHMmhO1y88FWeeN"
created: Fri May 28 2021 16:07:27 GMT-0500 (CDT)
customerID: "null"
lastSetupError: "null"
livemode: "false"
metadata: "null"
nextAction: "null"
paymentMethodID: "pm_1IwCtwDhGQo0NJV9MH3om2wn"
paymentMethodTypes: (
0
)
status: "5"
stripeDescription: "null"
stripeID: "seti_1IwCtvDhGQo0NJV9wZFLbZSH"
usage: "3"
allResponseFields: {
"cancellation_reason" = "";
"client_secret" = "seti_1IwCtvDhGQo0NJV9wZFLbZSH_secret_JZLbYnbYeiwmRtwJfHMmhO1y88FWeeN";
created = 1622236047;
description = "";
id = "seti_1IwCtvDhGQo0NJV9wZFLbZSH";
"last_setup_error" = "";
livemode = 0;
"next_action" = "";
object = "setup_intent";
"payment_method" = "pm_1IwCtwDhGQo0NJV9MH3om2wn";
"payment_method_types" = (
card
);
status = succeeded;
usage = "off_session";
}
autorelease: ()
class: ()
conformsToProtocol: ()
isEqual: ()
isKindOfClass: ()
isMemberOfClass: ()
performSelector: ()
performSelectorWithObject: ()
performSelectorWithObjectWithObject: ()
release: ()
respondsToSelector: ()
retain: ()
retainCount: ()
self: ()
debugDescription: "<Stripe.STPSetupIntent: 0x283ab2a80; stripeId = seti_1IwCtvDhGQo0NJV9wZFLbZSH; clientSecret = ; created = 2021-05-28 21:07:27 +0000; customerId = ; description = ; lastSetupError = nil; livemode = NO; nextAction = nil; paymentMethodId = pm_1IwCtwDhGQo0NJV9MH3om2wn; paymentMethodTypes = [card]; status = succeeded; usage = off_session>"
description: "<Stripe.STPSetupIntent: 0x283ab2a80; stripeId = seti_1IwCtvDhGQo0NJV9wZFLbZSH; clientSecret = ; created = 2021-05-28 21:07:27 +0000; customerId = ; description = ; lastSetupError = nil; livemode = NO; nextAction = nil; paymentMethodId = pm_1IwCtwDhGQo0NJV9MH3om2wn; paymentMethodTypes = [card]; status = succeeded; usage = off_session>"
hash: "10798967424"
isProxy: "false"
superclass: ()
zone: <Pointer: 0x1eb158000>
toString: ()
accessibilityActivationPoint:
accessibilityAttributedHint: "null"
accessibilityAttributedLabel: "null"
accessibilityAttributedUserInputLabels: "null"
accessibilityAttributedValue: "null"
accessibilityContainerType: "0"
accessibilityCustomActions: "null"
accessibilityCustomRotors: "null"
accessibilityDragSourceDescriptors: "null"
accessibilityDropPointDescriptors: "null"
accessibilityElements: "null"
accessibilityElementsHidden: "false"
accessibilityFrame:
accessibilityHint: "null"
accessibilityLabel: "null"
accessibilityLanguage: "null"
accessibilityNavigationStyle: "0"
accessibilityPath: "null"
accessibilityRespondsToUserInteraction: "false"
accessibilityTextualContext: "null"
accessibilityTraits: "0"
accessibilityUserInputLabels: (
)
accessibilityValue: "null"
accessibilityViewIsModal: "false"
autoContentAccessingProxy: "null"
classForCoder: ()
classForKeyedArchiver: ()
isAccessibilityElement: "false"
observationInfo: "null"
shouldGroupAccessibilityChildren: "false"
accessibilityActivate: ()
accessibilityAssistiveTechnologyFocusedIdentifiers: ()
accessibilityDecrement: ()
accessibilityElementAtIndex: ()
accessibilityElementCount: ()
accessibilityElementDidBecomeFocused: ()
accessibilityElementDidLoseFocus: ()
accessibilityElementIsFocused: ()
accessibilityIncrement: ()
accessibilityPerformEscape: ()
accessibilityPerformMagicTap: ()
accessibilityScroll: ()
addObserverForKeyPathOptionsContext: ()
awakeAfterUsingCoder: ()
awakeFromNib: ()
copy: ()
dealloc: ()
dictionaryWithValuesForKeys: ()
didChangeValueForKey: ()
didChangeValueForKeyWithSetMutationUsingObjects: ()
didChangeValuesAtIndexesForKey: ()
doesNotRecognizeSelector: ()
finalize: ()
forwardInvocation: ()
forwardingTargetForSelector: ()
indexOfAccessibilityElement: ()
init: ()
methodForSelector: ()
methodSignatureForSelector: ()
mutableArrayValueForKey: ()
mutableArrayValueForKeyPath: ()
mutableCopy: ()
mutableOrderedSetValueForKey: ()
mutableOrderedSetValueForKeyPath: ()
mutableSetValueForKey: ()
mutableSetValueForKeyPath: ()
observeValueForKeyPathOfObjectChangeContext: ()
performSelectorInBackgroundWithObject: ()
performSelectorOnMainThreadWithObjectWaitUntilDone: ()
performSelectorOnMainThreadWithObjectWaitUntilDoneModes: ()
performSelectorOnThreadWithObjectWaitUntilDone: ()
performSelectorOnThreadWithObjectWaitUntilDoneModes: ()
performSelectorWithObjectAfterDelay: ()
performSelectorWithObjectAfterDelayInModes: ()
prepareForInterfaceBuilder: ()
removeObserverForKeyPath: ()
removeObserverForKeyPathContext: ()
replacementObjectForCoder: ()
replacementObjectForKeyedArchiver: ()
setNilValueForKey: ()
setValueForKey: ()
setValueForKeyPath: ()
setValueForUndefinedKey: ()
setValuesForKeysWithDictionary: ()
validateValueForKeyError: ()
validateValueForKeyPathError: ()
valueForKey: ()
valueForKeyPath: ()
valueForUndefinedKey: ()
willChangeValueForKey: ()
willChangeValueForKeyWithSetMutationUsingObjects: ()
willChangeValuesAtIndexesForKey: ()
==== object dump end ====

`

@triniwiz
Copy link
Owner

Nice just as I thought can you try @triniwiz/[email protected]

@jonsabogal
Copy link
Author

So this has never worked. I downloaded ver 7.0.0 and the isSuccess flag is false even when the credit card entered was created successfully

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

No branches or pull requests

2 participants