payjp-react-native 0.6.3 → 0.8.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.
Files changed (58) hide show
  1. package/android/build.gradle +4 -11
  2. package/android/src/main/java/jp/pay/reactnative/PayjpCardFormModule.kt +24 -1
  3. package/ios/Classes/RNPAY.m +1 -1
  4. package/ios/Classes/RNPAYCardForm.m +22 -3
  5. package/lib/{src/ApplePay.d.ts → ApplePay.d.ts} +6 -6
  6. package/lib/{src/ApplePay.js → ApplePay.js} +22 -32
  7. package/lib/{src/CardForm.d.ts → CardForm.d.ts} +34 -9
  8. package/lib/{src/CardForm.js → CardForm.js} +26 -36
  9. package/lib/{src/Core.d.ts → Core.d.ts} +1 -1
  10. package/lib/Core.js +18 -0
  11. package/lib/index.d.ts +5 -0
  12. package/lib/index.js +6 -0
  13. package/lib/{src/models → models}/Card.d.ts +13 -1
  14. package/lib/models/Card.js +86 -0
  15. package/lib/{src/models → models}/CardBrand.d.ts +10 -9
  16. package/lib/models/CardBrand.js +44 -0
  17. package/lib/{src/models → models}/ErrorResponse.js +5 -12
  18. package/lib/{src/models → models}/ModelError.js +7 -14
  19. package/lib/{src/models → models}/Token.d.ts +1 -1
  20. package/lib/{src/models → models}/Token.js +12 -19
  21. package/lib/models/index.d.ts +5 -0
  22. package/lib/models/index.js +6 -0
  23. package/package.json +31 -54
  24. package/payjp-react-native.podspec +3 -1
  25. package/sdkconfig.json +3 -3
  26. package/src/ApplePay.ts +8 -8
  27. package/src/CardForm.ts +40 -10
  28. package/src/Core.ts +1 -1
  29. package/src/index.ts +4 -4
  30. package/src/models/Card.ts +37 -21
  31. package/src/models/CardBrand.ts +19 -8
  32. package/src/models/ErrorResponse.ts +1 -1
  33. package/src/models/ModelError.ts +3 -3
  34. package/src/models/Token.ts +7 -7
  35. package/src/models/index.ts +7 -6
  36. package/lib/src/ApplePay.js.map +0 -1
  37. package/lib/src/CardForm.js.map +0 -1
  38. package/lib/src/Core.js +0 -32
  39. package/lib/src/Core.js.map +0 -1
  40. package/lib/src/index.d.ts +0 -5
  41. package/lib/src/index.js +0 -34
  42. package/lib/src/index.js.map +0 -1
  43. package/lib/src/models/Card.js +0 -89
  44. package/lib/src/models/Card.js.map +0 -1
  45. package/lib/src/models/CardBrand.js +0 -43
  46. package/lib/src/models/CardBrand.js.map +0 -1
  47. package/lib/src/models/ErrorResponse.js.map +0 -1
  48. package/lib/src/models/ModelError.js.map +0 -1
  49. package/lib/src/models/Token.js.map +0 -1
  50. package/lib/src/models/TokenForm.d.ts +0 -51
  51. package/lib/src/models/TokenForm.js +0 -58
  52. package/lib/src/models/TokenForm.js.map +0 -1
  53. package/lib/src/models/index.d.ts +0 -6
  54. package/lib/src/models/index.js +0 -19
  55. package/lib/src/models/index.js.map +0 -1
  56. package/src/models/TokenForm.ts +0 -95
  57. /package/lib/{src/models → models}/ErrorResponse.d.ts +0 -0
  58. /package/lib/{src/models → models}/ModelError.d.ts +0 -0
@@ -5,11 +5,11 @@ buildscript {
5
5
 
6
6
  repositories {
7
7
  google()
8
- jcenter()
8
+ mavenCentral()
9
9
  }
10
10
 
11
11
  dependencies {
12
- classpath 'com.android.tools.build:gradle:4.1.1'
12
+ classpath 'com.android.tools.build:gradle:4.1.3'
13
13
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
14
  }
15
15
  }
@@ -27,22 +27,15 @@ apply plugin: 'kotlin-android'
27
27
 
28
28
  android {
29
29
  compileSdkVersion rootProject.properties.get('compileSdkVersion', 29)
30
- compileOptions {
31
- sourceCompatibility 1.8
32
- targetCompatibility 1.8
33
- }
34
30
 
35
31
  defaultConfig {
36
- minSdkVersion 16
32
+ minSdkVersion rootProject.properties.get('minSdkVersion', 16)
37
33
  targetSdkVersion rootProject.properties.get('targetSdkVersion', 29)
38
34
  buildConfigField "String", "VERSION_NAME", "\"$pluginVersion\""
39
35
  }
40
36
  lintOptions {
41
37
  warning 'InvalidPackage'
42
38
  }
43
- kotlinOptions {
44
- jvmTarget = "1.8"
45
- }
46
39
  }
47
40
 
48
41
  repositories {
@@ -51,7 +44,7 @@ repositories {
51
44
  // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
52
45
  url("$rootDir/../node_modules/react-native/android")
53
46
  }
54
- jcenter()
47
+ mavenCentral()
55
48
  }
56
49
 
57
50
  dependencies {
@@ -38,6 +38,7 @@ import jp.pay.android.Payjp
38
38
  import jp.pay.android.PayjpCardForm
39
39
  import jp.pay.android.PayjpTokenBackgroundHandler
40
40
  import jp.pay.android.PayjpTokenBackgroundHandler.CardFormStatus
41
+ import jp.pay.android.model.ExtraAttribute
41
42
  import jp.pay.android.model.TenantId
42
43
  import jp.pay.android.model.Token
43
44
  import jp.pay.android.model.toJsonValue
@@ -71,16 +72,38 @@ class PayjpCardFormModule(
71
72
  @ReactMethod fun startCardForm(
72
73
  tenantIdString: String?,
73
74
  cardFormType: String?,
75
+ extraAttributeEmailEnabled: Boolean,
76
+ extraAttributePhoneEnabled: Boolean,
77
+ extraAttributeEmailPreset: String?,
78
+ extraAttributePhoneRegion: String?,
79
+ extraAttributePhoneNumber: String?,
80
+ useThreeDSecure: Boolean,
74
81
  promise: Promise
75
82
  ) {
76
83
  val face = when (cardFormType) {
77
84
  "cardDisplay" -> PayjpCardForm.FACE_CARD_DISPLAY
78
85
  else -> PayjpCardForm.FACE_MULTI_LINE
79
86
  }
87
+ val extraAttributes: Array<ExtraAttribute<*>> = listOfNotNull(
88
+ ExtraAttribute.Email(preset = extraAttributeEmailPreset)
89
+ .takeIf { extraAttributeEmailEnabled },
90
+ ExtraAttribute.Phone(
91
+ region = extraAttributePhoneRegion ?: "JP",
92
+ number = extraAttributePhoneNumber
93
+ ).takeIf { extraAttributePhoneEnabled },
94
+ ).toTypedArray()
95
+
80
96
  mainThreadHandler.post {
81
97
  reactContext.currentActivity?.let { activity ->
82
98
  val tenantId = tenantIdString?.let { TenantId(it) }
83
- Payjp.cardForm().start(activity, CODE_START_CARD_FORM, tenantId, face)
99
+ Payjp.cardForm().start(
100
+ activity = activity,
101
+ requestCode = CODE_START_CARD_FORM,
102
+ tenant = tenantId,
103
+ face = face,
104
+ extraAttributes = extraAttributes,
105
+ useThreeDSecure = useThreeDSecure,
106
+ )
84
107
  }
85
108
  promise.resolve(null)
86
109
  }
@@ -23,4 +23,4 @@
23
23
  #import "RNPAY.h"
24
24
 
25
25
  NSString *const RNPAYErrorDomain = @"RNPAYErrorDomain";
26
- NSString *const RNPAYPluginVersion = @"0.6.3";
26
+ NSString *const RNPAYPluginVersion = @"0.8.0";
@@ -47,7 +47,13 @@ RCT_EXPORT_MODULE()
47
47
 
48
48
  RCT_EXPORT_METHOD(startCardForm
49
49
  : (NSString *)tenantId cardFormType
50
- : (NSString *)cardFormType resolve
50
+ : (NSString *)cardFormType extraAttributeEmailEnabled
51
+ : (BOOL)extraAttributeEmailEnabled extraAttributePhoneEnabled
52
+ : (BOOL)extraAttributePhoneEnabled extraAttributeEmail
53
+ : (NSString *)extraAttributeEmail extraAttributePhoneRegion
54
+ : (NSString *)extraAttributePhoneRegion extraAttributePhoneNumber
55
+ : (NSString *)extraAttributePhoneNumber useThreeDSecure
56
+ : (BOOL)useThreeDSecure resolve
51
57
  : (RCTPromiseResolveBlock)resolve reject
52
58
  : (__unused RCTPromiseRejectBlock)reject) {
53
59
  NSString *description =
@@ -60,13 +66,26 @@ RCT_EXPORT_METHOD(startCardForm
60
66
  if ([cardFormType isEqual:@"cardDisplay"]) {
61
67
  viewType = CardFormViewTypeDisplayStyled;
62
68
  }
63
-
69
+ NSMutableArray<id<PAYExtraAttribute>> *extraAttributes = [NSMutableArray array];
70
+ if (extraAttributeEmailEnabled) {
71
+ PAYExtraAttributeEmail *email =
72
+ [[PAYExtraAttributeEmail alloc] initWithPreset:extraAttributeEmail];
73
+ [extraAttributes addObject:email];
74
+ }
75
+ if (extraAttributePhoneEnabled) {
76
+ PAYExtraAttributePhone *phone =
77
+ [[PAYExtraAttributePhone alloc] initWithPresetNumber:extraAttributePhoneNumber
78
+ presetRegion:extraAttributePhoneRegion];
79
+ [extraAttributes addObject:phone];
80
+ }
64
81
  dispatch_async([self methodQueue], ^{
65
82
  PAYCardFormViewController *cardForm = [PAYCardFormViewController
66
83
  createCardFormViewControllerWithStyle:wself.style ?: PAYCardFormStyle.defaultStyle
67
84
  tenantId:tenantId
68
85
  delegate:wself
69
- viewType:viewType];
86
+ viewType:viewType
87
+ extraAttributes:extraAttributes
88
+ useThreeDSecure:useThreeDSecure];
70
89
  UIViewController *hostViewController =
71
90
  UIApplication.sharedApplication.keyWindow.rootViewController;
72
91
  if ([hostViewController isKindOfClass:[UINavigationController class]]) {
@@ -1,8 +1,8 @@
1
- import { Token } from "./models";
1
+ import { Token } from './models';
2
2
  /**
3
3
  * エラー情報
4
4
  */
5
- export declare type ErrorInfo = {
5
+ export type ErrorInfo = {
6
6
  errorType: string;
7
7
  errorCode: number;
8
8
  errorMessage: string;
@@ -11,21 +11,21 @@ export declare type ErrorInfo = {
11
11
  * PAY.JPトークンが生成されたときのリスナー
12
12
  * @param token PAY.JPトークン
13
13
  */
14
- export declare type OnApplePayProducedToken = (token: Token) => void;
14
+ export type OnApplePayProducedToken = (token: Token) => void;
15
15
  /**
16
16
  * トークンのリクエストに失敗したときのリスナー
17
17
  * @param errorInfo エラー情報
18
18
  */
19
- export declare type OnApplePayFailedRequestToken = (errorInfo: ErrorInfo) => void;
19
+ export type OnApplePayFailedRequestToken = (errorInfo: ErrorInfo) => void;
20
20
  /**
21
21
  * Apple Payが完了したときのリスナー
22
22
  */
23
- export declare type OnApplePayCompleted = () => void;
23
+ export type OnApplePayCompleted = () => void;
24
24
  /**
25
25
  * Apple Payで支払いをリクエストするときに必要な情報
26
26
  * @see {@link https://developer.apple.com/documentation/passkit/pkpaymentrequest}
27
27
  */
28
- export declare type ApplePayAuthorizationOption = {
28
+ export type ApplePayAuthorizationOption = {
29
29
  /**
30
30
  * AppleのMerchantId
31
31
  * 例: `merchant.com.example.www`
@@ -1,19 +1,7 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.onApplePayUpdate = exports.completeApplePay = exports.makeApplePayToken = exports.isApplePayAvailable = void 0;
13
1
  // LICENSE : MIT
14
- const react_native_1 = require("react-native");
15
- const { RNPAYApplePay } = react_native_1.NativeModules;
16
- const applePayEventEmitter = new react_native_1.NativeEventEmitter(RNPAYApplePay);
2
+ import { NativeModules, NativeEventEmitter } from 'react-native';
3
+ const { RNPAYApplePay } = NativeModules;
4
+ const applePayEventEmitter = new NativeEventEmitter(RNPAYApplePay);
17
5
  const onApplePayProducedTokenSet = new Set();
18
6
  const onApplePayFailedRequestTokenSet = new Set();
19
7
  const onApplePayCompletedSet = new Set();
@@ -22,9 +10,9 @@ const onApplePayCompletedSet = new Set();
22
10
  *
23
11
  * cf. [canMakePayments](https://developer.apple.com/documentation/passkit/pkpaymentauthorizationviewcontroller/1616192-canmakepayments)
24
12
  */
25
- exports.isApplePayAvailable = () => __awaiter(void 0, void 0, void 0, function* () {
13
+ export const isApplePayAvailable = async () => {
26
14
  return RNPAYApplePay.isApplePayAvailable();
27
- });
15
+ };
28
16
  /**
29
17
  * Apple Payの支払い認証フローを開始します。
30
18
  * AppleのMerchant IDが必要です。
@@ -33,10 +21,13 @@ exports.isApplePayAvailable = () => __awaiter(void 0, void 0, void 0, function*
33
21
  *
34
22
  * @param option Apple PayのPaymentRequestに必要な情報
35
23
  */
36
- exports.makeApplePayToken = (option) => __awaiter(void 0, void 0, void 0, function* () {
37
- const filledOption = Object.assign(Object.assign({}, option), { requiredBillingAddress: option.requiredBillingAddress || false });
38
- yield RNPAYApplePay.makeApplePayToken(filledOption);
39
- });
24
+ export const makeApplePayToken = async (option) => {
25
+ const filledOption = {
26
+ ...option,
27
+ requiredBillingAddress: option.requiredBillingAddress || false,
28
+ };
29
+ await RNPAYApplePay.makeApplePayToken(filledOption);
30
+ };
40
31
  /**
41
32
  * Apple Payによる支払いの成功可否を伝え、支払いフローを完了させます。
42
33
  * `isSuccess` がtrueの場合は成功の、falseの場合はエラーのUIを表示します。
@@ -44,9 +35,9 @@ exports.makeApplePayToken = (option) => __awaiter(void 0, void 0, void 0, functi
44
35
  * @param isSuccess Apple Payによるオーソリゼーションに成功したか(trueなら成功)
45
36
  * @param errorMessage エラーメッセージ
46
37
  */
47
- exports.completeApplePay = (isSuccess, errorMessage = null) => __awaiter(void 0, void 0, void 0, function* () {
48
- yield RNPAYApplePay.completeApplePay(isSuccess, errorMessage);
49
- });
38
+ export const completeApplePay = async (isSuccess, errorMessage = null) => {
39
+ await RNPAYApplePay.completeApplePay(isSuccess, errorMessage);
40
+ };
50
41
  /**
51
42
  * Apple Payの支払いフローの更新を受け取ります。
52
43
  * 登録したリスナーを解除するには、返却される関数を実行します。
@@ -54,7 +45,7 @@ exports.completeApplePay = (isSuccess, errorMessage = null) => __awaiter(void 0,
54
45
  * @param observer Apple Payによる支払いフローの更新を受け取るリスナー
55
46
  * @returns unsubscribe function リスナーを解除する関数
56
47
  */
57
- exports.onApplePayUpdate = (observer) => {
48
+ export const onApplePayUpdate = (observer) => {
58
49
  const { onApplePayProducedToken, onApplePayFailedRequestToken, onApplePayCompleted } = observer;
59
50
  const disconnect = connectApplePayEvent();
60
51
  onApplePayProducedToken && onApplePayProducedTokenSet.add(onApplePayProducedToken);
@@ -68,14 +59,14 @@ exports.onApplePayUpdate = (observer) => {
68
59
  };
69
60
  };
70
61
  const connectApplePayEvent = () => {
71
- const onApplePayProducedToken = applePayEventEmitter.addListener("onApplePayProducedToken", (token) => {
72
- onApplePayProducedTokenSet.forEach((observer) => observer(token));
62
+ const onApplePayProducedToken = applePayEventEmitter.addListener('onApplePayProducedToken', token => {
63
+ onApplePayProducedTokenSet.forEach(observer => observer(token));
73
64
  });
74
- const onApplePayFailedRequestToken = applePayEventEmitter.addListener("onApplePayFailedRequestToken", (error) => {
75
- onApplePayFailedRequestTokenSet.forEach((observer) => observer(error));
65
+ const onApplePayFailedRequestToken = applePayEventEmitter.addListener('onApplePayFailedRequestToken', error => {
66
+ onApplePayFailedRequestTokenSet.forEach(observer => observer(error));
76
67
  });
77
- const onApplePayCompleted = applePayEventEmitter.addListener("onApplePayCompleted", () => {
78
- onApplePayCompletedSet.forEach((observer) => observer());
68
+ const onApplePayCompleted = applePayEventEmitter.addListener('onApplePayCompleted', () => {
69
+ onApplePayCompletedSet.forEach(observer => observer());
79
70
  });
80
71
  return () => {
81
72
  onApplePayProducedToken.remove();
@@ -83,4 +74,3 @@ const connectApplePayEvent = () => {
83
74
  onApplePayCompleted.remove();
84
75
  };
85
76
  };
86
- //# sourceMappingURL=ApplePay.js.map
@@ -1,23 +1,23 @@
1
- import { ColorValue } from "react-native";
2
- import { Token } from "./models";
1
+ import { ColorValue } from 'react-native';
2
+ import { Token } from './models';
3
3
  /**
4
4
  * カードフォームがキャンセルされたときに実行されるリスナー
5
5
  */
6
- export declare type OnCardFormCanceled = () => void;
6
+ export type OnCardFormCanceled = () => void;
7
7
  /**
8
8
  * カードフォームが完了したときに実行されるリスナー
9
9
  */
10
- export declare type OnCardFormCompleted = () => void;
10
+ export type OnCardFormCompleted = () => void;
11
11
  /**
12
12
  * カードフォームでトークンが生成されたときに実行されるリスナー
13
13
  *
14
14
  * @param token PAY.JPトークン
15
15
  */
16
- export declare type OnCardFormProducedToken = (token: Token) => void;
16
+ export type OnCardFormProducedToken = (token: Token) => void;
17
17
  /**
18
18
  * カードフォームスタイル(iOS用)
19
19
  */
20
- export declare type IOSCardFormStyle = {
20
+ export type IOSCardFormStyle = {
21
21
  labelTextColor?: ColorValue;
22
22
  inputTextColor?: ColorValue;
23
23
  errorTextColor?: ColorValue;
@@ -29,11 +29,24 @@ export declare type IOSCardFormStyle = {
29
29
  /**
30
30
  * カードフォームの表示タイプ
31
31
  */
32
- export declare type CardFormType = "multiLine" | "cardDisplay";
32
+ export type CardFormType = 'multiLine' | 'cardDisplay';
33
+ type ExtraAttributeEmail = {
34
+ type: 'email';
35
+ preset?: string;
36
+ };
37
+ type ExtraAttributePhone = {
38
+ type: 'phone';
39
+ presetRegion?: string;
40
+ presetNumber?: string;
41
+ };
42
+ /**
43
+ * カードフォームの追加属性
44
+ */
45
+ export type ExtraAttribute = ExtraAttributeEmail | ExtraAttributePhone;
33
46
  /**
34
47
  * カードフォームのオプション
35
48
  */
36
- declare type CardFormOption = {
49
+ type CardFormOption = {
37
50
  /**
38
51
  * PAY.JP Platform Marketplace 利用の場合のみ必要です (cf. {@link https://pay.jp/docs/platform-tenant-checkout} ).
39
52
  */
@@ -42,6 +55,18 @@ declare type CardFormOption = {
42
55
  * カードフォームの表示タイプ(デフォルトはmultiLine)
43
56
  */
44
57
  cardFormType?: CardFormType;
58
+ /**
59
+ * カードフォームに追加の属性項目を設定できます。デフォルトはメールアドレスと電話番号が表示されます。
60
+ * 入力した内容はカードオブジェクトにセットされ、 3Dセキュア認証実施時に送信されます。
61
+ *
62
+ * 3Dセキュア認証実施時の連携項目追加については以下のドキュメントを参照してください。
63
+ * https://help.pay.jp/ja/articles/9556161
64
+ */
65
+ extraAttributes?: ExtraAttribute[];
66
+ /**
67
+ * 3-D セキュア認証の実施可否を設定します。デフォルトはfalseです。
68
+ */
69
+ useThreeDSecure?: boolean;
45
70
  };
46
71
  /**
47
72
  * カードフォームを開始します。
@@ -49,7 +74,7 @@ declare type CardFormOption = {
49
74
  *
50
75
  * @param options カードフォームのオプション
51
76
  */
52
- export declare const startCardForm: (options?: CardFormOption | undefined) => Promise<void>;
77
+ export declare const startCardForm: (options?: CardFormOption) => Promise<void>;
53
78
  /**
54
79
  * カードフォーム画面を閉じます。
55
80
  */
@@ -1,19 +1,7 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.onCardFormUpdate = exports.setIOSCardFormStyle = exports.showTokenProcessingError = exports.completeCardForm = exports.startCardForm = void 0;
13
1
  // LICENSE : MIT
14
- const react_native_1 = require("react-native");
15
- const { RNPAYCardForm } = react_native_1.NativeModules;
16
- const cardFormEventEmitter = new react_native_1.NativeEventEmitter(RNPAYCardForm);
2
+ import { NativeModules, NativeEventEmitter, processColor } from 'react-native';
3
+ const { RNPAYCardForm } = NativeModules;
4
+ const cardFormEventEmitter = new NativeEventEmitter(RNPAYCardForm);
17
5
  const onCardFormCanceledSet = new Set();
18
6
  const onCardFormCompletedSet = new Set();
19
7
  const onCardFormProducedTokenSet = new Set();
@@ -23,40 +11,43 @@ const onCardFormProducedTokenSet = new Set();
23
11
  *
24
12
  * @param options カードフォームのオプション
25
13
  */
26
- exports.startCardForm = (options) => __awaiter(void 0, void 0, void 0, function* () {
27
- yield RNPAYCardForm.startCardForm(options === null || options === void 0 ? void 0 : options.tenantId, options === null || options === void 0 ? void 0 : options.cardFormType);
28
- });
14
+ export const startCardForm = async (options) => {
15
+ const extraAttributes = options?.extraAttributes ?? [{ type: 'email' }, { type: 'phone' }];
16
+ const extraAttributeEmail = extraAttributes.find(attribute => attribute.type === 'email');
17
+ const extraAttributePhone = extraAttributes.find(attribute => attribute.type === 'phone');
18
+ await RNPAYCardForm.startCardForm(options?.tenantId, options?.cardFormType, !!extraAttributeEmail, !!extraAttributePhone, extraAttributeEmail?.preset, extraAttributePhone?.presetRegion, extraAttributePhone?.presetNumber, options?.useThreeDSecure ?? false);
19
+ };
29
20
  /**
30
21
  * カードフォーム画面を閉じます。
31
22
  */
32
- exports.completeCardForm = () => __awaiter(void 0, void 0, void 0, function* () {
33
- yield RNPAYCardForm.completeCardForm();
34
- });
23
+ export const completeCardForm = async () => {
24
+ await RNPAYCardForm.completeCardForm();
25
+ };
35
26
  /**
36
27
  * カードフォーム画面を終了せずにエラーメッセージを表示します。
37
28
  *
38
29
  * @param message エラーメッセージ
39
30
  */
40
- exports.showTokenProcessingError = (message) => __awaiter(void 0, void 0, void 0, function* () {
41
- yield RNPAYCardForm.showTokenProcessingError(message);
42
- });
31
+ export const showTokenProcessingError = async (message) => {
32
+ await RNPAYCardForm.showTokenProcessingError(message);
33
+ };
43
34
  /**
44
35
  * カードフォームのスタイルをセットします。(iOS用)
45
36
  *
46
37
  * @param style スタイル情報
47
38
  */
48
- exports.setIOSCardFormStyle = (style) => __awaiter(void 0, void 0, void 0, function* () {
39
+ export const setIOSCardFormStyle = async (style) => {
49
40
  const styleConverted = {};
50
41
  for (const key in style) {
51
42
  const styleKey = key;
52
43
  const styleValue = style[styleKey];
53
- const processedValue = react_native_1.processColor(styleValue);
44
+ const processedValue = processColor(styleValue);
54
45
  if (processedValue !== null && processedValue !== undefined) {
55
46
  styleConverted[styleKey] = processedValue;
56
47
  }
57
48
  }
58
- yield RNPAYCardForm.setFormStyle(styleConverted);
59
- });
49
+ await RNPAYCardForm.setFormStyle(styleConverted);
50
+ };
60
51
  /**
61
52
  * カードフォームの更新を受け取ります。
62
53
  * 登録したリスナーを解除するには、返却される関数を実行します。
@@ -74,7 +65,7 @@ exports.setIOSCardFormStyle = (style) => __awaiter(void 0, void 0, void 0, funct
74
65
  * @param observer カードフォームの更新を受け取るリスナー
75
66
  * @returns unsubscribe function リスナーを解除する(多くの場合アンマウント時にコールする)関数
76
67
  */
77
- exports.onCardFormUpdate = (observer) => {
68
+ export const onCardFormUpdate = (observer) => {
78
69
  const { onCardFormCanceled, onCardFormCompleted, onCardFormProducedToken } = observer;
79
70
  const unsubscribeNative = connectCardForm();
80
71
  onCardFormCanceled && onCardFormCanceledSet.add(onCardFormCanceled);
@@ -88,14 +79,14 @@ exports.onCardFormUpdate = (observer) => {
88
79
  };
89
80
  };
90
81
  const connectCardForm = () => {
91
- const onCardFormCanceled = cardFormEventEmitter.addListener("onCardFormCanceled", () => {
92
- onCardFormCanceledSet.forEach((observer) => observer());
82
+ const onCardFormCanceled = cardFormEventEmitter.addListener('onCardFormCanceled', () => {
83
+ onCardFormCanceledSet.forEach(observer => observer());
93
84
  });
94
- const onCardFormCompleted = cardFormEventEmitter.addListener("onCardFormCompleted", () => {
95
- onCardFormCompletedSet.forEach((observer) => observer());
85
+ const onCardFormCompleted = cardFormEventEmitter.addListener('onCardFormCompleted', () => {
86
+ onCardFormCompletedSet.forEach(observer => observer());
96
87
  });
97
- const onCardFormProducedToken = cardFormEventEmitter.addListener("onCardFormProducedToken", (token) => {
98
- onCardFormProducedTokenSet.forEach((observer) => observer(token));
88
+ const onCardFormProducedToken = cardFormEventEmitter.addListener('onCardFormProducedToken', token => {
89
+ onCardFormProducedTokenSet.forEach(observer => observer(token));
99
90
  });
100
91
  return () => {
101
92
  onCardFormCanceled.remove();
@@ -103,4 +94,3 @@ const connectCardForm = () => {
103
94
  onCardFormProducedToken.remove();
104
95
  };
105
96
  };
106
- //# sourceMappingURL=CardForm.js.map
@@ -1,4 +1,4 @@
1
- declare type InitOption = {
1
+ type InitOption = {
2
2
  /**
3
3
  * PAY.JPのパブリックキー
4
4
  * PAY.JP管理画面で取得します
package/lib/Core.js ADDED
@@ -0,0 +1,18 @@
1
+ // LICENSE : MIT
2
+ import { NativeModules } from 'react-native';
3
+ const { RNPAYCore } = NativeModules;
4
+ /**
5
+ * PAY.JPのSDKの初期設定
6
+ * カードフォームなどを利用する前にコールする必要があります。
7
+ *
8
+ * @param options オプション
9
+ */
10
+ export const init = async (options) => {
11
+ await RNPAYCore.initialize({
12
+ publicKey: options.publicKey,
13
+ locale: options.locale ?? null,
14
+ debugEnabled: options.debugEnabled ?? false,
15
+ threeDSecureRedirectUrl: options.threeDSecureRedirect?.url ?? null,
16
+ threeDSecureRedirectKey: options.threeDSecureRedirect?.key ?? null,
17
+ });
18
+ };
package/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import * as PayjpApplePay from './ApplePay';
2
+ import * as PayjpCardForm from './CardForm';
3
+ import * as PayjpCore from './Core';
4
+ export { PayjpCore, PayjpCardForm, PayjpApplePay };
5
+ export * from './models';
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // LICENSE : MIT
2
+ import * as PayjpApplePay from './ApplePay';
3
+ import * as PayjpCardForm from './CardForm';
4
+ import * as PayjpCore from './Core';
5
+ export { PayjpCore, PayjpCardForm, PayjpApplePay };
6
+ export * from './models';
@@ -9,7 +9,7 @@
9
9
  * https://openapi-generator.tech
10
10
  * Do not edit the class manually.
11
11
  */
12
- import { CardBrand } from "./";
12
+ import { CardBrand } from './';
13
13
  /**
14
14
  *
15
15
  * @export
@@ -82,6 +82,18 @@ export interface Card {
82
82
  * @memberof Card
83
83
  */
84
84
  fingerprint?: string;
85
+ /**
86
+ * メールアドレス 2024年8月以降、3Dセキュア認証の際にphoneまたはemailのデータ入力が求められます。
87
+ * @type {string}
88
+ * @memberof Card
89
+ */
90
+ email?: string | null;
91
+ /**
92
+ * E.164形式の電話番号 (e.g. 090-0123-4567(日本) => \"+819001234567\") 2024年8月以降、3Dセキュア認証の際にphoneまたはemailのデータ入力が求められます。
93
+ * @type {string}
94
+ * @memberof Card
95
+ */
96
+ phone?: string | null;
85
97
  /**
86
98
  * 都道府県
87
99
  * @type {string}
@@ -0,0 +1,86 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * PAY.JP Token API
5
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
+ *
7
+ * The version of the OpenAPI document: 0.1.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+ // import { exists, mapValues } from '../runtime';
15
+ function exists(json, key) {
16
+ const value = json[key];
17
+ return value !== null && value !== undefined;
18
+ }
19
+ function mapValues(data, fn) {
20
+ return Object.keys(data).reduce((acc, key) => ({ ...acc, [key]: fn(data[key]) }), {});
21
+ }
22
+ import { CardBrandFromJSON, CardBrandToJSON } from './';
23
+ export function CardFromJSON(json) {
24
+ return CardFromJSONTyped(json, false);
25
+ }
26
+ export function CardFromJSONTyped(json, ignoreDiscriminator) {
27
+ if (json === undefined || json === null) {
28
+ return json;
29
+ }
30
+ return {
31
+ id: json['id'],
32
+ object: !exists(json, 'object') ? undefined : json['object'],
33
+ created: !exists(json, 'created') ? undefined : json['created'],
34
+ name: !exists(json, 'name') ? undefined : json['name'],
35
+ last4: !exists(json, 'last4') ? undefined : json['last4'],
36
+ expMonth: !exists(json, 'exp_month') ? undefined : json['exp_month'],
37
+ expYear: !exists(json, 'exp_year') ? undefined : json['exp_year'],
38
+ brand: !exists(json, 'brand') ? undefined : CardBrandFromJSON(json['brand']),
39
+ cvcCheck: !exists(json, 'cvc_check') ? undefined : json['cvc_check'],
40
+ threeDSecureStatus: !exists(json, 'three_d_secure_status') ? undefined : json['three_d_secure_status'],
41
+ fingerprint: !exists(json, 'fingerprint') ? undefined : json['fingerprint'],
42
+ email: !exists(json, 'email') ? undefined : json['email'],
43
+ phone: !exists(json, 'phone') ? undefined : json['phone'],
44
+ addressState: !exists(json, 'address_state') ? undefined : json['address_state'],
45
+ addressCity: !exists(json, 'address_city') ? undefined : json['address_city'],
46
+ addressLine1: !exists(json, 'address_line1') ? undefined : json['address_line1'],
47
+ addressLine2: !exists(json, 'address_line2') ? undefined : json['address_line2'],
48
+ country: !exists(json, 'country') ? undefined : json['country'],
49
+ addressZip: !exists(json, 'address_zip') ? undefined : json['address_zip'],
50
+ addressZipCheck: !exists(json, 'address_zip_check') ? undefined : json['address_zip_check'],
51
+ customer: !exists(json, 'customer') ? undefined : json['customer'],
52
+ metadata: !exists(json, 'metadata') ? undefined : json['metadata'],
53
+ };
54
+ }
55
+ export function CardToJSON(value) {
56
+ if (value === undefined) {
57
+ return undefined;
58
+ }
59
+ if (value === null) {
60
+ return null;
61
+ }
62
+ return {
63
+ id: value.id,
64
+ object: value.object,
65
+ created: value.created,
66
+ name: value.name,
67
+ last4: value.last4,
68
+ exp_month: value.expMonth,
69
+ exp_year: value.expYear,
70
+ brand: CardBrandToJSON(value.brand),
71
+ cvc_check: value.cvcCheck,
72
+ three_d_secure_status: value.threeDSecureStatus,
73
+ fingerprint: value.fingerprint,
74
+ email: value.email,
75
+ phone: value.phone,
76
+ address_state: value.addressState,
77
+ address_city: value.addressCity,
78
+ address_line1: value.addressLine1,
79
+ address_line2: value.addressLine2,
80
+ country: value.country,
81
+ address_zip: value.addressZip,
82
+ address_zip_check: value.addressZipCheck,
83
+ customer: value.customer,
84
+ metadata: value.metadata,
85
+ };
86
+ }