From 40fa4ac88486020b775dbe7cfc7f5ef0505362cf Mon Sep 17 00:00:00 2001 From: Jonas Bark Date: Mon, 21 Aug 2023 13:45:50 +0200 Subject: [PATCH] sync iOS with 0.30.0 --- .../ios/Classes/Stripe Sdk/Mappers.swift | 1 + .../ios/Classes/Stripe Sdk/StripeSdk.swift | 32 +++++++++++++++++++ .../stripe_ios/ios/Classes/StripePlugin.swift | 16 ++++++++++ packages/stripe_ios/ios/stripe_ios.podspec | 2 +- 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/packages/stripe_ios/ios/Classes/Stripe Sdk/Mappers.swift b/packages/stripe_ios/ios/Classes/Stripe Sdk/Mappers.swift index e2dd4a515..fc1dba808 100644 --- a/packages/stripe_ios/ios/Classes/Stripe Sdk/Mappers.swift +++ b/packages/stripe_ios/ios/Classes/Stripe Sdk/Mappers.swift @@ -357,6 +357,7 @@ class Mappers { if let address = shipping.address { addressDetails = [ "city": address.city ?? NSNull(), + "state": address.state ?? NSNull(), "country": address.country ?? NSNull(), "line1": address.line1 ?? NSNull(), "line2":address.line2 ?? NSNull(), diff --git a/packages/stripe_ios/ios/Classes/Stripe Sdk/StripeSdk.swift b/packages/stripe_ios/ios/Classes/Stripe Sdk/StripeSdk.swift index b568fc2d8..c5254aff0 100644 --- a/packages/stripe_ios/ios/Classes/Stripe Sdk/StripeSdk.swift +++ b/packages/stripe_ios/ios/Classes/Stripe Sdk/StripeSdk.swift @@ -650,6 +650,38 @@ class StripeSdk: RCTEventEmitter, STPBankSelectionViewControllerDelegate, UIAdap } } + @objc(handleNextActionForSetup:returnURL:resolver:rejecter:) + func handleNextActionForSetup( + setupIntentClientSecret: String, + returnURL: String?, + resolver resolve: @escaping RCTPromiseResolveBlock, + rejecter reject: @escaping RCTPromiseRejectBlock + ){ + let paymentHandler = STPPaymentHandler.shared() + paymentHandler.handleNextAction(forSetupIntent: setupIntentClientSecret, with: self, returnURL: returnURL) { status, setupIntent, handleActionError in + switch (status) { + case .failed: + resolve(Errors.createError(ErrorType.Failed, handleActionError)) + break + case .canceled: + if let lastError = setupIntent?.lastSetupError { + resolve(Errors.createError(ErrorType.Canceled, lastError)) + } else { + resolve(Errors.createError(ErrorType.Canceled, "The setup intent has been canceled")) + } + break + case .succeeded: + if let setupIntent = setupIntent { + resolve(Mappers.createResult("setupIntent", Mappers.mapFromSetupIntent(setupIntent: setupIntent))) + } + break + @unknown default: + resolve(Errors.createError(ErrorType.Unknown, "Cannot complete setup")) + break + } + } + } + @objc(collectBankAccount:clientSecret:params:resolver:rejecter:) func collectBankAccount( isPaymentIntent: Bool, diff --git a/packages/stripe_ios/ios/Classes/StripePlugin.swift b/packages/stripe_ios/ios/Classes/StripePlugin.swift index cb1ba8198..180c48c95 100644 --- a/packages/stripe_ios/ios/Classes/StripePlugin.swift +++ b/packages/stripe_ios/ios/Classes/StripePlugin.swift @@ -496,6 +496,22 @@ extension StripePlugin { ) } + func handleNextActionForSetup(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + guard let arguments = call.arguments as? FlutterMap, + let setupIntentClientSecret = arguments["setupIntentClientSecret"] as? String, + let returnURL = arguments["returnURL"] as? String + else { + result(FlutterError.invalidParams) + return + } + handleNextActionForSetup( + setupIntentClientSecret: setupIntentClientSecret, + returnURL: returnURL, + resolver: resolver(for: result), + rejecter: rejecter(for: result) + ) + } + func dangerouslyUpdateCardDetails(_ call: FlutterMethodCall, result: @escaping FlutterResult) { guard let arguments = call.arguments as? FlutterMap, let params = arguments["params"] as? NSDictionary else { diff --git a/packages/stripe_ios/ios/stripe_ios.podspec b/packages/stripe_ios/ios/stripe_ios.podspec index 81b823c98..389c92ecf 100644 --- a/packages/stripe_ios/ios/stripe_ios.podspec +++ b/packages/stripe_ios/ios/stripe_ios.podspec @@ -2,7 +2,7 @@ # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. # Run `pod lib lint stripe_ios.podspec' to validate before publishing. # -stripe_version = '~> 23.10.0' +stripe_version = '~> 23.12.0' Pod::Spec.new do |s| s.name = 'stripe_ios' s.version = '0.0.1'