react-native-hyperpay-sdk 0.11.0 → 0.14.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.
Binary file
package/README.md CHANGED
@@ -11,23 +11,25 @@ npm i react-native-hyperpay-sdk
11
11
  ## Usage
12
12
 
13
13
  ```js
14
- import { setConfig } from "react-native-hyperpay-sdk";
14
+ import hyperPay from 'react-native-hyperpay-sdk'
15
+
15
16
 
16
17
  // the firt step , set default configiration
17
18
  // 1- shopperResultURL to redirect to this url after the payment completed
18
19
  // 2- select your country code from list
19
20
  // 3- merchantIdentifier is for apply pay only
20
- setConfig({
21
+ hyperPay.setConfig({
21
22
  shopperResultURL:"shopperResultURL",
22
23
  countryCode:"SA",
23
- merchantIdentifier:"merchantIdentifier"
24
+ merchantIdentifier:"merchantIdentifier",
25
+ mode:"TestMode"
24
26
  })
25
27
  // ...
26
28
  // to pay with apple
27
- const result = await applePay("CheckoutId")
29
+ const result = await hyperPay.applePay("CheckoutId")
28
30
 
29
31
  // to pay with any brand
30
- const result=await createPaymentTransaction(
32
+ const result=await hyperPay.createPaymentTransaction(
31
33
  { paymentBrand: "VISA",
32
34
  holderName: "Test Test",
33
35
  cardNumber: '4111111111111111',
@@ -37,8 +39,21 @@ const result = await applePay("CheckoutId")
37
39
  checkoutID: `${res.data?.checkout_id}`,
38
40
  shopperResultURL: "[YOUR_APP_IDENTIFIER]://[URL_SCHEMES]"
39
41
  })
42
+
43
+
44
+ // get payment status
45
+ const result=await hyperPay.getPaymentStatus("000.000.000")
46
+ // result={
47
+ // "code": "000.000.000",
48
+ // "description": "Transaction succeeded",
49
+ // "status": "successfully"
50
+ // }
51
+ ```
52
+
40
53
  ```
41
54
 
55
+
56
+
42
57
  ## Contributing
43
58
 
44
59
  See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
package/ios/HyperPay.m CHANGED
@@ -9,19 +9,16 @@ OPPPaymentProvider *provider;
9
9
  NSString *shopperResultURL = @"";
10
10
  NSString *merchantIdentifier = @"";
11
11
  NSString *countryCode = @"";
12
- NSString *mode=@"Test";
12
+ NSString *mode=@"TestMode";
13
13
 
14
14
  RCT_EXPORT_MODULE(HyperPay)
15
15
 
16
16
  -(instancetype)init
17
17
  {
18
18
 
19
-
20
-
21
19
  self = [super init];
22
20
  if (self) {
23
- // #ifdef DEBUG
24
- if ([mode isEqual:@"Test"])
21
+ if ([mode isEqual:@"TestMode"])
25
22
  provider = [OPPPaymentProvider paymentProviderWithMode:OPPProviderModeTest];
26
23
  else
27
24
  provider = [OPPPaymentProvider paymentProviderWithMode:OPPProviderModeLive];
@@ -0,0 +1,39 @@
1
+
2
+
3
+ export type PaymentStatusType =
4
+ {
5
+ code: string,
6
+ description: string,
7
+ status: string
8
+ }
9
+
10
+
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
+
@@ -12,17 +12,17 @@ export type CreateTransactionResponseType = {
12
12
 
13
13
  export type ConfigType = {
14
14
  shopperResultURL: string
15
- /**
16
- * required for apple pay
17
- */
15
+ /**
16
+ * required for apple pay
17
+ */
18
18
  countryCode?: keyof CountryCodes
19
19
  /**
20
20
  * required for apple pay
21
21
  */
22
22
  merchantIdentifier?: string
23
-
24
- mode:"Test"|"Live"
25
-
23
+
24
+ mode?: "TestMode" | "LiveMode"
25
+
26
26
  }
27
27
 
28
28
  export type CreateTransactionParams = {
@@ -33,15 +33,13 @@ export type CreateTransactionParams = {
33
33
  expiryMonth: string,
34
34
  cvv: string,
35
35
  checkoutID: string,
36
- shopperResultURL: string
36
+ shopperResultURL?: string
37
37
  }
38
38
 
39
39
  export declare function
40
40
  createPaymentTransaction(params: CreateTransactionParams):
41
41
  Promise<CreateTransactionResponseType>;
42
42
 
43
-
44
43
  export declare function setConfig(params: ConfigType): ConfigType
45
44
 
46
45
  export declare function applePay(checkoutID: string): Promise<any>;
47
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-hyperpay-sdk",
3
- "version": "0.11.0",
3
+ "version": "0.14.0",
4
4
  "description": "hyperpay",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -14,7 +14,6 @@
14
14
  "ios",
15
15
  "cpp",
16
16
  "react-native-hyperpay-sdk.podspec",
17
- "OPPWAMobile-Resources.bundle",
18
17
  "OPPWAMobile.framework",
19
18
  "!lib/typescript/example",
20
19
  "!android/build",
package/src/index.tsx CHANGED
@@ -1,5 +1,17 @@
1
- import { NativeModules, Platform } from 'react-native';
2
- import type { CreateTransactionResponseType, CreateTransactionParams, ConfigType } from '../lib/typescript'
1
+ import {
2
+ NativeModules,
3
+ Platform
4
+ } from 'react-native';
5
+ import type {
6
+ CreateTransactionResponseType,
7
+ CreateTransactionParams,
8
+ ConfigType
9
+ } from '../lib/typescript'
10
+ import {
11
+ getPaymentStatus
12
+ } from './paymentStatus'
13
+
14
+
3
15
  const LINKING_ERROR =
4
16
  `The package 'react-native-hyperpay-sdk' doesn't seem to be linked. Make sure: \n\n` +
5
17
  Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
@@ -18,7 +30,8 @@ const HyperPay = NativeModules.HyperPay
18
30
  );
19
31
 
20
32
 
21
- export function createPaymentTransaction(params: CreateTransactionParams): Promise<CreateTransactionResponseType> {
33
+ export function createPaymentTransaction(params: CreateTransactionParams):
34
+ Promise<CreateTransactionResponseType> {
22
35
  return HyperPay.createPaymentTransaction(params);
23
36
  }
24
37
 
@@ -26,7 +39,14 @@ export function setConfig(params: ConfigType): ConfigType {
26
39
  return HyperPay.setConfig(params);
27
40
  }
28
41
 
29
-
30
42
  export function applePay(checkoutID: string): Promise<any> {
31
43
  return HyperPay.applePay(checkoutID);
32
44
  }
45
+
46
+ const hyperpay = {
47
+ applePay,
48
+ setConfig,
49
+ createPaymentTransaction,
50
+ getPaymentStatus
51
+ }
52
+ export default hyperpay
@@ -0,0 +1,37 @@
1
+ import type {
2
+ PaymentStatusesGroups
3
+ } from "../../lib/typescript/PaymentStatus"
4
+
5
+ export const groups: {
6
+ group: PaymentStatusesGroups,
7
+ reg: RegExp,
8
+ status: "successfully" | "rejected" | "Chargeback" | "pending"
9
+ }[] =
10
+ [
11
+ { group: "successfully", reg: /^(000\.000\.|000\.100\.1|000\.[36])/, status: "successfully" },
12
+ { group: "manuallyReviewed", reg: /^(000\.400\.0[^3]|000\.400\.[0-1]{2}0)/, status: "successfully" },
13
+ { group: "pending", reg: /^(000\.200)/, status: "pending" },
14
+ { group: "pending", reg: /^(800\.400\.5|100\.400\.500)/, status: "pending" },
15
+ { group: "rejection3DsecureAndIntercardRiskChecks", reg: /^(000\.400\.[1][0-9][1-9]|000\.400\.2)/, status: "rejected" },
16
+ { group: "rejectionsByTheExternalBank", reg: /^(800\.[17]00|800\.800\.[123])/, status: "rejected" },
17
+ { group: "rejectionsDueToCommunicationErrors", reg: /^(900\.[1234]00|000\.400\.030)/, status: "rejected" },
18
+ { group: "rejectionsDueToSystemErrors", reg: /^(800\.[56]|999\.|600\.1|800\.800\.[84])/, status: "rejected" },
19
+ { group: "rejectionsDueToErrorInAsynchonousWorkflow", reg: /^(100\.39[765])/, status: "rejected" },
20
+ { group: "softDeclines", reg: /^(300\.100\.100)/, status: "rejected" },
21
+ { group: "rejectionsDueToChecksByExternalRiskSystems", reg: /^(100\.400\.[0-3]|100\.38|100\.370\.100|100\.370\.11)/, status: "rejected" },
22
+ { group: "rejectionsDueToAddressValidation", reg: /^(800\.400\.1)/, status: "rejected" },
23
+ { group: "rejectionsDueTo3Dsecure", reg: /^(800\.400\.2|100\.380\.4|100\.390)/, status: "rejected" },
24
+ { group: "rejectionsDueToBlacklistValidation", reg: /^(100\.100\.701|800\.[32])/, status: "rejected" },
25
+ { group: "rejectionsDueToRiskValidation", reg: /^(800\.1[123456]0)/, status: "rejected" },
26
+ { group: "rejectionsDueToConfigurationValidation", reg: /^(600\.[23]|500\.[12]|800\.121)/, status: "rejected" },
27
+ { group: "rejectionsDueToRegistrationValidation", reg: /^(100\.[13]50)/, status: "rejected" },
28
+ { group: "rejectionsDueToJobValidation", reg: /^(100\.250|100\.360)/, status: "rejected" },
29
+ { group: "rejectionsDueToReferenceValidation", reg: /^(700\.[1345][05]0)/, status: "rejected" },
30
+ { group: "rejectionsDueToFormatValidation", reg: /^(200\.[123]|100\.[53][07]|800\.900|100\.[69]00\.500)/, status: "rejected" },
31
+ { group: "rejectionsDueToAddressValidation", reg: /^(100\.800)/, status: "rejected" },
32
+ { group: "rejectionsDueToContactValidation", reg: /^(100\.[97]00)/, status: "rejected" },
33
+ { group: "rejectionsDueToAccountValidation", reg: /^(100\.100|100.2[01])/, status: "rejected" },
34
+ { group: "rejectionsDueToAmountValidation", reg: /^(100\.55)/, status: "rejected" },
35
+ { group: "rejectionsDueToRiskManagement", reg: /^(100\.380\.[23]|100\.380\.101)/, status: "rejected" },
36
+ { group: "chargebackRelatedResultCodes", reg: /^(000\.100\.2)/, status: "Chargeback" },
37
+ ]
@@ -0,0 +1,21 @@
1
+ import {
2
+ groups
3
+ } from './groups';
4
+ import type {
5
+ PaymentStatusType,
6
+ } from '../../lib/typescript/PaymentStatus'
7
+ import {
8
+ PaymentStatus
9
+ } from './paymentStatus'
10
+
11
+ export const getPaymentStatus = (code: string): PaymentStatusType => {
12
+ const selectedGroup = groups.find((group) => group.reg.test(code))
13
+ if (selectedGroup)
14
+ return PaymentStatus[selectedGroup.group][code]
15
+ else
16
+ return {
17
+ code,
18
+ description: "This status code is invalid",
19
+ status: "error"
20
+ }
21
+ }