stripe / stripe-terminal-ios

Stripe Terminal iOS SDK
https://stripe.com/docs/terminal/sdk/ios
Other
105 stars 65 forks source link

can not use offline mode after upgrade to 3.2.0 #275

Closed jonhcbs closed 12 months ago

jonhcbs commented 1 year ago

Summary

followed the steps in this link https://stripe.com/docs/terminal/features/operate-offline/collect-payments, and connected the reader. but when start to pay offline, it shows error:

An attempt was made to create a PaymentIntent with offline behavior of force offline and the reader in use is not configured to operate offline.

But I did not see the steps that need set the reader to offline manually in the link. any idea what's the issue?

Code to reproduce

let offlineBehavior: OfflineBehavior = {
                  if amount > offlineLimitAmount {
                      return .requireOnline
                  } else {
                      return .forceOffline
                  }
                }()

                let createConfiguration = try CreateConfigurationBuilder().setOfflineBehavior(offlineBehavior).build()
                Terminal.shared.createPaymentIntent(params, createConfig: createConfiguration) { createResult, createError in
                    if let error = createError {
                        ...
                    } else if let paymentIntent = createResult {
                        ...
                    }
                }

iOS version

16+

Installation method

cocoapods

SDK version

3.2.0

Other information

{"readerName":"","connectionStatus":"Connected","readerSN":"STRM26122000091","batteryLevel":"86%","firmwareVersion":"2.01.00.20-SZZZ_Prod_US_v5-480001"}

bric-stripe commented 1 year ago

Hi, it looks like the location being connected to isn't configured for offline mode. Now that offline mode is in public beta (as of 3.2.0), you must enable offline mode using the configuration API.

If you currently are not using configurations, you'll have a default configuration that you can find with:

curl https://api.stripe.com/v1/terminal/configurations?is_account_default=true -u $SECRET_KEY:

Use the configuration ID, and then you can enable offline for that configuration.

curl https://api.stripe.com/v1/terminal/configurations/<configuration_id> -u $SECRET_KEY: -d "offline[enabled]"=true

See also these docs: https://stripe.com/docs/terminal/features/operate-offline/collect-payments?terminal-sdk-platform=ios#enable-offline-mode

After enabling offline via the config API, connect to the reader while online to refresh the SDK's settings. Then, you should be able to collect offline payments once again.

bric-stripe commented 12 months ago

closing this out but please re-open if still seeing this after confirming the location in use has the expected config applied.

jonhcbs commented 12 months ago

It works, forgot to replay days ago. thanks much.