react-native-hyperpay-sdk 0.21.0 → 0.23.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/ios/HyperPay.m CHANGED
@@ -10,7 +10,7 @@ NSString *shopperResultURL = @"";
10
10
  NSString *merchantIdentifier = @"";
11
11
  NSString *countryCode = @"";
12
12
  NSString *mode=@"TestMode";
13
-
13
+ NSArray *supportedNetworks;
14
14
  RCT_EXPORT_MODULE(HyperPay)
15
15
 
16
16
  -(instancetype)init
@@ -32,12 +32,14 @@ RCT_EXPORT_MODULE(HyperPay)
32
32
  */
33
33
 
34
34
 
35
- RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(setConfig: (NSDictionary*)options) {
35
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(setup: (NSDictionary*)options) {
36
36
  shopperResultURL=[options valueForKey:@"shopperResultURL"];
37
37
  if ([options valueForKey:@"merchantIdentifier"])
38
38
  merchantIdentifier=[options valueForKey:@"merchantIdentifier"];
39
39
  if ([options valueForKey:@"countryCode"])
40
40
  countryCode=[options valueForKey:@"countryCode"];
41
+ if ([options valueForKey:@"supportedNetworks"])
42
+ supportedNetworks=[options valueForKey:@"supportedNetworks"];
41
43
  if ([[options valueForKey:@"mode"] isEqual:@"LiveMode"])
42
44
  provider = [OPPPaymentProvider paymentProviderWithMode:OPPProviderModeLive];
43
45
  else
@@ -96,10 +98,9 @@ RCT_EXPORT_METHOD(createPaymentTransaction: (NSDictionary*)options resolver:(RCT
96
98
 
97
99
  RCT_EXPORT_METHOD(applePay:(NSString*)checkoutID resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){
98
100
 
99
- OPPPaymentProvider *provider = [OPPPaymentProvider paymentProviderWithMode:OPPProviderModeTest];
100
101
  OPPCheckoutSettings *checkoutSettings = [[OPPCheckoutSettings alloc] init];
101
102
  PKPaymentRequest *paymentRequest = [OPPPaymentProvider paymentRequestWithMerchantIdentifier:merchantIdentifier countryCode:countryCode];
102
- paymentRequest.supportedNetworks = @ [PKPaymentNetworkMada,PKPaymentNetworkVisa,PKPaymentNetworkMasterCard];
103
+ paymentRequest.supportedNetworks = supportedNetworks;
103
104
  checkoutSettings.shopperResultURL=shopperResultURL;
104
105
  checkoutSettings.applePayPaymentRequest = paymentRequest;
105
106
  OPPCheckoutProvider *checkoutProvider = [OPPCheckoutProvider checkoutProviderWithPaymentProvider:provider
@@ -116,16 +117,7 @@ RCT_EXPORT_METHOD(applePay:(NSString*)checkoutID resolver:(RCTPromiseResolveBloc
116
117
  // reject(@"applePay",checkoutID,error);
117
118
  reject(@"applePay",error.localizedDescription, error);
118
119
  // See code attribute (OPPErrorCode) and NSLocalizedDescription to identify the reason of failure.
119
- } else {
120
- if (transaction.redirectURL) {
121
- resolve(transaction.redirectURL);
122
- // Shopper was redirected to the issuer web page.
123
- // Request payment status when shopper returns to the app using transaction.resourcePath or just checkout id.
124
- } else {
125
- resolve(transaction.resourcePath);
126
- // Request payment status for the synchronous transaction from your server using transactionPath.resourcePath or just checkout id.
127
- }
128
- }
120
+ } else {resolve(transaction); }
129
121
  } cancelHandler:^{
130
122
  reject(@"applePay",@"Executed if the shopper closes the payment page prematurely.",NULL);
131
123
  // Executed if the shopper closes the payment page prematurely.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.multiply = multiply;
6
+ exports.HyperPay = { init, createPaymentTransaction, applePay };
7
7
 
8
8
  var _reactNative = require("react-native");
9
9
 
@@ -11,14 +11,21 @@ const LINKING_ERROR = `The package 'react-native-hyperpay-sdk' doesn't seem to b
11
11
  ios: "- You have run 'pod install'\n",
12
12
  default: ''
13
13
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
14
- const HyperpaySdk = _reactNative.NativeModules.HyperpaySdk ? _reactNative.NativeModules.HyperpaySdk : new Proxy({}, {
14
+ const HyperPaySDK = _reactNative.NativeModules.HyperpaySdk ? _reactNative.NativeModules.HyperpaySdk : new Proxy({}, {
15
15
  get() {
16
16
  throw new Error(LINKING_ERROR);
17
17
  }
18
18
 
19
19
  });
20
20
 
21
- function multiply(a, b) {
22
- return HyperpaySdk.multiply(a, b);
21
+ function init(params) {
22
+ return HyperPaySDK.setup(params);
23
23
  }
24
- //# sourceMappingURL=index.js.map
24
+
25
+ function createPaymentTransaction(params) {
26
+ return HyperPaySDK.createPaymentTransaction(params);
27
+ }
28
+
29
+ function applePay(checkoutID) {
30
+ return HyperPaySDK.applePay(checkoutID)
31
+ }
@@ -1,15 +1,39 @@
1
1
  import { NativeModules, Platform } from 'react-native';
2
- const LINKING_ERROR = `The package 'react-native-hyperpay-sdk' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
- ios: "- You have run 'pod install'\n",
4
- default: ''
5
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
6
- const HyperpaySdk = NativeModules.HyperpaySdk ? NativeModules.HyperpaySdk : new Proxy({}, {
7
- get() {
8
- throw new Error(LINKING_ERROR);
9
- }
10
-
11
- });
12
- export function multiply(a, b) {
13
- return HyperpaySdk.multiply(a, b);
14
- }
15
- //# sourceMappingURL=index.js.map
2
+ import { getPaymentStatus } from './paymentStatus'
3
+
4
+ const LINKING_ERROR =
5
+ `The package 'react-native-hyperpay-sdk' doesn't seem to be linked. Make sure: \n\n` +
6
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
7
+ '- You rebuilt the app after installing the package\n' +
8
+ '- You are not using Expo managed workflow\n';
9
+
10
+ const HyperPaySDK = NativeModules.HyperPay
11
+ ? NativeModules.HyperPay
12
+ : new Proxy(
13
+ {},
14
+ {
15
+ get() {
16
+ throw new Error(LINKING_ERROR);
17
+ },
18
+ }
19
+ );
20
+ export function init(params) {
21
+ return HyperPaySDK.setup(params);
22
+ }
23
+
24
+ export function createPaymentTransaction(params) {
25
+ return HyperPaySDK.createPaymentTransaction(params);
26
+ }
27
+
28
+ export function applePay(checkoutID) {
29
+ return HyperPaySDK.applePay(checkoutID);
30
+ }
31
+
32
+ const Hyperpay = {
33
+ init,
34
+ applePay,
35
+ createPaymentTransaction,
36
+ getPaymentStatus
37
+ }
38
+
39
+ export default Hyperpay
@@ -1,39 +1,35 @@
1
1
 
2
2
 
3
- export type PaymentStatusType =
4
- {
5
- code: string,
6
- description: string,
7
- status: string
8
- }
3
+ export type PaymentStatus = {
4
+ code: string,
5
+ description: string,
6
+ status: 'successfully' | 'rejected' | 'Chargeback' | 'pending' | 'error'
7
+ }
9
8
 
9
+ export type PaymentStatusesGroups = 'successfully' |
10
+ 'manuallyReviewed' |
11
+ 'pending' |
12
+ 'rejection3DsecureAndIntercardRiskChecks' |
13
+ 'rejectionsByTheExternalBank' |
14
+ 'rejectionsDueToCommunicationErrors' |
15
+ 'rejectionsDueToSystemErrors' |
16
+ 'rejectionsDueToErrorInAsynchonousWorkflow' |
17
+ 'softDeclines' |
18
+ 'rejectionsDueToChecksByExternalRiskSystems' |
19
+ 'rejectionsDueToAddressValidation' |
20
+ 'rejectionsDueTo3Dsecure' |
21
+ 'rejectionsDueToBlacklistValidation' |
22
+ 'rejectionsDueToRiskValidation' |
23
+ 'rejectionsDueToConfigurationValidation' |
24
+ 'rejectionsDueToRegistrationValidation' |
25
+ 'rejectionsDueToJobValidation' |
26
+ 'rejectionsDueToReferenceValidation' |
27
+ 'rejectionsDueToFormatValidation' |
28
+ 'rejectionsDueToAddressValidation' |
29
+ 'rejectionsDueToContactValidation' |
30
+ 'rejectionsDueToAccountValidation' |
31
+ 'rejectionsDueToAmountValidation' |
32
+ 'rejectionsDueToRiskManagement' |
33
+ 'chargebackRelatedResultCodes'
10
34
 
11
- export type PaymentStatusesGroups =
12
- "successfully" |
13
- "manuallyReviewed" |
14
- "pending" |
15
- "rejection3DsecureAndIntercardRiskChecks" |
16
- "rejectionsByTheExternalBank" |
17
- "rejectionsDueToCommunicationErrors" |
18
- "rejectionsDueToSystemErrors" |
19
- "rejectionsDueToErrorInAsynchonousWorkflow" |
20
- "softDeclines" |
21
- "rejectionsDueToChecksByExternalRiskSystems" |
22
- "rejectionsDueToAddressValidation" |
23
- "rejectionsDueTo3Dsecure" |
24
- "rejectionsDueToBlacklistValidation" |
25
- "rejectionsDueToRiskValidation" |
26
- "rejectionsDueToConfigurationValidation" |
27
- "rejectionsDueToRegistrationValidation" |
28
- "rejectionsDueToJobValidation" |
29
- "rejectionsDueToReferenceValidation" |
30
- "rejectionsDueToFormatValidation" |
31
- "rejectionsDueToAddressValidation" |
32
- "rejectionsDueToContactValidation" |
33
- "rejectionsDueToAccountValidation" |
34
- "rejectionsDueToAmountValidation" |
35
- "rejectionsDueToRiskManagement" |
36
- "chargebackRelatedResultCodes"
37
-
38
- export declare function getPaymentStatus(status: string): PaymentStatusType
39
35
 
@@ -0,0 +1,29 @@
1
+
2
+ export type SupportedNetworks =
3
+ "mada" |
4
+ "Visa" |
5
+ "JCB" |
6
+ "Elo" |
7
+ "Mir" |
8
+ "Suica" |
9
+ "MasterCard" |
10
+ "iD" |
11
+ "CarteBancaires" |
12
+ "ChinaUnionPay" |
13
+ "AmEx" |
14
+ "WAON" |
15
+ "VPay" |
16
+ "Eftpos" |
17
+ "nanaco" |
18
+ "Barcode" |
19
+ "Dankort" |
20
+ "Interac" |
21
+ "Maestro" |
22
+ "Discover" |
23
+ "Electron" |
24
+ "girocard" |
25
+ "QUICPay" |
26
+ "PrivateLabel" |
27
+ "CartesBancaires" |
28
+ "CarteBancaire"
29
+
@@ -1,27 +1,29 @@
1
- import type {
2
- CountryCodes
3
- } from "./countryisCodes"
4
-
5
-
1
+ import type { CountryCodes } from './CountryCodes';
2
+ import { PaymentStatus } from './PaymentStatus';
3
+ import type { SupportedNetworks } from './SupportedNetworks';
6
4
  export type CreateTransactionResponseType = {
7
- status: 'pending',
5
+ status: 'pending' | 'rejected' | 'risk' | 'chargeback' | 'declines' | 'successfully',
8
6
  checkoutId: string,
9
7
  redirectURL: string
10
8
  }
11
-
12
-
13
- export type ConfigType = {
14
- shopperResultURL: string
9
+ export interface Config {
10
+ shopperResultURL: string;
15
11
  /**
16
12
  * required for apple pay
17
13
  */
18
- countryCode?: keyof CountryCodes
14
+ countryCode?: keyof CountryCodes;
19
15
  /**
20
16
  * required for apple pay
21
17
  */
22
- merchantIdentifier?: string
18
+ merchantIdentifier?: string;
23
19
 
24
- mode?: "TestMode" | "LiveMode"
20
+ mode?: "TestMode" | "LiveMode";
21
+
22
+ /**
23
+ * set up supported payment networks for apple pay
24
+ * @Platform IOS Only
25
+ */
26
+ supportedNetworks?: Array<SupportedNetworks>
25
27
 
26
28
  }
27
29
 
@@ -33,13 +35,59 @@ export type CreateTransactionParams = {
33
35
  expiryMonth: string,
34
36
  cvv: string,
35
37
  checkoutID: string,
36
- shopperResultURL?: string
38
+ shopperResultURL?: string,
39
+ }
40
+ export type ApplePayCallback = {
41
+ /** Shopper was redirected to the issuer web page.
42
+ Request payment status when shopper returns to the app using transaction.resourcePath or just checkout id.
43
+ */
44
+ redirectURL?: string;
45
+ /** Request payment status for the synchronous transaction from your server using transactionPath.resourcePath or just checkout id.*/
46
+ resourcePath?: string;
37
47
  }
48
+ export default class HyperPay {
49
+ /**
50
+ * @param {string} shopperResultURL
51
+ * @param {CountryCodes} countryCode
52
+ * @param {string} merchantIdentifier
53
+ * @param {string} mode
54
+ * @param {SupportedNetworks[]} supportedNetworks
55
+ * @returns Config
56
+ */
38
57
 
39
- export declare function
40
- createPaymentTransaction(params: CreateTransactionParams):
41
- Promise<CreateTransactionResponseType>;
58
+ static init(params: Config): Config
42
59
 
43
- export declare function setConfig(params: ConfigType): ConfigType
60
+ /**
61
+ * @param {string} checkoutID
62
+ * @returns ```Promise<{ redirectURL?: string,
63
+ resourcePath?: string}>```
64
+ */
65
+ static applePay(checkoutID: string): Promise<ApplePayCallback>;
66
+
67
+ /**
68
+ * @param {string} paymentBrand
69
+ * @param {string} holderName
70
+ * @param {string} cardNumber
71
+ * @param {string} expiryYear
72
+ * @param {string} expiryMonth
73
+ * @param {string} cvv
74
+ * @param {string} checkoutID
75
+ * @param {string} shopperResultURL
76
+ *
77
+ * @returns ```Promise<{ status: 'pending' | 'rejected' | 'risk' | 'chargeback' | 'declines' | 'successfully',
78
+ checkoutId: string,
79
+ redirectURL: string }>```
80
+ */
81
+
82
+ static createPaymentTransaction(params: CreateTransactionParams): Promise<CreateTransactionResponseType>;
83
+
84
+ /**
85
+ * @param {string} statusCode
86
+ * @returns```{ code: string, description: string, status: 'successfully' |
87
+ * 'rejected' | 'Chargeback' | 'pending' | 'error' }```
88
+ */
89
+
90
+ static getPaymentStatus(status: string): PaymentStatus
91
+
92
+ }
44
93
 
45
- export declare function applePay(checkoutID: string): Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-hyperpay-sdk",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "hyperpay",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/index.tsx CHANGED
@@ -5,20 +5,19 @@ import {
5
5
  import type {
6
6
  CreateTransactionResponseType,
7
7
  CreateTransactionParams,
8
- ConfigType
8
+ Config,
9
9
  } from '../lib/typescript'
10
10
  import {
11
11
  getPaymentStatus
12
12
  } from './paymentStatus'
13
-
14
-
13
+ import type { ApplePayCallback } from '../'
15
14
  const LINKING_ERROR =
16
15
  `The package 'react-native-hyperpay-sdk' doesn't seem to be linked. Make sure: \n\n` +
17
16
  Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
18
17
  '- You rebuilt the app after installing the package\n' +
19
18
  '- You are not using Expo managed workflow\n';
20
19
 
21
- const HyperPay = NativeModules.HyperPay
20
+ const HyperPaySDK = NativeModules.HyperPay
22
21
  ? NativeModules.HyperPay
23
22
  : new Proxy(
24
23
  {},
@@ -28,25 +27,26 @@ const HyperPay = NativeModules.HyperPay
28
27
  },
29
28
  }
30
29
  );
31
-
30
+ export function init(params: Config): Config {
31
+ return HyperPaySDK.setup(params);
32
+ }
32
33
 
33
34
  export function createPaymentTransaction(params: CreateTransactionParams):
34
35
  Promise<CreateTransactionResponseType> {
35
- return HyperPay.createPaymentTransaction(params);
36
+ return HyperPaySDK.createPaymentTransaction(params);
36
37
  }
37
38
 
38
- export function setConfig(params: ConfigType): ConfigType {
39
- return HyperPay.setConfig(params);
40
- }
41
39
 
42
- export function applePay(checkoutID: string): Promise<any> {
43
- return HyperPay.applePay(checkoutID);
40
+ export function applePay(checkoutID: string): Promise<ApplePayCallback> {
41
+ return HyperPaySDK.applePay(checkoutID);
44
42
  }
45
43
 
46
- const hyperpay = {
44
+ const Hyperpay = {
45
+ init,
47
46
  applePay,
48
- setConfig,
49
47
  createPaymentTransaction,
50
48
  getPaymentStatus
51
49
  }
52
- export default hyperpay
50
+
51
+
52
+ export default Hyperpay