framepayments-react-native 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +81 -59
  2. package/android/build/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
  3. package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
  4. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
  5. package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  6. package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-framepayments-react-native.jar +0 -0
  7. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
  8. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
  9. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  10. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  11. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  12. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  13. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  14. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  15. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  16. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  17. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  18. package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  19. package/android/build/outputs/aar/framepayments-react-native-debug.aar +0 -0
  20. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameCheckoutActivity$Companion.class +0 -0
  21. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameCheckoutActivity$tryShowCheckout$1.class +0 -0
  22. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameCheckoutActivity.class +0 -0
  23. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity$CartItemDto.class +0 -0
  24. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity$Companion.class +0 -0
  25. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity$parseCartItems$type$1.class +0 -0
  26. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity.class +0 -0
  27. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameGooglePayActivity$Companion.class +0 -0
  28. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameGooglePayActivity.class +0 -0
  29. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameOnboardingActivity$Companion.class +0 -0
  30. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameOnboardingActivity$parseCapabilities$type$1.class +0 -0
  31. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameOnboardingActivity.class +0 -0
  32. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameSDKModule.class +0 -0
  33. package/android/build.gradle +3 -3
  34. package/android/src/main/java/com/framepayments/reactnativeframe/FrameCheckoutActivity.kt +17 -13
  35. package/android/src/main/java/com/framepayments/reactnativeframe/FrameFlowActivity.kt +18 -11
  36. package/android/src/main/java/com/framepayments/reactnativeframe/FrameGooglePayActivity.kt +31 -8
  37. package/android/src/main/java/com/framepayments/reactnativeframe/FrameSDKModule.kt +28 -35
  38. package/ios/ApplePayPresenter.swift +53 -28
  39. package/ios/FrameSDKBridge.m +7 -7
  40. package/ios/FrameSDKBridge.swift +62 -32
  41. package/lib/errors.d.ts +9 -1
  42. package/lib/errors.d.ts.map +1 -1
  43. package/lib/errors.js +9 -1
  44. package/lib/index.d.ts +1 -1
  45. package/lib/index.d.ts.map +1 -1
  46. package/lib/native.d.ts +37 -7
  47. package/lib/native.d.ts.map +1 -1
  48. package/lib/native.js +61 -9
  49. package/lib/types.d.ts +18 -45
  50. package/lib/types.d.ts.map +1 -1
  51. package/package.json +1 -1
  52. package/src/__tests__/native.test.ts +179 -25
  53. package/src/errors.ts +9 -1
  54. package/src/index.ts +1 -3
  55. package/src/native.ts +69 -17
  56. package/src/types.ts +19 -58
  57. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/results.bin +0 -1
  58. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/BuildConfig.dex +0 -0
  59. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameCheckoutActivity$Companion.dex +0 -0
  60. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameCheckoutActivity$tryShowCheckout$1.dex +0 -0
  61. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameCheckoutActivity.dex +0 -0
  62. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity$CartItemDto.dex +0 -0
  63. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity$Companion.dex +0 -0
  64. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity$parseCartItems$type$1.dex +0 -0
  65. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity.dex +0 -0
  66. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameGooglePayActivity$Companion.dex +0 -0
  67. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameGooglePayActivity.dex +0 -0
  68. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameOnboardingActivity$Companion.dex +0 -0
  69. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameOnboardingActivity$parseCapabilities$type$1.dex +0 -0
  70. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameOnboardingActivity.dex +0 -0
  71. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameSDKModule$Companion.dex +0 -0
  72. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameSDKModule.dex +0 -0
  73. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameSDKPackage.dex +0 -0
  74. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/JsonConvertersKt.dex +0 -0
  75. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameCheckoutActivity$$InternalSyntheticLambda$2$28045340ca5b91151bb937065eeb5817c0f8f911bb460e6e7ed8bb228b67ee83$0.globals +0 -0
  76. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameFlowActivity$$InternalSyntheticLambda$2$467cdf1dabffeaa07b76e313efb66791f50d3ff264e427e91d1358ac5865a7a9$0.globals +0 -0
  77. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameFlowActivity$$InternalSyntheticLambda$2$d15cc37cc08a853958a9c0baad49f7fce1ef84e92db9baa5103646939a0fe3e5$0.globals +0 -0
  78. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameFlowActivity$$InternalSyntheticLambda$2$ee6ef8e6758d1b8e67a54e3fecfb200ac5e867541a69809ec1db49f74ffcada1$0.globals +0 -0
  79. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameGooglePayActivity$$InternalSyntheticLambda$2$46cecf303f126f7c9f20b615fc49b2714ec2eb4f046ae009cfdbce53a1759f18$0.globals +0 -0
  80. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameGooglePayActivity$$InternalSyntheticLambda$2$46cecf303f126f7c9f20b615fc49b2714ec2eb4f046ae009cfdbce53a1759f18$1.globals +0 -0
  81. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameGooglePayActivity$$InternalSyntheticLambda$2$46cecf303f126f7c9f20b615fc49b2714ec2eb4f046ae009cfdbce53a1759f18$2.globals +0 -0
  82. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameGooglePayActivity$$InternalSyntheticLambda$2$cdad629ad452b3c7f7de1310d225629dafa75285ad515d55f056371066170154$0.globals +0 -0
  83. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameOnboardingActivity$$InternalSyntheticLambda$2$5d91d018c63f48735ba5e2a00b14bd815f4ce248aa924e4a58bf6addce311837$0.globals +0 -0
  84. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameOnboardingActivity$$InternalSyntheticLambda$2$c9ac604bc80e3afcbfad7417717ae97568874f4e33246863c0d688abb3e89865$0.globals +0 -0
  85. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameSDKModule$$InternalSyntheticLambda$2$1f479ca48bf3a1c66ff65b38aaaef67a97119b29ddce703f8104188682007f0d$0.globals +0 -0
  86. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameSDKModule$$InternalSyntheticLambda$2$984ab30558bc904ed37602fa6e3ebf28f1ed69df6712b31b00c4f26fc26d3b70$0.globals +0 -0
  87. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameSDKModule$$InternalSyntheticLambda$2$f4a55b70e496f422e1e03998843d62c7208f0229c2d5d080706056e98810c892$0.globals +0 -0
  88. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameSDKModule$$InternalSyntheticLambda$2$f8d46f7169c404d37a1d505f19439b83090fbed62b5bdaf1e86717fdddebf622$0.globals +0 -0
  89. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/FrameSDKModule$$InternalSyntheticLambda$2$f8d46f7169c404d37a1d505f19439b83090fbed62b5bdaf1e86717fdddebf622$1.globals +0 -0
  90. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  91. package/android/build/intermediates/android_res_source_set_path_map/debug/mapDebugSourceSetPaths/file-map.txt +0 -10
  92. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  93. package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
  94. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/META-INF/framepayments-react-native_debug.kotlin_module +0 -0
  95. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/BuildConfig.class +0 -0
  96. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameCheckoutActivity$Companion.class +0 -0
  97. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameCheckoutActivity$tryShowCheckout$1.class +0 -0
  98. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameCheckoutActivity.class +0 -0
  99. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity$CartItemDto.class +0 -0
  100. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity$Companion.class +0 -0
  101. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity$parseCartItems$type$1.class +0 -0
  102. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity.class +0 -0
  103. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameGooglePayActivity$Companion.class +0 -0
  104. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameGooglePayActivity.class +0 -0
  105. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameOnboardingActivity$Companion.class +0 -0
  106. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameOnboardingActivity$parseCapabilities$type$1.class +0 -0
  107. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameOnboardingActivity.class +0 -0
  108. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameSDKModule$Companion.class +0 -0
  109. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameSDKModule.class +0 -0
  110. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameSDKPackage.class +0 -0
  111. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/JsonConvertersKt.class +0 -0
@@ -50,7 +50,7 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
50
50
  }
51
51
 
52
52
  @ReactMethod
53
- fun presentCheckout(customerId: String?, amount: Double, promise: Promise) {
53
+ fun presentCheckout(accountId: String?, amount: Double, promise: Promise) {
54
54
  val activity = reactApplicationContext.currentActivity ?: run {
55
55
  promise.reject("NO_ACTIVITY", "No current activity", null)
56
56
  return
@@ -58,7 +58,7 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
58
58
  checkoutPromise = promise
59
59
  activity.runOnUiThread {
60
60
  val intent = Intent(activity, FrameCheckoutActivity::class.java).apply {
61
- putExtra(FrameCheckoutActivity.EXTRA_CUSTOMER_ID, customerId)
61
+ putExtra(FrameCheckoutActivity.EXTRA_ACCOUNT_ID, accountId)
62
62
  putExtra(FrameCheckoutActivity.EXTRA_AMOUNT, amount.toInt())
63
63
  }
64
64
  activity.startActivityForResult(intent, FrameCheckoutActivity.REQUEST_CODE)
@@ -67,7 +67,7 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
67
67
 
68
68
  @ReactMethod
69
69
  fun presentCart(
70
- customerId: String?,
70
+ accountId: String?,
71
71
  items: com.facebook.react.bridge.ReadableArray,
72
72
  shippingAmountInCents: Double,
73
73
  promise: Promise
@@ -83,7 +83,7 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
83
83
  cartPromise = promise
84
84
  activity.runOnUiThread {
85
85
  val intent = Intent(activity, FrameFlowActivity::class.java).apply {
86
- putExtra(FrameFlowActivity.EXTRA_CUSTOMER_ID, customerId)
86
+ putExtra(FrameFlowActivity.EXTRA_ACCOUNT_ID, accountId)
87
87
  putExtra(FrameFlowActivity.EXTRA_ITEMS_JSON, itemsJson)
88
88
  putExtra(FrameFlowActivity.EXTRA_SHIPPING_CENTS, shippingAmountInCents.toInt())
89
89
  }
@@ -94,7 +94,8 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
94
94
  @ReactMethod
95
95
  fun presentGooglePay(
96
96
  amountCents: Double,
97
- customerId: String?,
97
+ ownerType: String?,
98
+ ownerId: String?,
98
99
  currencyCode: String?,
99
100
  googlePayMerchantId: String?,
100
101
  promise: Promise
@@ -108,6 +109,14 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
108
109
  promise.reject("INVALID_AMOUNT", "amountCents must be positive", null)
109
110
  return
110
111
  }
112
+ if (ownerType != "customer" && ownerType != "account") {
113
+ promise.reject("INVALID_OWNER", "owner.type must be 'customer' or 'account'", null)
114
+ return
115
+ }
116
+ if (ownerId.isNullOrEmpty()) {
117
+ promise.reject("INVALID_OWNER", "owner.id is required", null)
118
+ return
119
+ }
111
120
  googlePayPromise = promise
112
121
  pendingGooglePayCallback = { resultCode, data ->
113
122
  handleGooglePayResult(resultCode, data)
@@ -115,7 +124,8 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
115
124
  activity.runOnUiThread {
116
125
  val intent = Intent(activity, FrameGooglePayActivity::class.java).apply {
117
126
  putExtra(FrameGooglePayActivity.EXTRA_AMOUNT_CENTS, amountInt)
118
- putExtra(FrameGooglePayActivity.EXTRA_CUSTOMER_ID, customerId)
127
+ putExtra(FrameGooglePayActivity.EXTRA_OWNER_TYPE, ownerType)
128
+ putExtra(FrameGooglePayActivity.EXTRA_OWNER_ID, ownerId)
119
129
  putExtra(FrameGooglePayActivity.EXTRA_CURRENCY, currencyCode ?: "USD")
120
130
  putExtra(FrameGooglePayActivity.EXTRA_MERCHANT_ID, googlePayMerchantId)
121
131
  }
@@ -182,17 +192,11 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
182
192
  val promise = checkoutPromise ?: return
183
193
  checkoutPromise = null
184
194
  if (resultCode == Activity.RESULT_OK && data != null) {
185
- val json = data.getStringExtra(FrameCheckoutActivity.EXTRA_CHARGE_INTENT_JSON)
186
- if (json != null) {
187
- try {
188
- val obj = JSONObject(json)
189
- val map = jsonObjectToWritableMap(obj)
190
- promise.resolve(map)
191
- } catch (e: Exception) {
192
- promise.reject("PARSE_ERROR", e.message, e)
193
- }
195
+ val transferId = data.getStringExtra(FrameCheckoutActivity.EXTRA_TRANSFER_ID)
196
+ if (!transferId.isNullOrEmpty()) {
197
+ promise.resolve(transferId)
194
198
  } else {
195
- promise.reject("NO_RESULT", "No charge intent in result", null)
199
+ promise.reject("NO_RESULT", "No transfer id in result", null)
196
200
  }
197
201
  } else {
198
202
  promise.reject("USER_CANCELED", "User cancelled checkout", null)
@@ -203,17 +207,11 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
203
207
  val promise = cartPromise ?: return
204
208
  cartPromise = null
205
209
  if (resultCode == Activity.RESULT_OK && data != null) {
206
- val json = data.getStringExtra(FrameFlowActivity.EXTRA_CHARGE_INTENT_JSON)
207
- if (json != null) {
208
- try {
209
- val obj = JSONObject(json)
210
- val map = jsonObjectToWritableMap(obj)
211
- promise.resolve(map)
212
- } catch (e: Exception) {
213
- promise.reject("PARSE_ERROR", e.message, e)
214
- }
210
+ val transferId = data.getStringExtra(FrameFlowActivity.EXTRA_TRANSFER_ID)
211
+ if (!transferId.isNullOrEmpty()) {
212
+ promise.resolve(transferId)
215
213
  } else {
216
- promise.reject("NO_RESULT", "No charge intent in result", null)
214
+ promise.reject("NO_RESULT", "No transfer id in result", null)
217
215
  }
218
216
  } else {
219
217
  promise.reject("USER_CANCELED", "User cancelled", null)
@@ -225,16 +223,11 @@ class FrameSDKModule(reactContext: ReactApplicationContext) :
225
223
  googlePayPromise = null
226
224
  when (resultCode) {
227
225
  Activity.RESULT_OK -> {
228
- val json = data?.getStringExtra(FrameGooglePayActivity.EXTRA_CHARGE_INTENT_JSON)
229
- if (json != null) {
230
- try {
231
- val map = jsonObjectToWritableMap(JSONObject(json))
232
- promise.resolve(map)
233
- } catch (e: Exception) {
234
- promise.reject("PARSE_ERROR", e.message, e)
235
- }
226
+ val id = data?.getStringExtra(FrameGooglePayActivity.EXTRA_CHARGE_ID)
227
+ if (id.isNullOrEmpty()) {
228
+ promise.reject("NO_RESULT", "Google Pay returned no charge id", null)
236
229
  } else {
237
- promise.reject("NO_RESULT", "No charge intent in result", null)
230
+ promise.resolve(id)
238
231
  }
239
232
  }
240
233
  FrameGooglePayActivity.RESULT_FAILURE -> {
@@ -3,10 +3,14 @@
3
3
  // FrameReactNative
4
4
  //
5
5
  // Programmatic Apple Pay presentation for Frame.presentApplePay(). Wraps
6
- // PKPaymentAuthorizationController + ApplePayAPI + ChargeIntentsAPI directly
7
- // so we can detect the user-cancel path (PKPaymentAuthorizationController's
8
- // didFinish fires for both success and cancel; the underlying SDK's view
9
- // model only delivers success, so we re-implement that flow here).
6
+ // PKPaymentAuthorizationController + ApplePayAPI + (ChargeIntentsAPI | TransfersAPI)
7
+ // directly so we can detect the user-cancel path PKPaymentAuthorizationController's
8
+ // didFinish fires for both success and cancel, and the underlying SDK's view
9
+ // model only delivers success, so we re-implement that flow here.
10
+ //
11
+ // Supports both:
12
+ // - `.customer(id)` owner → creates a `ChargeIntent`; resolves with the ChargeIntent id.
13
+ // - `.account(id)` owner → creates a `Transfer`; resolves with the Transfer id.
10
14
  //
11
15
 
12
16
  import Foundation
@@ -16,9 +20,14 @@ import Frame
16
20
  @MainActor
17
21
  final class ApplePayPresenter: NSObject, PKPaymentAuthorizationControllerDelegate {
18
22
 
23
+ enum Owner {
24
+ case customer(String)
25
+ case account(String)
26
+ }
27
+
19
28
  private let amount: Int
20
29
  private let currency: String
21
- private let owner: FrameApplePayViewModel.PaymentMethodOwner
30
+ private let owner: Owner
22
31
  private let merchantId: String
23
32
  private let resolve: (Any?) -> Void
24
33
  private let reject: (String, String, Error?) -> Void
@@ -36,7 +45,7 @@ final class ApplePayPresenter: NSObject, PKPaymentAuthorizationControllerDelegat
36
45
 
37
46
  init(amount: Int,
38
47
  currency: String,
39
- owner: FrameApplePayViewModel.PaymentMethodOwner,
48
+ owner: Owner,
40
49
  merchantId: String,
41
50
  resolve: @escaping (Any?) -> Void,
42
51
  reject: @escaping (String, String, Error?) -> Void) {
@@ -80,6 +89,8 @@ final class ApplePayPresenter: NSObject, PKPaymentAuthorizationControllerDelegat
80
89
  didAuthorizePayment payment: PKPayment
81
90
  ) async -> PKPaymentAuthorizationResult {
82
91
  do {
92
+ // 1. Create the Frame PaymentMethod from the Apple Pay token, scoped to
93
+ // whichever owner the caller asked for.
83
94
  let (paymentMethod, methodError): (FrameObjects.PaymentMethod?, NetworkingError?)
84
95
  switch owner {
85
96
  case .customer(let customerId):
@@ -97,27 +108,45 @@ final class ApplePayPresenter: NSObject, PKPaymentAuthorizationControllerDelegat
97
108
  return PKPaymentAuthorizationResult(status: .failure, errors: nil)
98
109
  }
99
110
 
100
- let request: ChargeIntentsRequests.CreateChargeIntentRequest
111
+ // 2. Create the charge. Customer owners produce a ChargeIntent; account
112
+ // owners produce a Transfer. Both surface the resulting id to JS — the
113
+ // caller knows which resource the id refers to based on the owner.
101
114
  switch owner {
102
115
  case .customer(let customerId):
103
- request = ChargeIntentsRequests.CreateChargeIntentRequest(
104
- amount: amount, currency: currency, customer: customerId,
105
- paymentMethod: paymentMethodId, confirm: true, authorizationMode: .automatic
116
+ let request = ChargeIntentsRequests.CreateChargeIntentRequest(
117
+ amount: amount,
118
+ currency: currency,
119
+ customer: customerId,
120
+ paymentMethod: paymentMethodId,
121
+ confirm: true,
122
+ authorizationMode: .automatic
106
123
  )
124
+ let (chargeIntent, chargeError) = try await ChargeIntentsAPI.createChargeIntent(request: request)
125
+
126
+ if let chargeIntent {
127
+ deliverSuccess(id: chargeIntent.id)
128
+ return PKPaymentAuthorizationResult(status: .success, errors: nil)
129
+ } else {
130
+ deliverFailure(code: "PAYMENT_FAILED", error: chargeError)
131
+ return PKPaymentAuthorizationResult(status: .failure, errors: nil)
132
+ }
133
+
107
134
  case .account(let accountId):
108
- request = ChargeIntentsRequests.CreateChargeIntentRequest(
109
- amount: amount, currency: currency, account: accountId,
110
- paymentMethod: paymentMethodId, confirm: true, authorizationMode: .automatic
135
+ let request = TransferRequests.CreateTransferRequest(
136
+ amount: amount,
137
+ accountId: accountId,
138
+ currency: currency,
139
+ sourcePaymentMethodId: paymentMethodId
111
140
  )
112
- }
113
- let (chargeIntent, chargeError) = try await ChargeIntentsAPI.createChargeIntent(request: request)
114
-
115
- if let chargeIntent {
116
- deliverSuccess(chargeIntent)
117
- return PKPaymentAuthorizationResult(status: .success, errors: nil)
118
- } else {
119
- deliverFailure(code: "CHARGE_INTENT_FAILED", error: chargeError)
120
- return PKPaymentAuthorizationResult(status: .failure, errors: nil)
141
+ let (transfer, transferError) = try await TransfersAPI.createTransfer(request: request)
142
+
143
+ if let transfer {
144
+ deliverSuccess(id: transfer.id)
145
+ return PKPaymentAuthorizationResult(status: .success, errors: nil)
146
+ } else {
147
+ deliverFailure(code: "PAYMENT_FAILED", error: transferError)
148
+ return PKPaymentAuthorizationResult(status: .failure, errors: nil)
149
+ }
121
150
  }
122
151
  } catch {
123
152
  deliverFailure(code: "PAYMENT_FAILED", error: error)
@@ -136,14 +165,10 @@ final class ApplePayPresenter: NSObject, PKPaymentAuthorizationControllerDelegat
136
165
 
137
166
  // MARK: - Result delivery
138
167
 
139
- private func deliverSuccess(_ intent: FrameObjects.ChargeIntent) {
168
+ private func deliverSuccess(id: String) {
140
169
  guard !didDeliverResult else { return }
141
170
  didDeliverResult = true
142
- if let dict = FrameSDKBridge.encodeChargeIntent(intent) {
143
- resolve(dict)
144
- } else {
145
- reject("ENCODE_ERROR", "Failed to encode charge intent", nil)
146
- }
171
+ resolve(id)
147
172
  }
148
173
 
149
174
  private func deliverFailure(code: String, error: Error?) {
@@ -32,12 +32,12 @@ RCT_EXTERN_METHOD(initialize:(NSString *)secretKey
32
32
  resolver:(RCTPromiseResolveBlock)resolve
33
33
  rejecter:(RCTPromiseRejectBlock)reject)
34
34
 
35
- RCT_EXTERN_METHOD(presentCheckout:(id)customerId
35
+ RCT_EXTERN_METHOD(presentCheckout:(id)accountId
36
36
  amount:(nonnull NSNumber *)amount
37
37
  resolver:(RCTPromiseResolveBlock)resolve
38
38
  rejecter:(RCTPromiseRejectBlock)reject)
39
39
 
40
- RCT_EXTERN_METHOD(presentCart:(id)customerId
40
+ RCT_EXTERN_METHOD(presentCart:(id)accountId
41
41
  items:(NSArray *)items
42
42
  shippingAmountInCents:(nonnull NSNumber *)shippingAmountInCents
43
43
  resolver:(RCTPromiseResolveBlock)resolve
@@ -72,26 +72,26 @@ RCT_EXTERN_METHOD(presentApplePay:(NSString *)ownerType
72
72
  [[[ObjCFrameSDKBridge alloc] init] initialize:secretKey publishableKey:publishableKey debugMode:debugMode theme:theme resolver:resolve rejecter:reject];
73
73
  }
74
74
 
75
- - (void)presentCheckout:(id)customerId amount:(NSNumber *)amount resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
75
+ - (void)presentCheckout:(id)accountId amount:(NSNumber *)amount resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
76
76
  dispatch_async(dispatch_get_main_queue(), ^{
77
77
  UIViewController *topVC = FrameGetTopViewController();
78
78
  if (!topVC) {
79
79
  reject(@"NO_ROOT_VC", @"Could not find root view controller to present checkout", nil);
80
80
  return;
81
81
  }
82
- NSString *cId = [customerId isKindOfClass:[NSString class]] ? (NSString *)customerId : nil;
83
- [[[ObjCFrameSDKBridge alloc] init] presentCheckoutFrom:topVC customerId:cId amount:amount.intValue resolver:resolve rejecter:reject];
82
+ NSString *aId = [accountId isKindOfClass:[NSString class]] ? (NSString *)accountId : nil;
83
+ [[[ObjCFrameSDKBridge alloc] init] presentCheckoutFrom:topVC accountId:aId amount:amount.intValue resolver:resolve rejecter:reject];
84
84
  });
85
85
  }
86
86
 
87
- - (void)presentCart:(id)customerId items:(NSArray *)items shippingAmountInCents:(NSNumber *)shippingAmountInCents resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
87
+ - (void)presentCart:(id)accountId items:(NSArray *)items shippingAmountInCents:(NSNumber *)shippingAmountInCents resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
88
88
  dispatch_async(dispatch_get_main_queue(), ^{
89
89
  UIViewController *topVC = FrameGetTopViewController();
90
90
  if (!topVC) {
91
91
  reject(@"NO_ROOT_VC", @"Could not find root view controller to present cart", nil);
92
92
  return;
93
93
  }
94
- [[[ObjCFrameSDKBridge alloc] init] presentCartFrom:topVC customerId:customerId items:items shippingAmountInCents:shippingAmountInCents.integerValue resolver:resolve rejecter:reject];
94
+ [[[ObjCFrameSDKBridge alloc] init] presentCartFrom:topVC accountId:accountId items:items shippingAmountInCents:shippingAmountInCents.integerValue resolver:resolve rejecter:reject];
95
95
  });
96
96
  }
97
97
 
@@ -30,17 +30,25 @@ public class FrameSDKBridge: NSObject {
30
30
  }
31
31
 
32
32
  @objc public
33
- func presentCheckout(from viewController: UIViewController, customerId: String?, amount: Int, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
34
- presentCheckoutOnMain(from: viewController, customerId: customerId, amount: amount, resolve: resolve, reject: reject)
33
+ func presentCheckout(from viewController: UIViewController, accountId: String?, amount: Int, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
34
+ guard let accountId, !accountId.isEmpty else {
35
+ reject("INVALID_ACCOUNT", "Frame.presentCheckout requires a non-empty accountId", nil)
36
+ return
37
+ }
38
+ presentCheckoutOnMain(from: viewController, accountId: accountId, amount: amount, resolve: resolve, reject: reject)
35
39
  }
36
40
 
37
41
  @objc public
38
- func presentCart(from viewController: UIViewController, customerId: NSObject?, items: NSArray, shippingAmountInCents: Int, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
42
+ func presentCart(from viewController: UIViewController, accountId: NSObject?, items: NSArray, shippingAmountInCents: Int, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
39
43
  guard let cartItems = parseCartItems(items) else {
40
44
  reject("INVALID_ITEMS", "Invalid cart items array", nil)
41
45
  return
42
46
  }
43
- presentCartOnMain(from: viewController, customerId: customerId as? String, cartItems: cartItems, shippingAmountInCents: shippingAmountInCents, resolve: resolve, reject: reject)
47
+ guard let accountIdString = accountId as? String, !accountIdString.isEmpty else {
48
+ reject("INVALID_ACCOUNT", "Frame.presentCart requires a non-empty accountId", nil)
49
+ return
50
+ }
51
+ presentCartOnMain(from: viewController, accountId: accountIdString, cartItems: cartItems, shippingAmountInCents: shippingAmountInCents, resolve: resolve, reject: reject)
44
52
  }
45
53
 
46
54
  @objc public
@@ -55,10 +63,10 @@ public class FrameSDKBridge: NSObject {
55
63
  func presentApplePay(_ ownerType: String, ownerId: String, amount: Int, currency: String, merchantId: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
56
64
  DispatchQueue.main.async {
57
65
  Task { @MainActor in
58
- let owner: FrameApplePayViewModel.PaymentMethodOwner
66
+ let owner: ApplePayPresenter.Owner
59
67
  switch ownerType {
60
68
  case "customer": owner = .customer(ownerId)
61
- case "account": owner = .account(ownerId)
69
+ case "account": owner = .account(ownerId)
62
70
  default:
63
71
  reject("INVALID_OWNER", "owner.type must be 'customer' or 'account'", nil)
64
72
  return
@@ -97,19 +105,19 @@ public class FrameSDKBridge: NSObject {
97
105
 
98
106
  // MARK: - Private helpers
99
107
 
100
- private func presentCheckoutOnMain(from top: UIViewController, customerId: String?, amount: Int, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
108
+ private func presentCheckoutOnMain(from top: UIViewController, accountId: String, amount: Int, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
101
109
  var hosting: CheckoutHostingController!
102
110
  hosting = CheckoutHostingController(rootView: FrameCheckoutView(
103
- customerId: customerId,
111
+ accountId: accountId,
104
112
  paymentAmount: amount,
105
- checkoutCallback: { [weak hosting] chargeIntent in
113
+ checkoutCallback: { [weak hosting] success, transferId in
106
114
  hosting?.didComplete = true
107
115
  top.dismiss(animated: true)
108
116
  DispatchQueue.main.async {
109
- if let dict = Self.encodeChargeIntent(chargeIntent) {
110
- resolve(dict)
117
+ if success, let transferId {
118
+ resolve(transferId)
111
119
  } else {
112
- reject("ENCODE_ERROR", "Failed to encode charge intent", nil)
120
+ reject("PAYMENT_FAILED", "Checkout did not produce a transfer id", nil)
113
121
  }
114
122
  }
115
123
  }
@@ -128,11 +136,6 @@ public class FrameSDKBridge: NSObject {
128
136
  }
129
137
  }
130
138
 
131
- internal static func encodeChargeIntent(_ intent: FrameObjects.ChargeIntent) -> [String: Any]? {
132
- guard let data = try? JSONEncoder().encode(intent) else { return nil }
133
- return try? JSONSerialization.jsonObject(with: data) as? [String: Any]
134
- }
135
-
136
139
  private struct RNFrameCartItem: FrameCartItem {
137
140
  var id: String
138
141
  var imageURL: String
@@ -163,19 +166,29 @@ public class FrameSDKBridge: NSObject {
163
166
  return result
164
167
  }
165
168
 
166
- private func presentCartOnMain(from top: UIViewController, customerId: String?, cartItems: [RNFrameCartItem], shippingAmountInCents: Int, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
169
+ private func presentCartOnMain(from top: UIViewController, accountId: String, cartItems: [RNFrameCartItem], shippingAmountInCents: Int, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
170
+ // Single dismiss delegate guards against double-resolve: the inner checkout
171
+ // calls `finish(.success)` with the transfer id; bare-dismiss (swipe-down
172
+ // without completing checkout) calls `finish(.cancel)`.
173
+ let delegate = CartDismissDelegate(resolve: resolve, reject: reject)
167
174
  let cartView = FrameCartView(
168
- customer: nil,
175
+ accountId: accountId,
169
176
  cartItems: cartItems,
170
- shippingAmountInCents: shippingAmountInCents
177
+ shippingAmountInCents: shippingAmountInCents,
178
+ checkoutCallback: { [weak top, delegate] success, transferId in
179
+ if success, let transferId {
180
+ delegate.finish(.success(transferId))
181
+ } else {
182
+ delegate.finish(.cancel)
183
+ }
184
+ top?.dismiss(animated: true)
185
+ }
171
186
  )
172
187
  let hosting = UIHostingController(rootView: cartView)
173
188
  hosting.modalPresentationStyle = UIModalPresentationStyle.pageSheet
174
189
  if let sheet = hosting.sheetPresentationController {
175
190
  sheet.detents = [UISheetPresentationController.Detent.large()]
176
191
  }
177
- // When the sheet is dismissed (swipe or close), resolve. Note: FrameCartView does not expose ChargeIntent from nested checkout.
178
- let delegate = CartDismissDelegate(resolve: resolve)
179
192
  objc_setAssociatedObject(hosting, &cartDismissKey, delegate, .OBJC_ASSOCIATION_RETAIN)
180
193
  top.present(hosting, animated: true) {
181
194
  hosting.presentationController?.delegate = delegate
@@ -237,12 +250,8 @@ private final class CheckoutHostingController: UIHostingController<FrameCheckout
237
250
  onCancel?()
238
251
  }
239
252
 
240
- override func viewDidDisappear(_ animated: Bool) {
241
- super.viewDidDisappear(animated)
242
- cancel()
243
- }
244
-
245
253
  func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
254
+ guard presentationController.presentedViewController === self else { return }
246
255
  cancel()
247
256
  }
248
257
  }
@@ -254,13 +263,34 @@ private final class OnboardingHostingController<V: View>: UIHostingController<V>
254
263
  // MARK: - Delegates
255
264
 
256
265
  private final class CartDismissDelegate: NSObject, UIAdaptivePresentationControllerDelegate {
257
- let resolve: RCTPromiseResolveBlock
258
- init(resolve: @escaping RCTPromiseResolveBlock) { self.resolve = resolve }
259
- func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
260
- DispatchQueue.main.async { [resolve] in
261
- resolve([String: Any]())
266
+ enum Outcome {
267
+ case success(String)
268
+ case cancel
269
+ }
270
+
271
+ private let resolve: RCTPromiseResolveBlock
272
+ private let reject: RCTPromiseRejectBlock
273
+ private var didFinish = false
274
+
275
+ init(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
276
+ self.resolve = resolve
277
+ self.reject = reject
278
+ }
279
+
280
+ func finish(_ outcome: Outcome) {
281
+ guard !didFinish else { return }
282
+ didFinish = true
283
+ DispatchQueue.main.async { [resolve, reject] in
284
+ switch outcome {
285
+ case .success(let transferId): resolve(transferId)
286
+ case .cancel: reject("USER_CANCELED", "User dismissed cart without completing checkout", nil)
287
+ }
262
288
  }
263
289
  }
290
+
291
+ func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
292
+ finish(.cancel)
293
+ }
264
294
  }
265
295
 
266
296
  private final class OnboardingDismissDelegate: NSObject, UIAdaptivePresentationControllerDelegate {
package/lib/errors.d.ts CHANGED
@@ -7,12 +7,20 @@ export declare const ErrorCodes: {
7
7
  readonly NO_ROOT_VC: "NO_ROOT_VC";
8
8
  readonly NO_ACTIVITY: "NO_ACTIVITY";
9
9
  readonly INVALID_ITEMS: "INVALID_ITEMS";
10
+ readonly INVALID_ACCOUNT: "INVALID_ACCOUNT";
11
+ readonly INVALID_OWNER: "INVALID_OWNER";
12
+ readonly INVALID_MERCHANT_ID: "INVALID_MERCHANT_ID";
13
+ readonly INVALID_AMOUNT: "INVALID_AMOUNT";
10
14
  readonly NETWORK_ERROR: "NETWORK_ERROR";
11
15
  readonly API_ERROR: "API_ERROR";
12
16
  readonly PARSE_ERROR: "PARSE_ERROR";
13
17
  readonly NO_RESULT: "NO_RESULT";
14
18
  readonly INIT_FAILED: "INIT_FAILED";
15
- readonly ENCODE_ERROR: "ENCODE_ERROR";
19
+ readonly APPLE_PAY_UNAVAILABLE: "APPLE_PAY_UNAVAILABLE";
20
+ readonly GOOGLE_PAY_UNAVAILABLE: "GOOGLE_PAY_UNAVAILABLE";
21
+ readonly NOT_ATTESTED: "NOT_ATTESTED";
22
+ readonly PAYMENT_METHOD_FAILED: "PAYMENT_METHOD_FAILED";
23
+ readonly PAYMENT_FAILED: "PAYMENT_FAILED";
16
24
  };
17
25
  export type FrameErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
18
26
  export interface FrameErrorShape {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;CAYb,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAE1E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CASrE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,CAetE"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;CAoBb,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAE1E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CASrE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,CAetE"}
package/lib/errors.js CHANGED
@@ -7,12 +7,20 @@ export const ErrorCodes = {
7
7
  NO_ROOT_VC: 'NO_ROOT_VC',
8
8
  NO_ACTIVITY: 'NO_ACTIVITY',
9
9
  INVALID_ITEMS: 'INVALID_ITEMS',
10
+ INVALID_ACCOUNT: 'INVALID_ACCOUNT',
11
+ INVALID_OWNER: 'INVALID_OWNER',
12
+ INVALID_MERCHANT_ID: 'INVALID_MERCHANT_ID',
13
+ INVALID_AMOUNT: 'INVALID_AMOUNT',
10
14
  NETWORK_ERROR: 'NETWORK_ERROR',
11
15
  API_ERROR: 'API_ERROR',
12
16
  PARSE_ERROR: 'PARSE_ERROR',
13
17
  NO_RESULT: 'NO_RESULT',
14
18
  INIT_FAILED: 'INIT_FAILED',
15
- ENCODE_ERROR: 'ENCODE_ERROR',
19
+ APPLE_PAY_UNAVAILABLE: 'APPLE_PAY_UNAVAILABLE',
20
+ GOOGLE_PAY_UNAVAILABLE: 'GOOGLE_PAY_UNAVAILABLE',
21
+ NOT_ATTESTED: 'NOT_ATTESTED',
22
+ PAYMENT_METHOD_FAILED: 'PAYMENT_METHOD_FAILED',
23
+ PAYMENT_FAILED: 'PAYMENT_FAILED',
16
24
  };
17
25
  export function isFrameError(error) {
18
26
  return (typeof error === 'object' &&
package/lib/index.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { initialize, presentCheckout, presentCart, presentOnboarding, presentApplePay, presentGooglePay } from './native';
11
11
  export { initialize, presentCheckout, presentCart, presentOnboarding, presentApplePay, presentGooglePay, } from './native';
12
- export type { FrameCartItem, ChargeIntent, ChargeIntentStatus, AuthorizationMode, FrameError, BillingAddress, PaymentCard, BankAccount, PaymentMethod, OnboardingCapability, OnboardingResult, OnboardingResultStatus, ApplePayOwner, PresentApplePayOptions, PresentGooglePayOptions, FrameTheme, FrameThemeColor, FrameThemeFont, FrameThemeColors, FrameThemeFonts, FrameThemeRadii, } from './types';
12
+ export type { FrameCartItem, FrameError, BillingAddress, PaymentCard, BankAccount, PaymentMethod, OnboardingCapability, OnboardingResult, OnboardingResultStatus, WalletOwner, ApplePayOwner, PresentApplePayOptions, PresentGooglePayOptions, FrameTheme, FrameThemeColor, FrameThemeFont, FrameThemeColors, FrameThemeFonts, FrameThemeRadii, } from './types';
13
13
  export { ErrorCodes } from './errors';
14
14
  export type { FrameErrorShape, FrameErrorCode } from './errors';
15
15
  /** Default export for Frame.initialize(), Frame.presentCheckout(), Frame.presentCart(), Frame.presentOnboarding(), Frame.presentApplePay(), Frame.presentGooglePay() */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,UAAU,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEhE,wKAAwK;;;;;;;;;AACxK,wBAOE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,UAAU,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEhE,wKAAwK;;;;;;;;;AACxK,wBAOE"}
package/lib/native.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Native module bridge. Uses NativeModules for classic React Native bridge.
3
3
  */
4
- import type { ChargeIntent, FrameCartItem, FrameTheme, OnboardingCapability, OnboardingResult, PresentApplePayOptions, PresentGooglePayOptions } from './types';
4
+ import type { FrameCartItem, FrameTheme, OnboardingCapability, OnboardingResult, PresentApplePayOptions, PresentGooglePayOptions } from './types';
5
5
  export declare function initialize(options: {
6
6
  secretKey: string;
7
7
  publishableKey: string;
@@ -14,21 +14,51 @@ export declare function initialize(options: {
14
14
  */
15
15
  theme?: FrameTheme;
16
16
  }): Promise<void>;
17
+ /**
18
+ * Presents the Frame checkout sheet for the given account. Resolves with the
19
+ * created Transfer's id string on success, or rejects with `USER_CANCELED` if
20
+ * the user dismisses the sheet.
21
+ *
22
+ * `accountId` is required: the bundled checkout creates a `Transfer`, which is
23
+ * account-scoped. Callers needing a customer/ChargeIntent flow should use
24
+ * `presentApplePay` / `presentGooglePay` directly with a customer owner.
25
+ */
17
26
  export declare function presentCheckout(options: {
18
- customerId?: string | null;
27
+ accountId: string;
19
28
  amount: number;
20
- }): Promise<ChargeIntent>;
29
+ }): Promise<string>;
30
+ /**
31
+ * Presents the Frame cart UI; tapping checkout routes through the same flow
32
+ * as `presentCheckout` and resolves with the created Transfer's id string.
33
+ *
34
+ * `accountId` is required for the same reason as `presentCheckout`.
35
+ */
21
36
  export declare function presentCart(options: {
22
- customerId?: string | null;
37
+ accountId: string;
23
38
  items: FrameCartItem[];
24
39
  shippingAmountInCents: number;
25
- }): Promise<ChargeIntent>;
40
+ }): Promise<string>;
26
41
  export declare function presentOnboarding(options: {
27
42
  accountId?: string | null;
28
43
  capabilities?: OnboardingCapability[];
29
44
  applePayMerchantId?: string | null;
30
45
  googlePayMerchantId?: string | null;
31
46
  }): Promise<OnboardingResult>;
32
- export declare function presentApplePay(options: PresentApplePayOptions): Promise<ChargeIntent>;
33
- export declare function presentGooglePay(options: PresentGooglePayOptions): Promise<ChargeIntent>;
47
+ /**
48
+ * Presents the Apple Pay sheet and creates a charge from the resulting wallet
49
+ * payment method. Resolves with the created resource's id string on success,
50
+ * or rejects with `USER_CANCELED` if the sheet is dismissed.
51
+ *
52
+ * - `owner.type === 'customer'` → creates a `ChargeIntent`; resolves with its id.
53
+ * - `owner.type === 'account'` → creates a `Transfer`; resolves with its id.
54
+ */
55
+ export declare function presentApplePay(options: PresentApplePayOptions): Promise<string>;
56
+ /**
57
+ * Presents Google Pay and creates a charge from the resulting wallet payment method.
58
+ * Resolves with the created resource's id string on success.
59
+ *
60
+ * - `owner.type === 'customer'` → creates a `ChargeIntent`; resolves with its id.
61
+ * - `owner.type === 'account'` → creates a `Transfer`; resolves with its id.
62
+ */
63
+ export declare function presentGooglePay(options: PresentGooglePayOptions): Promise<string>;
34
64
  //# sourceMappingURL=native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAsBjB,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhB;AAwBD,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,YAAY,CAAC,CAKxB;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE;IACnC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;CAC/B,GAAG,OAAO,CAAC,YAAY,CAAC,CASxB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACtC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkB5B;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CAoBtF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,YAAY,CAAC,CAUxF"}
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAiCjB,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhB;AAwBD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQlB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;CAC/B,GAAG,OAAO,CAAC,MAAM,CAAC,CAYlB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACtC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkB5B;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoBhF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBlF"}