payjp-react-native 0.6.2 → 0.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/android/build.gradle +4 -11
- package/android/src/main/java/jp/pay/reactnative/PayjpCardFormModule.kt +22 -1
- package/ios/Classes/RNPAY.m +1 -1
- package/ios/Classes/RNPAYCardForm.m +20 -3
- package/lib/{src/ApplePay.d.ts → ApplePay.d.ts} +6 -6
- package/lib/{src/ApplePay.js → ApplePay.js} +22 -32
- package/lib/{src/CardForm.d.ts → CardForm.d.ts} +30 -9
- package/lib/{src/CardForm.js → CardForm.js} +26 -36
- package/lib/{src/Core.d.ts → Core.d.ts} +1 -1
- package/lib/Core.js +18 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +6 -0
- package/lib/{src/models → models}/Card.d.ts +13 -1
- package/lib/models/Card.js +86 -0
- package/lib/{src/models → models}/CardBrand.d.ts +10 -9
- package/lib/models/CardBrand.js +44 -0
- package/lib/{src/models → models}/ErrorResponse.js +5 -12
- package/lib/{src/models → models}/ModelError.js +7 -14
- package/lib/{src/models → models}/Token.d.ts +1 -1
- package/lib/{src/models → models}/Token.js +12 -19
- package/lib/models/index.d.ts +5 -0
- package/lib/models/index.js +6 -0
- package/package.json +31 -54
- package/payjp-react-native.podspec +3 -1
- package/sdkconfig.json +3 -3
- package/src/ApplePay.ts +8 -8
- package/src/CardForm.ts +35 -10
- package/src/Core.ts +1 -1
- package/src/index.ts +4 -4
- package/src/models/Card.ts +37 -21
- package/src/models/CardBrand.ts +19 -8
- package/src/models/ErrorResponse.ts +1 -1
- package/src/models/ModelError.ts +3 -3
- package/src/models/Token.ts +7 -7
- package/src/models/index.ts +7 -6
- package/lib/src/ApplePay.js.map +0 -1
- package/lib/src/CardForm.js.map +0 -1
- package/lib/src/Core.js +0 -32
- package/lib/src/Core.js.map +0 -1
- package/lib/src/index.d.ts +0 -5
- package/lib/src/index.js +0 -34
- package/lib/src/index.js.map +0 -1
- package/lib/src/models/Card.js +0 -89
- package/lib/src/models/Card.js.map +0 -1
- package/lib/src/models/CardBrand.js +0 -43
- package/lib/src/models/CardBrand.js.map +0 -1
- package/lib/src/models/ErrorResponse.js.map +0 -1
- package/lib/src/models/ModelError.js.map +0 -1
- package/lib/src/models/Token.js.map +0 -1
- package/lib/src/models/TokenForm.d.ts +0 -51
- package/lib/src/models/TokenForm.js +0 -58
- package/lib/src/models/TokenForm.js.map +0 -1
- package/lib/src/models/index.d.ts +0 -6
- package/lib/src/models/index.js +0 -19
- package/lib/src/models/index.js.map +0 -1
- package/src/models/TokenForm.ts +0 -95
- /package/lib/{src/models → models}/ErrorResponse.d.ts +0 -0
- /package/lib/{src/models → models}/ModelError.d.ts +0 -0
package/android/build.gradle
CHANGED
|
@@ -5,11 +5,11 @@ buildscript {
|
|
|
5
5
|
|
|
6
6
|
repositories {
|
|
7
7
|
google()
|
|
8
|
-
|
|
8
|
+
mavenCentral()
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
dependencies {
|
|
12
|
-
classpath 'com.android.tools.build:gradle:4.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
|
-
|
|
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,36 @@ 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?,
|
|
74
80
|
promise: Promise
|
|
75
81
|
) {
|
|
76
82
|
val face = when (cardFormType) {
|
|
77
83
|
"cardDisplay" -> PayjpCardForm.FACE_CARD_DISPLAY
|
|
78
84
|
else -> PayjpCardForm.FACE_MULTI_LINE
|
|
79
85
|
}
|
|
86
|
+
val extraAttributes: Array<ExtraAttribute<*>> = listOfNotNull(
|
|
87
|
+
ExtraAttribute.Email(preset = extraAttributeEmailPreset)
|
|
88
|
+
.takeIf { extraAttributeEmailEnabled },
|
|
89
|
+
ExtraAttribute.Phone(
|
|
90
|
+
region = extraAttributePhoneRegion ?: "JP",
|
|
91
|
+
number = extraAttributePhoneNumber
|
|
92
|
+
).takeIf { extraAttributePhoneEnabled },
|
|
93
|
+
).toTypedArray()
|
|
94
|
+
|
|
80
95
|
mainThreadHandler.post {
|
|
81
96
|
reactContext.currentActivity?.let { activity ->
|
|
82
97
|
val tenantId = tenantIdString?.let { TenantId(it) }
|
|
83
|
-
Payjp.cardForm().start(
|
|
98
|
+
Payjp.cardForm().start(
|
|
99
|
+
activity = activity,
|
|
100
|
+
requestCode = CODE_START_CARD_FORM,
|
|
101
|
+
tenant = tenantId,
|
|
102
|
+
face = face,
|
|
103
|
+
extraAttributes = extraAttributes,
|
|
104
|
+
)
|
|
84
105
|
}
|
|
85
106
|
promise.resolve(null)
|
|
86
107
|
}
|
package/ios/Classes/RNPAY.m
CHANGED
|
@@ -47,7 +47,12 @@ RCT_EXPORT_MODULE()
|
|
|
47
47
|
|
|
48
48
|
RCT_EXPORT_METHOD(startCardForm
|
|
49
49
|
: (NSString *)tenantId cardFormType
|
|
50
|
-
: (NSString *)cardFormType
|
|
50
|
+
: (NSString *)cardFormType extraAttributeEmailEnabled
|
|
51
|
+
: (BOOL)extraAttributeEmailEnabled extraAttributePhoneEnabled
|
|
52
|
+
: (BOOL)extraAttributePhoneEnabled extraAttributeEmail
|
|
53
|
+
: (NSString *)extraAttributeEmail extraAttributePhoneRegion
|
|
54
|
+
: (NSString *)extraAttributePhoneRegion extraAttributePhoneNumber
|
|
55
|
+
: (NSString *)extraAttributePhoneNumber resolve
|
|
51
56
|
: (RCTPromiseResolveBlock)resolve reject
|
|
52
57
|
: (__unused RCTPromiseRejectBlock)reject) {
|
|
53
58
|
NSString *description =
|
|
@@ -60,13 +65,25 @@ RCT_EXPORT_METHOD(startCardForm
|
|
|
60
65
|
if ([cardFormType isEqual:@"cardDisplay"]) {
|
|
61
66
|
viewType = CardFormViewTypeDisplayStyled;
|
|
62
67
|
}
|
|
63
|
-
|
|
68
|
+
NSMutableArray<id<PAYExtraAttribute>> *extraAttributes = [NSMutableArray array];
|
|
69
|
+
if (extraAttributeEmailEnabled) {
|
|
70
|
+
PAYExtraAttributeEmail *email =
|
|
71
|
+
[[PAYExtraAttributeEmail alloc] initWithPreset:extraAttributeEmail];
|
|
72
|
+
[extraAttributes addObject:email];
|
|
73
|
+
}
|
|
74
|
+
if (extraAttributePhoneEnabled) {
|
|
75
|
+
PAYExtraAttributePhone *phone =
|
|
76
|
+
[[PAYExtraAttributePhone alloc] initWithPresetNumber:extraAttributePhoneNumber
|
|
77
|
+
presetRegion:extraAttributePhoneRegion];
|
|
78
|
+
[extraAttributes addObject:phone];
|
|
79
|
+
}
|
|
64
80
|
dispatch_async([self methodQueue], ^{
|
|
65
81
|
PAYCardFormViewController *cardForm = [PAYCardFormViewController
|
|
66
82
|
createCardFormViewControllerWithStyle:wself.style ?: PAYCardFormStyle.defaultStyle
|
|
67
83
|
tenantId:tenantId
|
|
68
84
|
delegate:wself
|
|
69
|
-
viewType:viewType
|
|
85
|
+
viewType:viewType
|
|
86
|
+
extraAttributes:extraAttributes];
|
|
70
87
|
UIViewController *hostViewController =
|
|
71
88
|
UIApplication.sharedApplication.keyWindow.rootViewController;
|
|
72
89
|
if ([hostViewController isKindOfClass:[UINavigationController class]]) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Token } from
|
|
1
|
+
import { Token } from './models';
|
|
2
2
|
/**
|
|
3
3
|
* エラー情報
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
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
|
|
14
|
+
export type OnApplePayProducedToken = (token: Token) => void;
|
|
15
15
|
/**
|
|
16
16
|
* トークンのリクエストに失敗したときのリスナー
|
|
17
17
|
* @param errorInfo エラー情報
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
19
|
+
export type OnApplePayFailedRequestToken = (errorInfo: ErrorInfo) => void;
|
|
20
20
|
/**
|
|
21
21
|
* Apple Payが完了したときのリスナー
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
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
|
|
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
|
-
|
|
15
|
-
const { RNPAYApplePay } =
|
|
16
|
-
const applePayEventEmitter = new
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
const filledOption =
|
|
38
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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(
|
|
72
|
-
onApplePayProducedTokenSet.forEach(
|
|
62
|
+
const onApplePayProducedToken = applePayEventEmitter.addListener('onApplePayProducedToken', token => {
|
|
63
|
+
onApplePayProducedTokenSet.forEach(observer => observer(token));
|
|
73
64
|
});
|
|
74
|
-
const onApplePayFailedRequestToken = applePayEventEmitter.addListener(
|
|
75
|
-
onApplePayFailedRequestTokenSet.forEach(
|
|
65
|
+
const onApplePayFailedRequestToken = applePayEventEmitter.addListener('onApplePayFailedRequestToken', error => {
|
|
66
|
+
onApplePayFailedRequestTokenSet.forEach(observer => observer(error));
|
|
76
67
|
});
|
|
77
|
-
const onApplePayCompleted = applePayEventEmitter.addListener(
|
|
78
|
-
onApplePayCompletedSet.forEach(
|
|
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
|
|
2
|
-
import { Token } from
|
|
1
|
+
import { ColorValue } from 'react-native';
|
|
2
|
+
import { Token } from './models';
|
|
3
3
|
/**
|
|
4
4
|
* カードフォームがキャンセルされたときに実行されるリスナー
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type OnCardFormCanceled = () => void;
|
|
7
7
|
/**
|
|
8
8
|
* カードフォームが完了したときに実行されるリスナー
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type OnCardFormCompleted = () => void;
|
|
11
11
|
/**
|
|
12
12
|
* カードフォームでトークンが生成されたときに実行されるリスナー
|
|
13
13
|
*
|
|
14
14
|
* @param token PAY.JPトークン
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type OnCardFormProducedToken = (token: Token) => void;
|
|
17
17
|
/**
|
|
18
18
|
* カードフォームスタイル(iOS用)
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
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
|
|
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
|
-
|
|
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,14 @@ 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[];
|
|
45
66
|
};
|
|
46
67
|
/**
|
|
47
68
|
* カードフォームを開始します。
|
|
@@ -49,7 +70,7 @@ declare type CardFormOption = {
|
|
|
49
70
|
*
|
|
50
71
|
* @param options カードフォームのオプション
|
|
51
72
|
*/
|
|
52
|
-
export declare const startCardForm: (options?: CardFormOption
|
|
73
|
+
export declare const startCardForm: (options?: CardFormOption) => Promise<void>;
|
|
53
74
|
/**
|
|
54
75
|
* カードフォーム画面を閉じます。
|
|
55
76
|
*/
|
|
@@ -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
|
-
|
|
15
|
-
const { RNPAYCardForm } =
|
|
16
|
-
const cardFormEventEmitter = new
|
|
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
|
-
|
|
27
|
-
|
|
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);
|
|
19
|
+
};
|
|
29
20
|
/**
|
|
30
21
|
* カードフォーム画面を閉じます。
|
|
31
22
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
23
|
+
export const completeCardForm = async () => {
|
|
24
|
+
await RNPAYCardForm.completeCardForm();
|
|
25
|
+
};
|
|
35
26
|
/**
|
|
36
27
|
* カードフォーム画面を終了せずにエラーメッセージを表示します。
|
|
37
28
|
*
|
|
38
29
|
* @param message エラーメッセージ
|
|
39
30
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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 =
|
|
44
|
+
const processedValue = processColor(styleValue);
|
|
54
45
|
if (processedValue !== null && processedValue !== undefined) {
|
|
55
46
|
styleConverted[styleKey] = processedValue;
|
|
56
47
|
}
|
|
57
48
|
}
|
|
58
|
-
|
|
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
|
-
|
|
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(
|
|
92
|
-
onCardFormCanceledSet.forEach(
|
|
82
|
+
const onCardFormCanceled = cardFormEventEmitter.addListener('onCardFormCanceled', () => {
|
|
83
|
+
onCardFormCanceledSet.forEach(observer => observer());
|
|
93
84
|
});
|
|
94
|
-
const onCardFormCompleted = cardFormEventEmitter.addListener(
|
|
95
|
-
onCardFormCompletedSet.forEach(
|
|
85
|
+
const onCardFormCompleted = cardFormEventEmitter.addListener('onCardFormCompleted', () => {
|
|
86
|
+
onCardFormCompletedSet.forEach(observer => observer());
|
|
96
87
|
});
|
|
97
|
-
const onCardFormProducedToken = cardFormEventEmitter.addListener(
|
|
98
|
-
onCardFormProducedTokenSet.forEach(
|
|
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
|
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
package/lib/index.js
ADDED
|
@@ -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
|
+
}
|
|
@@ -12,16 +12,17 @@
|
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
14
14
|
* @export
|
|
15
|
-
* @enum {string}
|
|
16
15
|
*/
|
|
17
|
-
export declare
|
|
18
|
-
Visa
|
|
19
|
-
MasterCard
|
|
20
|
-
|
|
21
|
-
AmericanExpress
|
|
22
|
-
DinersClub
|
|
23
|
-
Discover
|
|
24
|
-
}
|
|
16
|
+
export declare const CardBrand: {
|
|
17
|
+
readonly Visa: "Visa";
|
|
18
|
+
readonly MasterCard: "MasterCard";
|
|
19
|
+
readonly Jcb: "JCB";
|
|
20
|
+
readonly AmericanExpress: "American Express";
|
|
21
|
+
readonly DinersClub: "Diners Club";
|
|
22
|
+
readonly Discover: "Discover";
|
|
23
|
+
};
|
|
24
|
+
export type CardBrand = (typeof CardBrand)[keyof typeof CardBrand];
|
|
25
|
+
export declare function instanceOfCardBrand(value: any): boolean;
|
|
25
26
|
export declare function CardBrandFromJSON(json: any): CardBrand;
|
|
26
27
|
export declare function CardBrandFromJSONTyped(json: any, ignoreDiscriminator: boolean): CardBrand;
|
|
27
28
|
export declare function CardBrandToJSON(value?: CardBrand | null): any;
|