Skip to content

Commit ec18cd0

Browse files
committed
Add buySKUComplete method
1 parent f7cc82c commit ec18cd0

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,6 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
238238
fun removeListeners(count: Int?) {
239239
}
240240

241-
@ReactMethod
242-
fun removeAllListeners(eventName: String?) {
243-
}
244-
245241
override fun onActivityResult(
246242
activity: Activity?,
247243
requestCode: Int,

examples/Basic/App.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ const App = () => {
103103
}
104104

105105
if (Platform.OS === 'ios' || Platform.isTV) {
106-
console.log('Preparing to call buySkuCompleteApple');
106+
console.log('Preparing to call buySkuComplete with Apple');
107107

108108
console.log(namiSku);
109109
console.log(purchase.transactionId);
110110
console.log(purchase.originalTransactionIdentifierIOS);
111111

112-
NamiPaywallManager.buySkuCompleteApple({
112+
NamiPaywallManager.buySkuComplete({
113113
product: namiSku,
114114
transactionID: purchase.transactionId ?? '',
115115
originalTransactionID: purchase.originalTransactionIdentifierIOS ?? purchase.transactionId ?? '',
@@ -118,21 +118,21 @@ const App = () => {
118118
});
119119
} else if (Platform.OS === 'android') {
120120
if (Platform.constants.Manufacturer === 'Amazon') {
121-
console.log('Preparing to call buySkuCompleteAmazon');
122-
NamiPaywallManager.buySkuCompleteAmazon({
121+
console.log('Preparing to call buySkuComplete with Amazon');
122+
NamiPaywallManager.buySkuComplete({
123123
product: namiSku,
124124
receiptId: purchase.transactionId ?? '',
125125
localizedPrice: price,
126126
userId: purchase.userIdAmazon ?? '',
127127
marketplace: purchase.userMarketplaceAmazon ?? '',
128-
});
128+
}, "Amazon");
129129
} else {
130-
console.log('Preparing to call buySkuCompleteGooglePlay');
131-
NamiPaywallManager.buySkuCompleteGooglePlay({
130+
console.log('Preparing to call buySkuComplete with GooglePlay');
131+
NamiPaywallManager.buySkuComplete({
132132
product: namiSku,
133133
purchaseToken: purchase.purchaseToken ?? '',
134134
orderId: purchase.transactionId ?? '',
135-
});
135+
}, "GooglePlay");
136136
}
137137
}
138138

examples/TestNamiTV/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const App = () => {
6161
NamiPaywallManager.dismiss();
6262

6363
if (Platform.OS === 'ios') {
64-
NamiPaywallManager.buySkuCompleteApple({
64+
NamiPaywallManager.buySkuComplete({
6565
product: sku,
6666
transactionID: '12345',
6767
originalTransactionID: '12345',
@@ -70,20 +70,20 @@ const App = () => {
7070
});
7171
} else if (Platform.OS === 'android') {
7272
if (Platform.constants.Manufacturer === 'Amazon') {
73-
NamiPaywallManager.buySkuCompleteAmazon({
73+
NamiPaywallManager.buySkuComplete({
7474
product: sku,
7575
receiptId: '12345',
7676
localizedPrice: '120',
7777
userId: '12345',
7878
marketplace: 'US',
79-
});
79+
}, "Amazon");
8080
} else {
81-
NamiPaywallManager.buySkuCompleteGooglePlay({
81+
NamiPaywallManager.buySkuComplete({
8282
product: sku,
8383
purchaseToken:
8484
'jolbnkpmojnpnjecgmphbmkc.AO-J1OznE4AIzyUvKFe1RSVkxw4KEtv0WfyL_tkzozOqnlSvIPsyQJBphCN80gwIMaex4EMII95rFCZhMCbVPZDc-y_VVhQU5Ddua1dLn8zV7ms_tdwoDmE',
8585
orderId: 'GPA.3317-0284-9993-42221',
86-
});
86+
}, "GooglePlay");
8787
}
8888
}
8989
},

src/NamiPaywallManager.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ export declare enum ServicesEnum {
1111
Amazon = "Amazon",
1212
GooglePlay = "GooglePlay"
1313
}
14+
15+
export type Service = ServicesEnum.Amazon | ServicesEnum.GooglePlay
16+
1417
export interface INamiPaywallManager {
1518
paywallEmitter: NativeEventEmitter;
1619
buySkuCompleteApple: (purchaseSuccess: NamiPurchaseSuccessApple) => void;
1720
buySkuCompleteAmazon: (purchaseSuccess: NamiPurchaseSuccessAmazon) => void;
1821
buySkuCompleteGooglePlay: (purchaseSuccess: NamiPurchaseSuccessGooglePlay) => void;
22+
buySkuComplete: (purchaseSuccess: NamiPurchaseSuccessApple | NamiPurchaseSuccessAmazon | NamiPurchaseSuccessGooglePlay, platform?: Service) => void;
1923
buySkuCancel: () => void;
2024
registerBuySkuHandler: (callback: (sku: NamiSKU) => void) => EmitterSubscription['remove'];
2125
registerCloseHandler: (callback: () => void) => EmitterSubscription['remove'];

src/NamiPaywallManager.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ export enum ServicesEnum {
2323
GooglePlay = 'GooglePlay',
2424
}
2525

26+
export type Service = ServicesEnum.Amazon | ServicesEnum.GooglePlay
27+
2628
export interface INamiPaywallManager {
2729
paywallEmitter: NativeEventEmitter;
2830
buySkuCompleteApple: (purchaseSuccess: NamiPurchaseSuccessApple) => void;
2931
buySkuCompleteAmazon: (purchaseSuccess: NamiPurchaseSuccessAmazon) => void;
3032
buySkuCompleteGooglePlay: (
3133
purchaseSuccess: NamiPurchaseSuccessGooglePlay,
3234
) => void;
35+
buySkuComplete: (purchaseSuccess: NamiPurchaseSuccessApple | NamiPurchaseSuccessAmazon | NamiPurchaseSuccessGooglePlay, platform?: Service) => void;
3336
buySkuCancel: () => void;
3437
registerBuySkuHandler: (
3538
callback: (sku: NamiSKU) => void,
@@ -59,6 +62,13 @@ export const NamiPaywallManager: INamiPaywallManager = {
5962
paywallEmitter: new NativeEventEmitter(RNNamiPaywallManager),
6063
...RNNamiPaywallManager,
6164
...NamiPaywallManagerBridge,
65+
buySkuComplete: (purchaseSuccess: NamiPurchaseSuccessApple | NamiPurchaseSuccessAmazon | NamiPurchaseSuccessGooglePlay, platform?: Service) => {
66+
if (!platform) {
67+
RNNamiPaywallManager.buySkuComplete(purchaseSuccess);
68+
} else {
69+
RNNamiPaywallManager.buySkuComplete(purchaseSuccess, platform);
70+
}
71+
},
6272
buySkuCompleteApple: (purchaseSuccess: NamiPurchaseSuccessApple) => {
6373
RNNamiPaywallManager.buySkuComplete(purchaseSuccess);
6474
},

0 commit comments

Comments
 (0)