@klarna/react-native-klarna-network-payment 0.0.1 → 2.7.0
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.
- package/README.md +143 -29
- package/android/build.gradle +95 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaNetworkPaymentButtonViewSpec.kt +22 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaNetworkPaymentModule.kt +46 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaNetworkPaymentModuleImpl.kt +163 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaNetworkPaymentPackage.kt +30 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaPaymentButtonPressEvent.kt +19 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaPaymentButtonViewManager.kt +276 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaPaymentPresentationMapper.kt +132 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaPaymentRequestMapper.kt +328 -0
- package/android/src/main/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaPaymentResponseMapper.kt +145 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaNetworkPaymentModuleImplTest.kt +361 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaPaymentButtonViewManagerTest.kt +155 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaPaymentPresentationMapperTest.kt +447 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaPaymentRequestMapperTest.kt +489 -0
- package/android/src/test/java/com/klarna/mobile/sdk/reactnative/klarnanetwork/payment/KlarnaPaymentResponseMapperTest.kt +456 -0
- package/ios/Sources/KlarnaNetworkPayment.h +5 -0
- package/ios/Sources/KlarnaNetworkPayment.mm +110 -0
- package/ios/Sources/KlarnaNetworkPaymentModuleImpl.swift +196 -0
- package/ios/Sources/KlarnaPaymentButtonComponentView.mm +147 -0
- package/ios/Sources/KlarnaPaymentButtonViewImpl.swift +77 -0
- package/ios/Sources/KlarnaPaymentPresentationMapping.swift +102 -0
- package/ios/Sources/KlarnaPaymentRequestDataMapping.swift +232 -0
- package/ios/Sources/KlarnaPaymentRequestMapping.swift +103 -0
- package/ios/Tests/KlarnaNetworkPaymentModuleImplTests.swift +143 -0
- package/ios/Tests/KlarnaPaymentButtonViewImplTests.swift +122 -0
- package/ios/Tests/KlarnaPaymentPresentationMappingTests.swift +335 -0
- package/lib/commonjs/KlarnaNetworkPayment.js +6 -0
- package/lib/commonjs/KlarnaNetworkPayment.js.map +1 -0
- package/lib/commonjs/KlarnaNetworkPaymentImpl.js +44 -0
- package/lib/commonjs/KlarnaNetworkPaymentImpl.js.map +1 -0
- package/lib/commonjs/KlarnaNetworkPaymentMapper.js +164 -0
- package/lib/commonjs/KlarnaNetworkPaymentMapper.js.map +1 -0
- package/lib/commonjs/KlarnaPaymentButton.js +43 -0
- package/lib/commonjs/KlarnaPaymentButton.js.map +1 -0
- package/lib/commonjs/Specs/KlarnaPaymentButtonNativeComponent.js +10 -0
- package/lib/commonjs/Specs/KlarnaPaymentButtonNativeComponent.js.map +1 -0
- package/lib/commonjs/Specs/NativeKlarnaNetworkPayment.js +13 -0
- package/lib/commonjs/Specs/NativeKlarnaNetworkPayment.js.map +1 -0
- package/lib/commonjs/index.js +51 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types/KlarnaPaymentRequest.js +6 -0
- package/lib/commonjs/types/KlarnaPaymentRequest.js.map +1 -0
- package/lib/commonjs/types/KlarnaPaymentRequestState.js +2 -0
- package/lib/commonjs/types/KlarnaPaymentRequestState.js.map +1 -0
- package/lib/commonjs/types/KlarnaPaymentRequestStateContext.js +6 -0
- package/lib/commonjs/types/KlarnaPaymentRequestStateContext.js.map +1 -0
- package/lib/commonjs/types/KlarnaPaymentRequestStateReason.js +2 -0
- package/lib/commonjs/types/KlarnaPaymentRequestStateReason.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaBillingPlan.js +6 -0
- package/lib/commonjs/types/models/KlarnaBillingPlan.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaCollectCustomerProfileType.js +2 -0
- package/lib/commonjs/types/models/KlarnaCollectCustomerProfileType.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaCustomer.js +6 -0
- package/lib/commonjs/types/models/KlarnaCustomer.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaFreeTrial.js +2 -0
- package/lib/commonjs/types/models/KlarnaFreeTrial.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaInterval.js +2 -0
- package/lib/commonjs/types/models/KlarnaInterval.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaLineItem.js +2 -0
- package/lib/commonjs/types/models/KlarnaLineItem.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaOndemandService.js +6 -0
- package/lib/commonjs/types/models/KlarnaOndemandService.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaPartnerCustomer.js +6 -0
- package/lib/commonjs/types/models/KlarnaPartnerCustomer.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaPaymentPresentation.js +6 -0
- package/lib/commonjs/types/models/KlarnaPaymentPresentation.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaPaymentRequestData.js +6 -0
- package/lib/commonjs/types/models/KlarnaPaymentRequestData.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaRequestCustomerToken.js +6 -0
- package/lib/commonjs/types/models/KlarnaRequestCustomerToken.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaRequestCustomerTokenScope.js +2 -0
- package/lib/commonjs/types/models/KlarnaRequestCustomerTokenScope.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaShipping.js +6 -0
- package/lib/commonjs/types/models/KlarnaShipping.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaShippingConfig.js +6 -0
- package/lib/commonjs/types/models/KlarnaShippingConfig.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaShippingConfigMode.js +2 -0
- package/lib/commonjs/types/models/KlarnaShippingConfigMode.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaShippingOption.js +6 -0
- package/lib/commonjs/types/models/KlarnaShippingOption.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaShippingRecipient.js +2 -0
- package/lib/commonjs/types/models/KlarnaShippingRecipient.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaShippingType.js +2 -0
- package/lib/commonjs/types/models/KlarnaShippingType.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaShippingTypeAttribute.js +2 -0
- package/lib/commonjs/types/models/KlarnaShippingTypeAttribute.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaSubscription.js +6 -0
- package/lib/commonjs/types/models/KlarnaSubscription.js.map +1 -0
- package/lib/commonjs/types/models/KlarnaSupplementaryPurchaseData.js +6 -0
- package/lib/commonjs/types/models/KlarnaSupplementaryPurchaseData.js.map +1 -0
- package/lib/commonjs/types/models/index.js +2 -0
- package/lib/commonjs/types/models/index.js.map +1 -0
- package/lib/module/KlarnaNetworkPayment.js +2 -0
- package/lib/module/KlarnaNetworkPayment.js.map +1 -0
- package/lib/module/KlarnaNetworkPaymentImpl.js +36 -0
- package/lib/module/KlarnaNetworkPaymentImpl.js.map +1 -0
- package/lib/module/KlarnaNetworkPaymentMapper.js +146 -0
- package/lib/module/KlarnaNetworkPaymentMapper.js.map +1 -0
- package/lib/module/KlarnaPaymentButton.js +37 -0
- package/lib/module/KlarnaPaymentButton.js.map +1 -0
- package/lib/module/Specs/KlarnaPaymentButtonNativeComponent.js +3 -0
- package/lib/module/Specs/KlarnaPaymentButtonNativeComponent.js.map +1 -0
- package/lib/module/Specs/NativeKlarnaNetworkPayment.js +9 -0
- package/lib/module/Specs/NativeKlarnaNetworkPayment.js.map +1 -0
- package/lib/module/index.js +40 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types/KlarnaPaymentRequest.js +2 -0
- package/lib/module/types/KlarnaPaymentRequest.js.map +1 -0
- package/lib/module/types/KlarnaPaymentRequestState.js +2 -0
- package/lib/module/types/KlarnaPaymentRequestState.js.map +1 -0
- package/lib/module/types/KlarnaPaymentRequestStateContext.js +2 -0
- package/lib/module/types/KlarnaPaymentRequestStateContext.js.map +1 -0
- package/lib/module/types/KlarnaPaymentRequestStateReason.js +2 -0
- package/lib/module/types/KlarnaPaymentRequestStateReason.js.map +1 -0
- package/lib/module/types/models/KlarnaBillingPlan.js +2 -0
- package/lib/module/types/models/KlarnaBillingPlan.js.map +1 -0
- package/lib/module/types/models/KlarnaCollectCustomerProfileType.js +2 -0
- package/lib/module/types/models/KlarnaCollectCustomerProfileType.js.map +1 -0
- package/lib/module/types/models/KlarnaCustomer.js +2 -0
- package/lib/module/types/models/KlarnaCustomer.js.map +1 -0
- package/lib/module/types/models/KlarnaFreeTrial.js +2 -0
- package/lib/module/types/models/KlarnaFreeTrial.js.map +1 -0
- package/lib/module/types/models/KlarnaInterval.js +2 -0
- package/lib/module/types/models/KlarnaInterval.js.map +1 -0
- package/lib/module/types/models/KlarnaLineItem.js +2 -0
- package/lib/module/types/models/KlarnaLineItem.js.map +1 -0
- package/lib/module/types/models/KlarnaOndemandService.js +2 -0
- package/lib/module/types/models/KlarnaOndemandService.js.map +1 -0
- package/lib/module/types/models/KlarnaPartnerCustomer.js +2 -0
- package/lib/module/types/models/KlarnaPartnerCustomer.js.map +1 -0
- package/lib/module/types/models/KlarnaPaymentPresentation.js +2 -0
- package/lib/module/types/models/KlarnaPaymentPresentation.js.map +1 -0
- package/lib/module/types/models/KlarnaPaymentRequestData.js +2 -0
- package/lib/module/types/models/KlarnaPaymentRequestData.js.map +1 -0
- package/lib/module/types/models/KlarnaRequestCustomerToken.js +2 -0
- package/lib/module/types/models/KlarnaRequestCustomerToken.js.map +1 -0
- package/lib/module/types/models/KlarnaRequestCustomerTokenScope.js +2 -0
- package/lib/module/types/models/KlarnaRequestCustomerTokenScope.js.map +1 -0
- package/lib/module/types/models/KlarnaShipping.js +2 -0
- package/lib/module/types/models/KlarnaShipping.js.map +1 -0
- package/lib/module/types/models/KlarnaShippingConfig.js +2 -0
- package/lib/module/types/models/KlarnaShippingConfig.js.map +1 -0
- package/lib/module/types/models/KlarnaShippingConfigMode.js +2 -0
- package/lib/module/types/models/KlarnaShippingConfigMode.js.map +1 -0
- package/lib/module/types/models/KlarnaShippingOption.js +2 -0
- package/lib/module/types/models/KlarnaShippingOption.js.map +1 -0
- package/lib/module/types/models/KlarnaShippingRecipient.js +2 -0
- package/lib/module/types/models/KlarnaShippingRecipient.js.map +1 -0
- package/lib/module/types/models/KlarnaShippingType.js +2 -0
- package/lib/module/types/models/KlarnaShippingType.js.map +1 -0
- package/lib/module/types/models/KlarnaShippingTypeAttribute.js +2 -0
- package/lib/module/types/models/KlarnaShippingTypeAttribute.js.map +1 -0
- package/lib/module/types/models/KlarnaSubscription.js +2 -0
- package/lib/module/types/models/KlarnaSubscription.js.map +1 -0
- package/lib/module/types/models/KlarnaSupplementaryPurchaseData.js +2 -0
- package/lib/module/types/models/KlarnaSupplementaryPurchaseData.js.map +1 -0
- package/lib/module/types/models/index.js +2 -0
- package/lib/module/types/models/index.js.map +1 -0
- package/lib/typescript/KlarnaNetworkPayment.d.ts +22 -0
- package/lib/typescript/KlarnaNetworkPayment.d.ts.map +1 -0
- package/lib/typescript/KlarnaNetworkPaymentImpl.d.ts +12 -0
- package/lib/typescript/KlarnaNetworkPaymentImpl.d.ts.map +1 -0
- package/lib/typescript/KlarnaNetworkPaymentMapper.d.ts +273 -0
- package/lib/typescript/KlarnaNetworkPaymentMapper.d.ts.map +1 -0
- package/lib/typescript/KlarnaPaymentButton.d.ts +51 -0
- package/lib/typescript/KlarnaPaymentButton.d.ts.map +1 -0
- package/lib/typescript/Specs/KlarnaPaymentButtonNativeComponent.d.ts +16 -0
- package/lib/typescript/Specs/KlarnaPaymentButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/Specs/NativeKlarnaNetworkPayment.d.ts +13 -0
- package/lib/typescript/Specs/NativeKlarnaNetworkPayment.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +14 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/types/KlarnaPaymentRequest.d.ts +19 -0
- package/lib/typescript/types/KlarnaPaymentRequest.d.ts.map +1 -0
- package/lib/typescript/types/KlarnaPaymentRequestState.d.ts +15 -0
- package/lib/typescript/types/KlarnaPaymentRequestState.d.ts.map +1 -0
- package/lib/typescript/types/KlarnaPaymentRequestStateContext.d.ts +12 -0
- package/lib/typescript/types/KlarnaPaymentRequestStateContext.d.ts.map +1 -0
- package/lib/typescript/types/KlarnaPaymentRequestStateReason.d.ts +13 -0
- package/lib/typescript/types/KlarnaPaymentRequestStateReason.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaBillingPlan.d.ts +17 -0
- package/lib/typescript/types/models/KlarnaBillingPlan.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaCollectCustomerProfileType.d.ts +19 -0
- package/lib/typescript/types/models/KlarnaCollectCustomerProfileType.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaCustomer.d.ts +11 -0
- package/lib/typescript/types/models/KlarnaCustomer.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaFreeTrial.d.ts +7 -0
- package/lib/typescript/types/models/KlarnaFreeTrial.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaInterval.d.ts +11 -0
- package/lib/typescript/types/models/KlarnaInterval.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaLineItem.d.ts +28 -0
- package/lib/typescript/types/models/KlarnaLineItem.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaOndemandService.d.ts +17 -0
- package/lib/typescript/types/models/KlarnaOndemandService.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaPartnerCustomer.d.ts +15 -0
- package/lib/typescript/types/models/KlarnaPartnerCustomer.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaPaymentPresentation.d.ts +119 -0
- package/lib/typescript/types/models/KlarnaPaymentPresentation.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaPaymentRequestData.d.ts +24 -0
- package/lib/typescript/types/models/KlarnaPaymentRequestData.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaRequestCustomerToken.d.ts +9 -0
- package/lib/typescript/types/models/KlarnaRequestCustomerToken.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaRequestCustomerTokenScope.d.ts +9 -0
- package/lib/typescript/types/models/KlarnaRequestCustomerTokenScope.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaShipping.d.ts +15 -0
- package/lib/typescript/types/models/KlarnaShipping.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaShippingConfig.d.ts +9 -0
- package/lib/typescript/types/models/KlarnaShippingConfig.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaShippingConfigMode.d.ts +5 -0
- package/lib/typescript/types/models/KlarnaShippingConfigMode.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaShippingOption.d.ts +12 -0
- package/lib/typescript/types/models/KlarnaShippingOption.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaShippingRecipient.d.ts +14 -0
- package/lib/typescript/types/models/KlarnaShippingRecipient.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaShippingType.d.ts +25 -0
- package/lib/typescript/types/models/KlarnaShippingType.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaShippingTypeAttribute.d.ts +21 -0
- package/lib/typescript/types/models/KlarnaShippingTypeAttribute.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaSubscription.d.ts +14 -0
- package/lib/typescript/types/models/KlarnaSubscription.d.ts.map +1 -0
- package/lib/typescript/types/models/KlarnaSupplementaryPurchaseData.d.ts +21 -0
- package/lib/typescript/types/models/KlarnaSupplementaryPurchaseData.d.ts.map +1 -0
- package/lib/typescript/types/models/index.d.ts +22 -0
- package/lib/typescript/types/models/index.d.ts.map +1 -0
- package/package.json +120 -6
- package/react-native-klarna-network-payment.podspec +28 -0
- package/src/KlarnaNetworkPayment.ts +30 -0
- package/src/KlarnaNetworkPaymentImpl.ts +79 -0
- package/src/KlarnaNetworkPaymentMapper.ts +204 -0
- package/src/KlarnaPaymentButton.tsx +80 -0
- package/src/Specs/KlarnaPaymentButtonNativeComponent.ts +22 -0
- package/src/Specs/NativeKlarnaNetworkPayment.ts +17 -0
- package/src/index.tsx +63 -0
- package/src/types/KlarnaPaymentRequest.ts +19 -0
- package/src/types/KlarnaPaymentRequestState.ts +14 -0
- package/src/types/KlarnaPaymentRequestStateContext.ts +12 -0
- package/src/types/KlarnaPaymentRequestStateReason.ts +12 -0
- package/src/types/models/KlarnaBillingPlan.ts +17 -0
- package/src/types/models/KlarnaCollectCustomerProfileType.ts +18 -0
- package/src/types/models/KlarnaCustomer.ts +11 -0
- package/src/types/models/KlarnaFreeTrial.ts +6 -0
- package/src/types/models/KlarnaInterval.ts +10 -0
- package/src/types/models/KlarnaLineItem.ts +27 -0
- package/src/types/models/KlarnaOndemandService.ts +17 -0
- package/src/types/models/KlarnaPartnerCustomer.ts +15 -0
- package/src/types/models/KlarnaPaymentPresentation.ts +135 -0
- package/src/types/models/KlarnaPaymentRequestData.ts +24 -0
- package/src/types/models/KlarnaRequestCustomerToken.ts +9 -0
- package/src/types/models/KlarnaRequestCustomerTokenScope.ts +8 -0
- package/src/types/models/KlarnaShipping.ts +15 -0
- package/src/types/models/KlarnaShippingConfig.ts +9 -0
- package/src/types/models/KlarnaShippingConfigMode.ts +4 -0
- package/src/types/models/KlarnaShippingOption.ts +12 -0
- package/src/types/models/KlarnaShippingRecipient.ts +13 -0
- package/src/types/models/KlarnaShippingType.ts +24 -0
- package/src/types/models/KlarnaShippingTypeAttribute.ts +20 -0
- package/src/types/models/KlarnaSubscription.ts +14 -0
- package/src/types/models/KlarnaSupplementaryPurchaseData.ts +21 -0
- package/src/types/models/index.ts +35 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Additional attribute for a shipping type. */
|
|
2
|
+
export type KlarnaShippingTypeAttribute =
|
|
3
|
+
/** Delivery is contactless. */
|
|
4
|
+
'CONTACTLESS_DELIVERY'
|
|
5
|
+
/** Express delivery. */
|
|
6
|
+
| 'EXPRESS'
|
|
7
|
+
/** Identification is required upon delivery. */
|
|
8
|
+
| 'IDENTIFICATION_REQUIRED'
|
|
9
|
+
/** Package may be left at the curb. */
|
|
10
|
+
| 'LEAVE_AT_CURB'
|
|
11
|
+
/** Package may be left at the door. */
|
|
12
|
+
| 'LEAVE_AT_DOOR'
|
|
13
|
+
/** Package may be left with a neighbour. */
|
|
14
|
+
| 'LEAVE_WITH_NEIGHBOUR'
|
|
15
|
+
/** Signature is required upon delivery. */
|
|
16
|
+
| 'SIGNATURE_REQUIRED'
|
|
17
|
+
/** Delivery is tracked. */
|
|
18
|
+
| 'TRACKED'
|
|
19
|
+
/** Delivery is not tracked. */
|
|
20
|
+
| 'UNTRACKED';
|
|
21
|
+
//# sourceMappingURL=KlarnaShippingTypeAttribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaShippingTypeAttribute.d.ts","sourceRoot":"","sources":["../../../../src/types/models/KlarnaShippingTypeAttribute.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,MAAM,MAAM,2BAA2B;AACrC,+BAA+B;AAC7B,sBAAsB;AACxB,wBAAwB;GACtB,SAAS;AACX,gDAAgD;GAC9C,yBAAyB;AAC3B,uCAAuC;GACrC,eAAe;AACjB,uCAAuC;GACrC,eAAe;AACjB,4CAA4C;GAC1C,sBAAsB;AACxB,2CAA2C;GACzC,oBAAoB;AACtB,2BAA2B;GACzB,SAAS;AACX,+BAA+B;GAC7B,WAAW,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { KlarnaBillingPlan } from './KlarnaBillingPlan';
|
|
2
|
+
import type { KlarnaFreeTrial } from './KlarnaFreeTrial';
|
|
3
|
+
/** Subscription details for a payment request. */
|
|
4
|
+
export type KlarnaSubscription = {
|
|
5
|
+
/** Reference for the subscription. */
|
|
6
|
+
subscriptionReference: string;
|
|
7
|
+
/** Name of the subscription. */
|
|
8
|
+
name?: string;
|
|
9
|
+
/** Free trial status. */
|
|
10
|
+
freeTrial?: KlarnaFreeTrial;
|
|
11
|
+
/** Billing plans for the subscription. */
|
|
12
|
+
billingPlans?: KlarnaBillingPlan[];
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=KlarnaSubscription.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaSubscription.d.ts","sourceRoot":"","sources":["../../../../src/types/models/KlarnaSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,kDAAkD;AAClD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,sCAAsC;IACtC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,0CAA0C;IAC1C,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACpC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { KlarnaLineItem } from './KlarnaLineItem';
|
|
2
|
+
import type { KlarnaOndemandService } from './KlarnaOndemandService';
|
|
3
|
+
import type { KlarnaPartnerCustomer } from './KlarnaPartnerCustomer';
|
|
4
|
+
import type { KlarnaShipping } from './KlarnaShipping';
|
|
5
|
+
import type { KlarnaSubscription } from './KlarnaSubscription';
|
|
6
|
+
/** Supplementary purchase data for a payment request. */
|
|
7
|
+
export type KlarnaSupplementaryPurchaseData = {
|
|
8
|
+
/** Customer information. */
|
|
9
|
+
customer?: KlarnaPartnerCustomer;
|
|
10
|
+
/** List of line items in the order. */
|
|
11
|
+
lineItems?: KlarnaLineItem[];
|
|
12
|
+
/** Reference for the purchase. */
|
|
13
|
+
purchaseReference?: string;
|
|
14
|
+
/** List of shipping information. */
|
|
15
|
+
shipping?: KlarnaShipping[];
|
|
16
|
+
/** On-demand service information. */
|
|
17
|
+
ondemandService?: KlarnaOndemandService;
|
|
18
|
+
/** List of subscriptions. */
|
|
19
|
+
subscriptions?: KlarnaSubscription[];
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=KlarnaSupplementaryPurchaseData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlarnaSupplementaryPurchaseData.d.ts","sourceRoot":"","sources":["../../../../src/types/models/KlarnaSupplementaryPurchaseData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,yDAAyD;AACzD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IACjC,uCAAuC;IACvC,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;IAC7B,kCAAkC;IAClC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oCAAoC;IACpC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,qCAAqC;IACrC,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,6BAA6B;IAC7B,aAAa,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACtC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type { KlarnaBillingPlan } from './KlarnaBillingPlan';
|
|
2
|
+
export type { KlarnaCollectCustomerProfileType } from './KlarnaCollectCustomerProfileType';
|
|
3
|
+
export type { KlarnaCustomer } from './KlarnaCustomer';
|
|
4
|
+
export type { KlarnaFreeTrial } from './KlarnaFreeTrial';
|
|
5
|
+
export type { KlarnaInterval } from './KlarnaInterval';
|
|
6
|
+
export type { KlarnaLineItem } from './KlarnaLineItem';
|
|
7
|
+
export type { KlarnaOndemandService } from './KlarnaOndemandService';
|
|
8
|
+
export type { KlarnaPartnerCustomer } from './KlarnaPartnerCustomer';
|
|
9
|
+
export type { KlarnaPaymentRequestData } from './KlarnaPaymentRequestData';
|
|
10
|
+
export type { KlarnaRequestCustomerToken } from './KlarnaRequestCustomerToken';
|
|
11
|
+
export type { KlarnaRequestCustomerTokenScope } from './KlarnaRequestCustomerTokenScope';
|
|
12
|
+
export type { KlarnaShipping } from './KlarnaShipping';
|
|
13
|
+
export type { KlarnaShippingConfig } from './KlarnaShippingConfig';
|
|
14
|
+
export type { KlarnaShippingConfigMode } from './KlarnaShippingConfigMode';
|
|
15
|
+
export type { KlarnaShippingOption } from './KlarnaShippingOption';
|
|
16
|
+
export type { KlarnaShippingRecipient } from './KlarnaShippingRecipient';
|
|
17
|
+
export type { KlarnaShippingType } from './KlarnaShippingType';
|
|
18
|
+
export type { KlarnaShippingTypeAttribute } from './KlarnaShippingTypeAttribute';
|
|
19
|
+
export type { KlarnaSubscription } from './KlarnaSubscription';
|
|
20
|
+
export type { KlarnaSupplementaryPurchaseData } from './KlarnaSupplementaryPurchaseData';
|
|
21
|
+
export type { KlarnaPaymentPresentationContent, KlarnaPaymentPresentationData, KlarnaPaymentPresentationIcon, KlarnaPaymentPresentationImageAlignment, KlarnaPaymentPresentationInstruction, KlarnaPaymentPresentationIntent, KlarnaPaymentPresentationPaymentButton, KlarnaPaymentPresentationPaymentOption, KlarnaPaymentPresentationPaymentStatus, KlarnaPaymentPresentationText, KlarnaPaymentPresentationTextPart, KlarnaPaymentPresentationTextPartLinkContext, KlarnaPaymentPresentationTextPartStyle, } from './KlarnaPaymentPresentation';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/models/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,YAAY,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAC3F,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,YAAY,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACzF,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,YAAY,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,YAAY,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACjF,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,YAAY,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACzF,YAAY,EACV,gCAAgC,EAChC,6BAA6B,EAC7B,6BAA6B,EAC7B,uCAAuC,EACvC,oCAAoC,EACpC,+BAA+B,EAC/B,sCAAsC,EACtC,sCAAsC,EACtC,sCAAsC,EACtC,6BAA6B,EAC7B,iCAAiC,EACjC,4CAA4C,EAC5C,sCAAsC,GACvC,MAAM,6BAA6B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,124 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klarna/react-native-klarna-network-payment",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.7.0",
|
|
4
|
+
"description": "React Native package for Klarna Network Payment",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
6
|
+
"react-native",
|
|
7
|
+
"klarna",
|
|
8
|
+
"sdk",
|
|
9
|
+
"network",
|
|
10
|
+
"payment"
|
|
11
|
+
],
|
|
12
|
+
"repository": "https://github.com/klarna/react-native-klarna-inapp-sdk",
|
|
13
|
+
"main": "./src/index.tsx",
|
|
14
|
+
"codegenConfig": {
|
|
15
|
+
"name": "KlarnaNetworkPaymentSpec",
|
|
16
|
+
"type": "all",
|
|
17
|
+
"jsSrcsDir": "src",
|
|
18
|
+
"android": {
|
|
19
|
+
"javaPackageName": "com.klarna.mobile.sdk.reactnative.klarnanetwork.payment"
|
|
20
|
+
},
|
|
21
|
+
"ios": {
|
|
22
|
+
"componentProvider": {
|
|
23
|
+
"KlarnaNetworkPaymentButton": "KlarnaPaymentButtonComponentView"
|
|
24
|
+
},
|
|
25
|
+
"modulesProvider": {
|
|
26
|
+
"KlarnaNetworkPayment": "KlarnaNetworkPayment"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"author": "Mobile SDK <mobile.sdk@klarna.com>",
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"homepage": "https://github.com/klarna/react-native-klarna-inapp-sdk#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/klarna/react-native-klarna-inapp-sdk/issues"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"src",
|
|
41
|
+
"lib",
|
|
42
|
+
"android",
|
|
43
|
+
"ios",
|
|
44
|
+
"*.podspec",
|
|
45
|
+
"!ios/build",
|
|
46
|
+
"!ios/Pods",
|
|
47
|
+
"!android/build",
|
|
48
|
+
"!android/gradle",
|
|
49
|
+
"!android/gradlew",
|
|
50
|
+
"!android/gradlew.bat",
|
|
51
|
+
"!android/local.properties",
|
|
52
|
+
"!**/__tests__",
|
|
53
|
+
"!**/__fixtures__",
|
|
54
|
+
"!**/__mocks__",
|
|
55
|
+
"!**/.*"
|
|
56
|
+
],
|
|
57
|
+
"create-react-native-library": {
|
|
58
|
+
"type": "turbo-module",
|
|
59
|
+
"languages": "kotlin-objc",
|
|
60
|
+
"tools": [
|
|
61
|
+
"eslint"
|
|
62
|
+
],
|
|
63
|
+
"version": "0.62.0"
|
|
64
|
+
},
|
|
65
|
+
"types": "./src/index.tsx",
|
|
66
|
+
"react-native": "./src/index.tsx",
|
|
67
|
+
"source": "./src/index.tsx",
|
|
68
|
+
"exports": {
|
|
69
|
+
".": {
|
|
70
|
+
"source": "./src/index.tsx",
|
|
71
|
+
"types": "./src/index.tsx",
|
|
72
|
+
"react-native": "./src/index.tsx",
|
|
73
|
+
"default": "./src/index.tsx"
|
|
74
|
+
},
|
|
75
|
+
"./package.json": "./package.json"
|
|
76
|
+
},
|
|
77
|
+
"packageManager": "yarn@4.4.0",
|
|
78
|
+
"scripts": {
|
|
79
|
+
"prepack": "bob build",
|
|
80
|
+
"test": "jest",
|
|
81
|
+
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
82
|
+
"lint:fix": "eslint \"src/**/*.{js,ts,tsx}\" --fix",
|
|
83
|
+
"prettier": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
|
|
84
|
+
"prettier:fix": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\"",
|
|
85
|
+
"typecheck": "tsc --noEmit",
|
|
86
|
+
"test:ios": "xcodebuild test -workspace ../../TestApp/ios/TestApp.xcworkspace -scheme 'react-native-klarna-network-payment-Unit-Tests' -destination 'platform=iOS Simulator,name=iPhone 17 Pro'"
|
|
87
|
+
},
|
|
88
|
+
"devDependencies": {
|
|
89
|
+
"@klarna/react-native-klarna-network-core": "workspace:*",
|
|
90
|
+
"@types/jest": "^29.5.4",
|
|
91
|
+
"@types/react": "^18.0.24",
|
|
92
|
+
"@types/react-native": "^0.72.2",
|
|
93
|
+
"jest": "^29.2.1",
|
|
94
|
+
"metro-react-native-babel-preset": "0.76.8",
|
|
95
|
+
"react": "18.2.0",
|
|
96
|
+
"react-native": "0.76.0",
|
|
97
|
+
"react-native-builder-bob": "^0.20.0",
|
|
98
|
+
"typescript": "^5.0.2"
|
|
99
|
+
},
|
|
100
|
+
"peerDependencies": {
|
|
101
|
+
"@klarna/react-native-klarna-network-core": "2.7.0",
|
|
102
|
+
"react": ">=18.2.0",
|
|
103
|
+
"react-native": ">=0.76.0 <1.0.x"
|
|
104
|
+
},
|
|
105
|
+
"react-native-builder-bob": {
|
|
106
|
+
"source": "src",
|
|
107
|
+
"output": "lib",
|
|
108
|
+
"targets": [
|
|
109
|
+
"commonjs",
|
|
110
|
+
"module",
|
|
111
|
+
"typescript"
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"jest": {
|
|
115
|
+
"preset": "react-native",
|
|
116
|
+
"testPathIgnorePatterns": [
|
|
117
|
+
"/node_modules/",
|
|
118
|
+
"/lib/"
|
|
119
|
+
],
|
|
120
|
+
"transformIgnorePatterns": [
|
|
121
|
+
"node_modules/(?!(react-native|@react-native)/)"
|
|
122
|
+
]
|
|
123
|
+
}
|
|
10
124
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "react-native-klarna-network-payment"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.swift_version = '5.0'
|
|
15
|
+
s.source = { :git => "https://github.com/klarna/react-native-klarna-inapp-sdk.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/Sources/**/*.{h,m,mm,swift,cpp}"
|
|
18
|
+
s.private_header_files = "ios/Sources/**/*.h"
|
|
19
|
+
|
|
20
|
+
install_modules_dependencies(s)
|
|
21
|
+
|
|
22
|
+
s.dependency 'KlarnaMobileSDK/KlarnaNetworkPayment', '2.11.7'
|
|
23
|
+
s.dependency 'react-native-klarna-network-core', s.version.to_s
|
|
24
|
+
|
|
25
|
+
s.test_spec 'Tests' do |ts|
|
|
26
|
+
ts.source_files = 'ios/Tests/**/*.swift'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { KlarnaPaymentRequest } from './types/KlarnaPaymentRequest';
|
|
2
|
+
import type { KlarnaPaymentRequestData } from './types/models/KlarnaPaymentRequestData';
|
|
3
|
+
import type {
|
|
4
|
+
KlarnaPaymentPresentationContent,
|
|
5
|
+
KlarnaPaymentPresentationData,
|
|
6
|
+
} from './types/models/KlarnaPaymentPresentation';
|
|
7
|
+
|
|
8
|
+
/** Provides access to payment presentation content for rendering Klarna UI elements. */
|
|
9
|
+
export interface KlarnaPaymentPresentation {
|
|
10
|
+
/** Fetches presentation content for the given amount, currency, and intent. */
|
|
11
|
+
fetch(
|
|
12
|
+
data: KlarnaPaymentPresentationData
|
|
13
|
+
): Promise<KlarnaPaymentPresentationContent>;
|
|
14
|
+
/** Handles a deep link URL returned from the Klarna flow and returns updated presentation content. */
|
|
15
|
+
handleLink(url: string): Promise<KlarnaPaymentPresentationContent>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Entry point for managing the Klarna Network Payment lifecycle. */
|
|
19
|
+
export interface KlarnaPayment {
|
|
20
|
+
/** Provides access to payment presentation content. */
|
|
21
|
+
readonly presentation: KlarnaPaymentPresentation;
|
|
22
|
+
/** Initiates a payment request by its existing payment request ID or data for client side payment request creation. */
|
|
23
|
+
initiate(
|
|
24
|
+
paymentRequestIdOrData: string | KlarnaPaymentRequestData
|
|
25
|
+
): Promise<KlarnaPaymentRequest>;
|
|
26
|
+
/** Fetches the current state of a payment request by its ID. */
|
|
27
|
+
fetch(paymentRequestId: string): Promise<KlarnaPaymentRequest>;
|
|
28
|
+
/** Cancels a payment request by its ID. */
|
|
29
|
+
cancel(paymentRequestId: string): Promise<KlarnaPaymentRequest>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import NativeKlarnaNetworkPayment from './Specs/NativeKlarnaNetworkPayment';
|
|
2
|
+
import type {
|
|
3
|
+
KlarnaPayment,
|
|
4
|
+
KlarnaPaymentPresentation,
|
|
5
|
+
} from './KlarnaNetworkPayment';
|
|
6
|
+
import type { KlarnaPaymentRequest } from './types/KlarnaPaymentRequest';
|
|
7
|
+
import type { KlarnaPaymentRequestData } from './types/models/KlarnaPaymentRequestData';
|
|
8
|
+
import type {
|
|
9
|
+
KlarnaPaymentPresentationContent,
|
|
10
|
+
KlarnaPaymentPresentationData,
|
|
11
|
+
} from './types/models/KlarnaPaymentPresentation';
|
|
12
|
+
import {
|
|
13
|
+
mapPaymentRequest,
|
|
14
|
+
mapPaymentRequestData,
|
|
15
|
+
mapPresentationContent,
|
|
16
|
+
} from './KlarnaNetworkPaymentMapper';
|
|
17
|
+
|
|
18
|
+
class KlarnaPaymentPresentationImpl implements KlarnaPaymentPresentation {
|
|
19
|
+
constructor(private readonly instanceId: string) {}
|
|
20
|
+
|
|
21
|
+
fetch(
|
|
22
|
+
data: KlarnaPaymentPresentationData
|
|
23
|
+
): Promise<KlarnaPaymentPresentationContent> {
|
|
24
|
+
return NativeKlarnaNetworkPayment.presentationFetch(
|
|
25
|
+
this.instanceId,
|
|
26
|
+
data as unknown as Object
|
|
27
|
+
).then(mapPresentationContent);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
handleLink(url: string): Promise<KlarnaPaymentPresentationContent> {
|
|
31
|
+
return NativeKlarnaNetworkPayment.presentationHandleLink(
|
|
32
|
+
this.instanceId,
|
|
33
|
+
url
|
|
34
|
+
).then(mapPresentationContent);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class KlarnaNetworkPaymentImpl implements KlarnaPayment {
|
|
39
|
+
private readonly instanceId: string;
|
|
40
|
+
readonly presentation: KlarnaPaymentPresentation;
|
|
41
|
+
|
|
42
|
+
constructor(instanceId: string) {
|
|
43
|
+
this.instanceId = instanceId;
|
|
44
|
+
this.presentation = new KlarnaPaymentPresentationImpl(instanceId);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
initiate(
|
|
48
|
+
paymentRequestIdOrData: string | KlarnaPaymentRequestData
|
|
49
|
+
): Promise<KlarnaPaymentRequest> {
|
|
50
|
+
if (typeof paymentRequestIdOrData === 'string') {
|
|
51
|
+
return NativeKlarnaNetworkPayment.initiateWithId(
|
|
52
|
+
this.instanceId,
|
|
53
|
+
paymentRequestIdOrData
|
|
54
|
+
).then(mapPaymentRequest);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return NativeKlarnaNetworkPayment.initiateWithData(
|
|
58
|
+
this.instanceId,
|
|
59
|
+
mapPaymentRequestData(paymentRequestIdOrData)
|
|
60
|
+
).then(mapPaymentRequest);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
return Promise.reject(e);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fetch(paymentRequestId: string): Promise<KlarnaPaymentRequest> {
|
|
67
|
+
return NativeKlarnaNetworkPayment.fetch(
|
|
68
|
+
this.instanceId,
|
|
69
|
+
paymentRequestId
|
|
70
|
+
).then(mapPaymentRequest);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
cancel(paymentRequestId: string): Promise<KlarnaPaymentRequest> {
|
|
74
|
+
return NativeKlarnaNetworkPayment.cancel(
|
|
75
|
+
this.instanceId,
|
|
76
|
+
paymentRequestId
|
|
77
|
+
).then(mapPaymentRequest);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { KlarnaAddress } from '@klarna/react-native-klarna-network-core';
|
|
2
|
+
import type { KlarnaBillingPlan } from './types/models/KlarnaBillingPlan';
|
|
3
|
+
import type { KlarnaLineItem } from './types/models/KlarnaLineItem';
|
|
4
|
+
import type { KlarnaOndemandService } from './types/models/KlarnaOndemandService';
|
|
5
|
+
import type { KlarnaPartnerCustomer } from './types/models/KlarnaPartnerCustomer';
|
|
6
|
+
import type { KlarnaPaymentRequest } from './types/KlarnaPaymentRequest';
|
|
7
|
+
import type { KlarnaPaymentRequestData } from './types/models/KlarnaPaymentRequestData';
|
|
8
|
+
import type { KlarnaPaymentRequestState } from './types/KlarnaPaymentRequestState';
|
|
9
|
+
import type { KlarnaPaymentRequestStateReason } from './types/KlarnaPaymentRequestStateReason';
|
|
10
|
+
import type { KlarnaRequestCustomerToken } from './types/models/KlarnaRequestCustomerToken';
|
|
11
|
+
import type { KlarnaShipping } from './types/models/KlarnaShipping';
|
|
12
|
+
import type { KlarnaShippingConfig } from './types/models/KlarnaShippingConfig';
|
|
13
|
+
import type { KlarnaSubscription } from './types/models/KlarnaSubscription';
|
|
14
|
+
import type { KlarnaSupplementaryPurchaseData } from './types/models/KlarnaSupplementaryPurchaseData';
|
|
15
|
+
import type { KlarnaPaymentPresentationContent } from './types/models/KlarnaPaymentPresentation';
|
|
16
|
+
|
|
17
|
+
function requireFiniteNumber(value: unknown, label: string): number {
|
|
18
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
19
|
+
throw new Error(`${label} must be a finite number, got ${value}`);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function mapAddress(address: KlarnaAddress | undefined) {
|
|
25
|
+
if (!address) return null;
|
|
26
|
+
return {
|
|
27
|
+
streetAddress: address.streetAddress ?? null,
|
|
28
|
+
streetAddress2: address.streetAddress2 ?? null,
|
|
29
|
+
city: address.city ?? null,
|
|
30
|
+
region: address.region ?? null,
|
|
31
|
+
postalCode: address.postalCode ?? null,
|
|
32
|
+
country: address.country ?? null,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function mapLineItem(item: KlarnaLineItem) {
|
|
37
|
+
requireFiniteNumber(
|
|
38
|
+
item.totalAmount,
|
|
39
|
+
`KlarnaLineItem "${item.name}": totalAmount`
|
|
40
|
+
);
|
|
41
|
+
requireFiniteNumber(item.quantity, `KlarnaLineItem "${item.name}": quantity`);
|
|
42
|
+
return {
|
|
43
|
+
currency: item.currency ?? null,
|
|
44
|
+
imageUrl: item.imageUrl ?? null,
|
|
45
|
+
name: item.name,
|
|
46
|
+
productIdentifier: item.productIdentifier ?? null,
|
|
47
|
+
productUrl: item.productUrl ?? null,
|
|
48
|
+
quantity: item.quantity,
|
|
49
|
+
lineItemReference: item.lineItemReference ?? null,
|
|
50
|
+
shippingReference: item.shippingReference ?? null,
|
|
51
|
+
subscriptionReference: item.subscriptionReference ?? null,
|
|
52
|
+
totalAmount: item.totalAmount,
|
|
53
|
+
totalTaxAmount: item.totalTaxAmount ?? null,
|
|
54
|
+
unitPrice: item.unitPrice ?? null,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function mapPartnerCustomer(
|
|
59
|
+
customer: KlarnaPartnerCustomer | undefined
|
|
60
|
+
) {
|
|
61
|
+
if (!customer) return null;
|
|
62
|
+
return {
|
|
63
|
+
address: mapAddress(customer.address),
|
|
64
|
+
email: customer.email ?? null,
|
|
65
|
+
familyName: customer.familyName ?? null,
|
|
66
|
+
givenName: customer.givenName ?? null,
|
|
67
|
+
phone: customer.phone ?? null,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function mapShipping(shipping: KlarnaShipping) {
|
|
72
|
+
return {
|
|
73
|
+
address: mapAddress(shipping.address),
|
|
74
|
+
recipient: shipping.recipient
|
|
75
|
+
? {
|
|
76
|
+
attention: shipping.recipient.attention ?? null,
|
|
77
|
+
email: shipping.recipient.email ?? null,
|
|
78
|
+
familyName: shipping.recipient.familyName,
|
|
79
|
+
givenName: shipping.recipient.givenName,
|
|
80
|
+
phone: shipping.recipient.phone ?? null,
|
|
81
|
+
}
|
|
82
|
+
: null,
|
|
83
|
+
shippingOption: shipping.shippingOption
|
|
84
|
+
? {
|
|
85
|
+
shippingCarrier: shipping.shippingOption.shippingCarrier ?? null,
|
|
86
|
+
shippingType: shipping.shippingOption.shippingType,
|
|
87
|
+
shippingTypeAttributes:
|
|
88
|
+
shipping.shippingOption.shippingTypeAttributes ?? null,
|
|
89
|
+
}
|
|
90
|
+
: null,
|
|
91
|
+
shippingReference: shipping.shippingReference ?? null,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function mapOndemandService(service: KlarnaOndemandService | undefined) {
|
|
96
|
+
if (!service) return null;
|
|
97
|
+
return {
|
|
98
|
+
currency: service.currency ?? null,
|
|
99
|
+
averageAmount: service.averageAmount ?? null,
|
|
100
|
+
minimumAmount: service.minimumAmount ?? null,
|
|
101
|
+
maximumAmount: service.maximumAmount ?? null,
|
|
102
|
+
purchaseInterval: service.purchaseInterval ?? null,
|
|
103
|
+
purchaseIntervalFrequency: service.purchaseIntervalFrequency ?? null,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function mapBillingPlan(plan: KlarnaBillingPlan) {
|
|
108
|
+
requireFiniteNumber(plan.billingAmount, 'KlarnaBillingPlan: billingAmount');
|
|
109
|
+
requireFiniteNumber(
|
|
110
|
+
plan.intervalFrequency,
|
|
111
|
+
'KlarnaBillingPlan: intervalFrequency'
|
|
112
|
+
);
|
|
113
|
+
return {
|
|
114
|
+
billingAmount: plan.billingAmount,
|
|
115
|
+
currency: plan.currency ?? null,
|
|
116
|
+
from: plan.from,
|
|
117
|
+
interval: plan.interval,
|
|
118
|
+
intervalFrequency: plan.intervalFrequency,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function mapSubscription(s: KlarnaSubscription) {
|
|
123
|
+
return {
|
|
124
|
+
subscriptionReference: s.subscriptionReference,
|
|
125
|
+
name: s.name ?? null,
|
|
126
|
+
freeTrial: s.freeTrial ?? null,
|
|
127
|
+
billingPlans: s.billingPlans ? s.billingPlans.map(mapBillingPlan) : null,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function mapRequestCustomerToken(
|
|
132
|
+
token: KlarnaRequestCustomerToken | undefined
|
|
133
|
+
) {
|
|
134
|
+
if (!token) return null;
|
|
135
|
+
return {
|
|
136
|
+
scopes: token.scopes,
|
|
137
|
+
customerTokenReference: token.customerTokenReference ?? null,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function mapShippingConfig(config: KlarnaShippingConfig | undefined) {
|
|
142
|
+
if (!config) return null;
|
|
143
|
+
return {
|
|
144
|
+
supportedCountries: config.supportedCountries ?? null,
|
|
145
|
+
mode: config.mode,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function mapSupplementaryPurchaseData(
|
|
150
|
+
d: KlarnaSupplementaryPurchaseData | undefined
|
|
151
|
+
) {
|
|
152
|
+
if (!d) return null;
|
|
153
|
+
return {
|
|
154
|
+
customer: mapPartnerCustomer(d.customer),
|
|
155
|
+
lineItems: d.lineItems ? d.lineItems.map(mapLineItem) : null,
|
|
156
|
+
purchaseReference: d.purchaseReference ?? null,
|
|
157
|
+
shipping: d.shipping ? d.shipping.map(mapShipping) : null,
|
|
158
|
+
ondemandService: mapOndemandService(d.ondemandService),
|
|
159
|
+
subscriptions: d.subscriptions
|
|
160
|
+
? d.subscriptions.map(mapSubscription)
|
|
161
|
+
: null,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function mapPaymentRequestData(data: KlarnaPaymentRequestData) {
|
|
166
|
+
requireFiniteNumber(data.amount, 'KlarnaPaymentRequestData: amount');
|
|
167
|
+
return {
|
|
168
|
+
amount: data.amount,
|
|
169
|
+
currency: data.currency,
|
|
170
|
+
paymentOptionId: data.paymentOptionId ?? null,
|
|
171
|
+
paymentRequestReference: data.paymentRequestReference ?? null,
|
|
172
|
+
requestCustomerToken: mapRequestCustomerToken(data.requestCustomerToken),
|
|
173
|
+
shippingConfig: mapShippingConfig(data.shippingConfig),
|
|
174
|
+
collectCustomerProfile: data.collectCustomerProfile ?? null,
|
|
175
|
+
supplementaryPurchaseData: mapSupplementaryPurchaseData(
|
|
176
|
+
data.supplementaryPurchaseData
|
|
177
|
+
),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function mapPaymentRequest(raw: any): KlarnaPaymentRequest {
|
|
182
|
+
const spec = raw as {
|
|
183
|
+
paymentRequestId: string;
|
|
184
|
+
state: string;
|
|
185
|
+
previousState: string | null;
|
|
186
|
+
stateContext: { klarnaNetworkSessionToken: string | null } | null;
|
|
187
|
+
stateReason: string | null;
|
|
188
|
+
paymentRequestReference: string | null;
|
|
189
|
+
};
|
|
190
|
+
return {
|
|
191
|
+
paymentRequestId: spec.paymentRequestId,
|
|
192
|
+
state: spec.state as KlarnaPaymentRequestState,
|
|
193
|
+
previousState: spec.previousState as KlarnaPaymentRequestState | null,
|
|
194
|
+
stateContext: spec.stateContext,
|
|
195
|
+
stateReason: spec.stateReason as KlarnaPaymentRequestStateReason | null,
|
|
196
|
+
paymentRequestReference: spec.paymentRequestReference,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function mapPresentationContent(
|
|
201
|
+
raw: any
|
|
202
|
+
): KlarnaPaymentPresentationContent {
|
|
203
|
+
return raw as KlarnaPaymentPresentationContent;
|
|
204
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import RNKlarnaPaymentButton from './Specs/KlarnaPaymentButtonNativeComponent';
|
|
4
|
+
|
|
5
|
+
/** Visual state of the Klarna payment button. */
|
|
6
|
+
export type KlarnaPaymentButtonState =
|
|
7
|
+
/** Default interactive state. */
|
|
8
|
+
| 'default'
|
|
9
|
+
/** Button is non-interactive and visually dimmed. */
|
|
10
|
+
| 'disabled'
|
|
11
|
+
/** Button shows a loading indicator. */
|
|
12
|
+
| 'loading';
|
|
13
|
+
|
|
14
|
+
/** Intent of the Klarna payment button, determining the label and flow it initiates. */
|
|
15
|
+
export type KlarnaPaymentButtonIntent = 'pay' | 'subscribe' | 'addToWallet';
|
|
16
|
+
|
|
17
|
+
/** Shape of the Klarna payment button. */
|
|
18
|
+
export type KlarnaPaymentButtonShape =
|
|
19
|
+
/** Rectangle with rounded corners. */
|
|
20
|
+
| 'roundedRect'
|
|
21
|
+
/** Pill shaped button. */
|
|
22
|
+
| 'pill'
|
|
23
|
+
/** Rectangle with square corners. */
|
|
24
|
+
| 'rectangle';
|
|
25
|
+
|
|
26
|
+
/** Fill style of the Klarna payment button. */
|
|
27
|
+
export type KlarnaPaymentButtonStyle = 'filled' | 'outlined';
|
|
28
|
+
|
|
29
|
+
/** Color theme of the Klarna payment button. Defaults to light. */
|
|
30
|
+
export type KlarnaPaymentButtonTheme =
|
|
31
|
+
/** Light background with dark foreground content. */
|
|
32
|
+
| 'light'
|
|
33
|
+
/** Dark background with light foreground content. */
|
|
34
|
+
| 'dark'
|
|
35
|
+
/** Automatically follows the system appearance. */
|
|
36
|
+
| 'automatic';
|
|
37
|
+
|
|
38
|
+
/** Props for the KlarnaPaymentButton component. */
|
|
39
|
+
export interface KlarnaPaymentButtonProps {
|
|
40
|
+
/** The instance ID of the KlarnaNetworkPayment session this button is associated with. */
|
|
41
|
+
instanceId: string;
|
|
42
|
+
/** Visual state of the button. */
|
|
43
|
+
state?: KlarnaPaymentButtonState;
|
|
44
|
+
/** Intent determining the button label and flow. */
|
|
45
|
+
intent?: KlarnaPaymentButtonIntent;
|
|
46
|
+
/** Shape of the button. */
|
|
47
|
+
shape?: KlarnaPaymentButtonShape;
|
|
48
|
+
/** Fill style of the button. */
|
|
49
|
+
buttonStyle?: KlarnaPaymentButtonStyle;
|
|
50
|
+
/** Color theme of the button. */
|
|
51
|
+
theme?: KlarnaPaymentButtonTheme;
|
|
52
|
+
/** Called when the button is tapped. */
|
|
53
|
+
onPress?: () => void;
|
|
54
|
+
/** Style applied to the button container. */
|
|
55
|
+
style?: StyleProp<ViewStyle>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function KlarnaPaymentButton({
|
|
59
|
+
instanceId,
|
|
60
|
+
state,
|
|
61
|
+
intent,
|
|
62
|
+
shape,
|
|
63
|
+
buttonStyle,
|
|
64
|
+
theme,
|
|
65
|
+
onPress,
|
|
66
|
+
style,
|
|
67
|
+
}: KlarnaPaymentButtonProps) {
|
|
68
|
+
return (
|
|
69
|
+
<RNKlarnaPaymentButton
|
|
70
|
+
instanceId={instanceId}
|
|
71
|
+
state={state}
|
|
72
|
+
intent={intent}
|
|
73
|
+
shape={shape}
|
|
74
|
+
buttonStyle={buttonStyle}
|
|
75
|
+
theme={theme}
|
|
76
|
+
onButtonPress={onPress ? () => onPress() : () => {}}
|
|
77
|
+
style={style}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
}
|