triniwiz / nativescript-stripe

Apache License 2.0
49 stars 34 forks source link

StripeSetupIntent.isSuccess coming back as false in iOS #130

Open jonsabogal opened 3 years ago

jonsabogal commented 3 years ago

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 oss@nativescript.org", "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 commented 3 years ago

Can you try @triniwiz/nativescript-stripe@7.0.0-beta-0 an lmk

jonsabogal commented 3 years ago

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

triniwiz commented 3 years ago

Ok @triniwiz/nativescript-stripe@7.0.0-beta-1 should be it

jonsabogal commented 3 years ago

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 commented 3 years ago

That one was on me 😂 use @triniwiz/nativescript-stripe@7.0.0-beta-2

jonsabogal commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

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

jonsabogal commented 3 years ago

@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 commented 3 years ago

Nice just as I thought can you try @triniwiz/nativescript-stripe@7.0.0-beta-4

jonsabogal commented 3 years ago

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