### Start IabHelper Setup Source: https://myket.ir/kb/pages/in-app-purchase-implementation-steps Initiate the asynchronous setup process and handle the result via the OnIabSetupFinishedListener. ```java mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { // Oh noes, there was a problem. Log.d(TAG, "Problem setting up In-app Billing: " + result); } // Hooray, IAB is fully set up! } }); ``` -------------------------------- ### myket://download/[PACKAGE_NAME] Source: https://myket.ir/kb/pages/open-application-page-in-myket Opens the application detail page and automatically starts the download process. ```APIDOC ## URI Scheme: myket://download/[PACKAGE_NAME] ### Description Opens the application detail page in Myket and simultaneously triggers the download of the application. ### Parameters - **PACKAGE_NAME** (string) - Required - The package name of the application to be downloaded. ``` -------------------------------- ### Install Myket In-App Billing Module Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Commands to install the required dependency using npm or yarn. ```bash npm install iab-myket-reactnative ``` ```bash yarn add iab-myket-reactnative ``` -------------------------------- ### Connect(RSAPublicKey: String) Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Initializes the Myket billing service. This method is required before performing any other operations and returns a promise that rejects if the Myket app is not installed or the key is invalid. ```APIDOC ## Connect(RSAPublicKey: String) ### Description Initializes the Myket billing service. This method is required before performing any other operations. ### Parameters - **RSAPublicKey** (String) - Required - The RSA public key obtained from the Myket developer panel. ### Response - **Promise** - Resolves on success, rejects if Myket is not installed or the key is invalid. ``` -------------------------------- ### Install Myket IAP Dependency Source: https://myket.ir/kb/pages/iab-flutter Add the dependency to your pubspec.yaml file. ```yaml myket_iap: ^1.1.10 ``` -------------------------------- ### Configure Package Visibility Source: https://myket.ir/kb/pages/in-app-purchase-implementation-steps Required for targetSdkVersion 30 and above to ensure the app can communicate with Myket when installed. ```xml ``` -------------------------------- ### GET /api/partners/applications/{PACKAGE_NAME}/purchases/products/{SKU_ID}/verify Source: https://myket.ir/kb/pages/server-to-server-payment-validation-api Verifies the status of an in-app purchase by providing the package name, product SKU, and purchase token. ```APIDOC ## POST /api/partners/applications/{PACKAGE_NAME}/purchases/products/{SKU_ID}/verify ### Description Validates an in-app purchase transaction status. This request must be performed server-to-server to maintain security. ### Method POST ### Endpoint https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/purchases/products/{SKU_ID}/verify ### Parameters #### Path Parameters - **PACKAGE_NAME** (string) - Required - The package name of the application (e.g., org.medrik.roosterwars) - **SKU_ID** (string) - Required - The product SKU identifier (e.g., GEM2) #### Request Body - **tokenId** (string) - Required - The purchase token received from the in-app purchase process ### Request Example { "tokenId": "{TOKEN_ID}" } ### Response #### Success Response (200) - **kind** (string) - The type of purchase - **purchaseTime** (long) - Timestamp of the transaction - **developerPayload** (string) - Payload sent during purchase initiation - **purchaseState** (integer) - 0 for success, 1 for failure - **consumptionState** (integer) - 0 for non-consumable, 1 for consumable #### Response Example { "kind": "androidpublisher#productPurchase", "purchaseTime": 1492839267000, "developerPayload": "", "purchaseState": 0, "consumptionState": 1 } ``` -------------------------------- ### GET /api/partners/applications/{PACKAGE_NAME}/products Source: https://myket.ir/kb/pages/manage-sku-items دریافت لیست محصولات درون‌برنامه‌ای ثبت شده برای یک پکیج خاص. ```APIDOC ## [GET] /api/partners/applications/{PACKAGE_NAME}/products ### Description این سرویس لیست محصولات درون‌برنامه‌ای ثبت شده برای یک برنامه را بازمی‌گرداند. این فراخوانی باید به صورت Server-to-Server انجام شود. ### Method GET ### Endpoint https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products ### Parameters #### Path Parameters - **PACKAGE_NAME** (string) - Required - نام پکیج برنامه (مثال: org.medrik.roosterwars) #### Query Parameters - **limit** (integer) - Optional - تعداد آیتم‌های برگشتی (پیش‌فرض: 100، حداکثر: 1000) - **offset** (integer) - Optional - شماره صفحه برگشتی (پیش‌فرض: 0) #### Headers - **X-Access-Token** (string) - Required - توکن صحت‌سنجی دریافت شده از پنل توسعه‌دهندگان ### Response #### Success Response (200) - **skus** (array) - لیست محصولات - **totalCount** (integer) - تعداد کل محصولات #### Response Example { "skus": [{ "skuId": "GEM1", "englishTitle": "Gem Level 1", "farsiTitle": "الماس ۱۰۰۰ تومانی مرحله اول", "price": 10000, "creationDate": "2024-07-27T00:00:05.41", "isActive": false }], "totalCount": 2 } ``` -------------------------------- ### Get Purchase Status Source: https://myket.ir/kb/pages/iab-flutter Check the status of a specific product. ```dart Map result = await MyketIAP.getPurchase(sku: "gas", querySkuDetails: false); ``` ```dart IabResult purchaseResult = result[MyketIAP.RESULT]; Purchase purchase = result[MyketIAP.PURCHASE]; ``` -------------------------------- ### GET /api/partners/applications/{packageName}/release-bundle Source: https://myket.ir/kb/pages/developer-cd Retrieves a list of all uploaded release bundles for a specific application, with optional filtering by status and pagination support. ```APIDOC ## [GET] /api/partners/applications/{packageName}/release-bundle ### Description Retrieves a list of all release bundles associated with a specific application package name. Supports filtering by release status and pagination. ### Method GET ### Endpoint https://developer.myket.ir/api/partners/applications/{packageName}/release-bundle?status={status}&offset={offset}&limit={limit} ### Parameters #### Path Parameters - **packageName** (string) - Required - The package name of the application (e.g., ir.mservices.mybook). #### Query Parameters - **status** (string) - Optional - Filter by status: JustCreated, WaitingForApproval, Rejected, Approved, RolledBack. - **offset** (integer) - Required - Pagination offset (must be > 0). - **limit** (integer) - Required - Number of items to return (range 1-20). ### Response #### Success Response (200) - **eol** (boolean) - Indicates if the end of the list has been reached. - **releases** (array) - List of release objects containing title, status, createdAt, id, and version details. #### Error Response (401) - Returned if the package does not exist or does not belong to the authenticated user. ``` -------------------------------- ### MyketSupportHelper.startSetup Source: https://myket.ir/kb/pages/check-version-update-service Initializes the Myket support helper to establish a connection with the Myket service. ```APIDOC ## MyketSupportHelper.startSetup ### Description Initializes the connection to the Myket service. This must be called before any other operations. ### Method void startSetup(OnMyketSetupFinishedListener listener) ### Parameters - **listener** (OnMyketSetupFinishedListener) - Required - Callback invoked when the setup process completes. ``` -------------------------------- ### MyketIAB.init Source: https://myket.ir/kb/pages/%DB%8C%D9%88%D9%86%DB%8C%D8%AA%DB%8C-unity-%D8%A8%D8%A7-gradle Initializes the Myket IAB service with the provided public key. ```APIDOC ## public static void init(string publicKey) ### Description Initializes the Myket IAB service. This must be called before any other library function. Success triggers `billingSupportedEvent`, failure triggers `billingNotSupportedEvent`. ### Parameters - **publicKey** (string) - Required - The public key obtained from the Myket developer panel. ``` -------------------------------- ### MyketIAB.init Source: https://myket.ir/kb/pages/unity-with-gradle-fa Initializes the billing service with the provided public key. Must be called before any other library functions. ```APIDOC ## public static void init(string publicKey) ### Description Initializes the Myket billing service. Requires the public key from the Myket developer panel. Triggers billingSupportedEvent on success or billingNotSupportedEvent on failure. ### Parameters - **publicKey** (string) - Required - The public key for the application. ``` -------------------------------- ### Run Prebuild Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Commands to run prebuild after adding the plugin. ```bash npx expo prebuild ``` ```bash yarn expo prebuild ``` -------------------------------- ### Connect to Myket Service Source: https://myket.ir/kb/pages/java Establish a connection to the billing service using startSetup and handle the result via OnIabSetupFinishedListener. ```java mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { } }); } ``` -------------------------------- ### Initialize Myket Billing Source: https://myket.ir/kb/pages/unity-with-gradle-fa Initializes the billing service with the public key from the Myket developer panel. ```csharp public static void init(string publicKey) ``` -------------------------------- ### Run Locally Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Commands to test the application on an emulator or device. ```bash npx expo run:android ``` ```bash yarn expo run:android ``` -------------------------------- ### دریافت لیست محصولات درون‌برنامه‌ای Source: https://myket.ir/kb/pages/manage-sku-items فراخوانی متد GET برای دریافت محصولات ثبت شده. این سرویس باید از سمت سرور فراخوانی شود. ```HTTP [GET] [Header: X-Access-Token] https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products?limit=10&offset=0 ``` -------------------------------- ### myket://details?id=[PACKAGE_NAME] Source: https://myket.ir/kb/pages/open-application-page-in-myket Opens the application detail page in the Myket store for the specified package. ```APIDOC ## URI Scheme: myket://details?id=[PACKAGE_NAME] ### Description Opens the Myket store page for a specific application. This is useful for directing users to your app page, such as when prompting them to install a new version. ### Parameters - **id** (string) - Required - The package name of the application. ``` -------------------------------- ### Launch In-App Purchase Flow Source: https://myket.ir/kb/pages/java Initiates the purchase process for a specific product SKU using the IabHelper instance. ```java try { mHelper.launchPurchaseFlow(this, SKU_PREMIUM, mPurchaseFinishedListener, payload); } catch (IabAsyncInProgressException e) { complain("Error launching purchase flow. Another async operation in progress."); } ``` -------------------------------- ### MyketIAP.init Source: https://myket.ir/kb/pages/iab-flutter Initializes the Myket IAP service. This must be called before any other function, typically in the initState() method. ```APIDOC ## MyketIAP.init(rsaKey: String, enableDebugLogging: bool) ### Description Initializes the connection to the Myket billing service. Returns an IabResult object. ### Parameters - **rsaKey** (String) - Required - The public key obtained from the Myket developer panel. - **enableDebugLogging** (bool) - Optional - Enables logging for purchase events. ``` -------------------------------- ### Launch Purchase Flow Source: https://myket.ir/kb/pages/iab-flutter Initiate a purchase for a specific product SKU. ```dart Map result = await MyketIAP.launchPurchaseFlow(sku: "gas", payload:"payload"); ``` ```dart IabResult purchaseResult = result[MyketIAP.RESULT]; Purchase purchase = result[MyketIAP.PURCHASE]; ``` -------------------------------- ### Purchase Product Source: https://myket.ir/kb/pages/unity-with-gradle-fa Initiates the purchase process for a specific product SKU. ```csharp public static void purchaseProduct(string sku)public static void purchaseProduct(string sku, string developerPayload) ``` -------------------------------- ### Initialize IabHelper Source: https://myket.ir/kb/pages/java Create an instance of IabHelper using the application context and the public key from BuildConfig. ```java mHelper = new IabHelper(context, BuildConfig.IAB_PUBLIC_KEY); ``` -------------------------------- ### Configure build.gradle Source: https://myket.ir/kb/pages/iab-flutter Add the required manifest placeholders and toolchain settings to your build.gradle file. ```gradle android { defaultConfig { def marketApplicationId = "ir.mservices.market" def marketBindAddress = "ir.mservices.market.InAppBillingService.BIND" manifestPlaceholders += [marketApplicationId: "${marketApplicationId}", marketBindAddress : "${marketBindAddress}", marketPermission : "${marketApplicationId}.BILLING"] } kotlin { jvmToolchain(21) } ... } ``` -------------------------------- ### MyketIAP.launchPurchaseFlow Source: https://myket.ir/kb/pages/iab-flutter Initiates the purchase flow for a specific product. ```APIDOC ## MyketIAP.launchPurchaseFlow(sku: String, payload: String) ### Description Starts the purchase process for the specified product SKU. ### Parameters - **sku** (String) - Required - The product identifier. - **payload** (String) - Optional - Developer payload for additional information. ``` -------------------------------- ### افزودن مخزن Jitpack به پروژه Source: https://myket.ir/kb/pages/java مخزن Jitpack را در فایل build.gradle اصلی پروژه برای دسترسی به کتابخانه اضافه کنید. ```gradle allprojects { repositories { ... maven { url 'https://jitpack.io' } } } ``` -------------------------------- ### Query SKU Details Source: https://myket.ir/kb/pages/unity-with-gradle-fa Retrieves information such as price and title for defined products. ```csharp public static void querySkuDetails(string[] skus) ``` -------------------------------- ### Initialize Myket IAP Source: https://myket.ir/kb/pages/iab-flutter Initialize the service before calling other methods, typically in initState(). ```dart var iabResult = await MyketIAP.init(rsaKey: rsa, enableDebugLogging: true); ``` -------------------------------- ### Query Inventory Source: https://myket.ir/kb/pages/unity-with-gradle-fa Retrieves product details and a list of unconsumed purchased items. ```csharp public static void queryInventory(string[] skus) ``` -------------------------------- ### MyketIAP.queryInventory Source: https://myket.ir/kb/pages/iab-flutter Retrieves information about all products purchased by the user. ```APIDOC ## MyketIAP.queryInventory(querySkuDetails: bool) ### Description Fetches the inventory of all items purchased by the current user. ### Parameters - **querySkuDetails** (bool) - Optional - If true, returns additional product details. ``` -------------------------------- ### افزودن وابستگی کتابخانه پرداخت Source: https://myket.ir/kb/pages/java کتابخانه پرداخت مایکت را در بخش dependencies فایل build.gradle پروژه قرار دهید. ```gradle dependencies { ... implementation 'com.github.myketstore:myket-billing-client:1.6' } ``` -------------------------------- ### MyketIAB.purchaseProduct Source: https://myket.ir/kb/pages/%DB%8C%D9%88%D9%86%DB%8C%D8%AA%DB%8C-unity-%D8%A8%D8%A7-gradle Initiates the purchase process for a product. ```APIDOC ## public static void purchaseProduct(string sku) ## public static void purchaseProduct(string sku, string developerPayload) ### Description Starts the purchase flow for a specific product. Success triggers `purchaseSucceededEvent`, failure triggers `purchaseFailedEvent`. ### Parameters - **sku** (string) - Required - The product ID. - **developerPayload** (string) - Optional - Additional developer data. ``` -------------------------------- ### Build for Production Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Command to build the final production version using EAS. ```bash eas build -p android --profile production ``` -------------------------------- ### Configure app.config.js Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Adding the plugin to existing or new app.config.js files. ```javascript plugins: [   ...(config.plugins || []),   [     withMarketPlace,     {       marketApplicationId: "ir.mservices.market",       marketBindAddress: "ir.mservices.market.InAppBillingService.BIND",       marketPermission: "ir.mservices.market.BILLING"     }   ] ] ``` ```javascript const fs = require('fs'); let baseConfig = {}; if (fs.existsSync('./app.json')) {   const appJson = require('./app.json');   baseConfig = appJson.expo || {}; } const withMarketPlace = require('./plugins/withMarketPlace'); export default ({ config }) => ({   ...baseConfig,   ...config,   plugins: [     ...(config.plugins || []),     [       withMarketPlace,       {         marketApplicationId: "ir.mservices.market",         marketBindAddress: "ir.mservices.market.InAppBillingService.BIND",         marketPermission: "ir.mservices.market.BILLING"       }     ]   ] }); ``` -------------------------------- ### IabHelper.launchPurchaseFlow Source: https://myket.ir/kb/pages/java Initiates the in-app purchase process for a specific product. This method opens the Myket purchase interface for the user. ```APIDOC ## launchPurchaseFlow(Activity act, String sku, OnIabPurchaseFinishedListener listener, String developerPayload) ### Description Starts the purchase flow for an in-app product. The Myket application handles the payment UI and transaction management. ### Parameters - **act** (Activity) - Required - The current activity where the purchase flow is initiated. - **sku** (String) - Required - The unique identifier of the product to be purchased. - **listener** (OnIabPurchaseFinishedListener) - Required - A callback to handle the result of the purchase process. - **developerPayload** (String) - Optional - A developer-defined string used for security verification and tracking. ### Code Example ```java try { mHelper.launchPurchaseFlow(this, SKU_PREMIUM, mPurchaseFinishedListener, payload); } catch (IabAsyncInProgressException e) { complain("Error launching purchase flow. Another async operation in progress."); } ``` ``` -------------------------------- ### PUT /api/partners/applications/{packageName}/release-bundle/upload Source: https://myket.ir/kb/pages/developer-cd بارگذاری و اضافه کردن یک بسته جدید به برنامه موجود. پیش‌نیاز این سرویس، ایجاد بسته از طریق سرویس تکمیل اطلاعات است. ```APIDOC ## PUT /api/partners/applications/{packageName}/release-bundle/upload ### Description این سرویس برای بارگذاری فایل نسخه برنامه استفاده می‌شود. فایل باید به صورت MultiPartFormData ارسال شود و حجم آن نباید از ۵۰۰ مگابایت بیشتر باشد. ### Method PUT ### Endpoint https://developer.myket.ir/api/partners/applications/{packageName}/release-bundle/upload ### Parameters #### Path Parameters - **packageName** (string) - Required - نام پکیج برنامه #### Request Body - **file** (binary) - Required - فایل برنامه (APK/Bundle) که به صورت MultiPartFormData ارسال می‌شود. ### Response #### Success Response (200) - **resultCode** (string) - وضعیت موفقیت‌آمیز عملیات #### Response Example [ { "resultCode": "Successful" } ] ``` -------------------------------- ### MyketIAB.querySkuDetails Source: https://myket.ir/kb/pages/%DB%8C%D9%88%D9%86%DB%8C%D8%AA%DB%8C-unity-%D8%A8%D8%A7-gradle Retrieves product details. ```APIDOC ## public static void querySkuDetails(string[] skus) ### Description Retrieves information such as price and title for products defined in the IAB panel. ### Parameters - **skus** (string[]) - Required - List of product IDs. ``` -------------------------------- ### حذف تنظیمات Gradle برای نسخه‌های قدیمی یونیتی Source: https://myket.ir/kb/pages/%DB%8C%D9%88%D9%86%DB%8C%D8%AA%DB%8C-unity-%D8%A8%D8%A7-gradle در صورت استفاده از Unity 2022.2 به قبل، این دو خط باید از فایل launcherTemplate.gradle حذف شوند. ```gradle namespace "**NAMESPACE**" ndkPath "**NDKPATH**" ``` -------------------------------- ### Project Directory Structure Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Required directory structure for custom plugins. ```text your-project/ └── plugins/ ``` -------------------------------- ### MyketIAB.queryInventory Source: https://myket.ir/kb/pages/%DB%8C%D9%88%D9%86%DB%8C%D8%AA%DB%8C-unity-%D8%A8%D8%A7-gradle Retrieves product information and unconsumed purchases. ```APIDOC ## public static void queryInventory(string[] skus) ### Description Retrieves details (price, title, etc.) for defined products and lists unconsumed purchases. It is recommended to call this at app startup. ### Parameters - **skus** (string[]) - Required - List of product IDs. ``` -------------------------------- ### Create withMarketPlace.js Plugin Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Implementation of the Expo config plugin to modify app/build.gradle. ```javascript const { withAppBuildGradle } = require('@expo/config-plugins'); const addMarketPlaceToGradle = (config, values) => {   return withAppBuildGradle(config, config => {     if (config.modResults.language === 'groovy') {       let gradleContent = config.modResults.contents;       const placeholdersString = `         manifestPlaceholders = [           marketApplicationId: "${values.marketApplicationId}",           marketBindAddress: "${values.marketBindAddress}",           marketPermission: "${values.marketPermission}"         ]       `;       const defaultConfigPattern = /defaultConfig\s*\{/;       if (!gradleContent.includes(placeholdersString)) {         gradleContent = gradleContent.replace(           defaultConfigPattern,           match => `${match}\n        ${placeholdersString}`         );       }       config.modResults.contents = gradleContent;     }     return config;   }); }; const withMarketPlace = (config, options = {}) => {   const { marketApplicationId, marketBindAddress, marketPermission } = options;   if (!marketApplicationId || !marketBindAddress || !marketPermission) {     throw new Error("withMarketPlace plugin requires all 3 values");   }   return addMarketPlaceToGradle(config, {     marketApplicationId,     marketBindAddress,     marketPermission   }); }; module.exports = withMarketPlace; ``` -------------------------------- ### فراخوانی متد queryInventoryAsync Source: https://myket.ir/kb/pages/java نحوه شروع فرایند به‌روزرسانی اطلاعات خرید با استفاده از IabHelper. در صورت وجود عملیات در حال اجرا، استثنای IabAsyncInProgressException پرتاب می‌شود. ```java try { mHelper.queryInventoryAsync(true, itemSkus, subSkus, mGotInventoryListener); } catch (IabAsyncInProgressException e) { Log.e(TAG, "Error querying inventory. Another async operation in progress."); } ``` -------------------------------- ### IabHelper.queryInventoryAsync(boolean, List, List, QueryInventoryFinishedListener) Source: https://myket.ir/kb/pages/java Initiates an asynchronous request to fetch inventory information, including purchase status and product details. ```APIDOC ## IabHelper.queryInventoryAsync ### Description Retrieves the user's purchase history and product details from the Myket service. This method is essential for verifying purchases and ensuring that consumable items are delivered to the user. ### Method Asynchronous SDK Method ### Parameters - **querySkuDetails** (boolean) - Required - Set to true to retrieve product details (name, price, etc.) from the developer panel. - **moreItemSkus** (List) - Optional - A list of product IDs to query. Pass null if there are no products to query. - **subSkus** (List) - Optional - A list of subscription product IDs to query. - **listener** (QueryInventoryFinishedListener) - Required - A callback interface to handle the result of the inventory query. ### Exceptions - **IabAsyncInProgressException** - Thrown if another asynchronous operation is already in progress. ### Callback Result - **IabResult result** - Contains the status of the request (success/failure). - **Inventory inventory** - Contains the retrieved purchase data (mPurchaseMap) and product details (mSkuMap). ``` -------------------------------- ### queryPurchaseProduct(querySkuDetails: Boolean, moreSku: String[]) Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Queries the inventory for purchased products and product details. It is recommended to call this after initialization. ```APIDOC ## queryPurchaseProduct(querySkuDetails: Boolean, moreSku: String[]) ### Description Retrieves a list of purchases and product details from the Myket service. ### Parameters - **querySkuDetails** (Boolean) - Required - Set to true to retrieve product details (SKU details). - **moreSku** (String[]) - Required - List of product IDs to query. ### Response - **Promise** - Returns an object containing 'all Purchases' (list of unconsumed purchases) and 'all Products' (if querySkuDetails is true). ``` -------------------------------- ### راه‌اندازی سرویس پرداخت و فراخوانی queryInventoryAsync Source: https://myket.ir/kb/pages/java این قطعه کد نحوه شروع به کار IabHelper و فراخوانی متد queryInventoryAsync را در متد startSetup نشان می‌دهد. ```java mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { Log.d(TAG, "Setup finished."); if (!result.isSuccess()) { // Oh noes, there was a problem. complain("Problem setting up in-app billing: " + result); return; } // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) return; Log.d(TAG, "Setup successful. Querying inventory."); try { mHelper.queryInventoryAsync(true, itemSkus, subSkus, mGotInventoryListener); } catch (IabAsyncInProgressException e) { complain("Error querying inventory. Another async operation in progress."); } } }); } ``` -------------------------------- ### تنظیمات پرداخت در build.gradle Source: https://myket.ir/kb/pages/java پیکربندی‌های لازم برای سرویس پرداخت را در بخش android فایل build.gradle اعمال کنید. ```gradle android { defaultConfig { def marketApplicationId = "ir.mservices.market" def marketBindAddress = "ir.mservices.market.InAppBillingService.BIND" manifestPlaceholders = [marketApplicationId: "${marketApplicationId}", marketBindAddress : "${marketBindAddress}", marketPermission : "${marketApplicationId}.BILLING"] buildConfigField "String", "IAB_PUBLIC_KEY", "\"{MYKET_PUBLIC_KEY}\"" } ... } ``` ```kotlin android { defaultConfig { val marketApplicationId = "ir.mservices.market" val marketBindAddress = "ir.mservices.market.InAppBillingService.BIND" manifestPlaceholders.apply { this["marketApplicationId"] = marketApplicationId this["marketBindAddress"] = marketBindAddress this["marketPermission"] = "${marketApplicationId}.BILLING" } buildConfigField( "String", "IAB_PUBLIC_KEY", "YOUR_KEY" ) } ... } ``` -------------------------------- ### POST /api/partners/applications/{PACKAGE_NAME}/products Source: https://myket.ir/kb/pages/manage-sku-items Creates a new in-app consumable product for a specific application. ```APIDOC ## POST /api/partners/applications/{PACKAGE_NAME}/products ### Description Creates a new in-app consumable product for the specified application package. ### Method POST ### Endpoint https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products ### Parameters #### Path Parameters - **PACKAGE_NAME** (string) - Required - The package name of the application (e.g., org.medrik.roosterwars). #### Request Body - **skuId** (string) - Required - Unique identifier for the product (max 100 characters). - **farsiTitle** (string) - Required - Persian title for the product (max 150 characters). - **price** (integer) - Required - Price of the product in Rials (minimum 1000). - **englishTitle** (string) - Optional - English title for the product (max 150 characters). - **isActive** (boolean) - Optional - Whether the product is active (default: false). ### Request Example { "skuId": "100GOLD2000", "farsiTitle": "صد طلا", "price": 20000, "englishTitle" : "100 Gold 2000 Tuman", "isActive": false } ### Response #### Success Response (200) - **code** (integer) - Status code. - **messageCode** (string) - Success message identifier. - **translatedMessage** (string) - Human-readable success message. #### Response Example { "code": 200, "messageCode": "Successful", "translatedMessage": "عملیات با موفقیت انجام شد." } ``` -------------------------------- ### Import Myket IAP Package Source: https://myket.ir/kb/pages/iab-flutter Import the package into your Dart class. ```dart import 'package:myket_iap/myket_iap.dart'; ``` -------------------------------- ### Implement Purchase Finished Listener Source: https://myket.ir/kb/pages/java Handles the callback triggered after a purchase attempt, providing the result and purchase details. ```java IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() { public void onIabPurchaseFinished(IabResult result, Purchase purchase) { Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase); // if we were disposed of in the meantime, quit. if (mHelper == null) return; if (result.isFailure()) { complain("Error purchasing: " + result); setWaitScreen(false); return; } Log.d(TAG, "Purchase successful."); // handling purchase } }; ``` -------------------------------- ### Query Inventory Source: https://myket.ir/kb/pages/iab-flutter Retrieve information about all products purchased by the user. ```dart Map result = await MyketIAP.queryInventory(querySkuDetails: false); ``` ```dart IabResult purchaseResult = result[MyketIAP.RESULT]; Inventory inventory = result[MyketIAP.INVENTORY]; ``` -------------------------------- ### myket://comment?id=[PACKAGE_NAME] Source: https://myket.ir/kb/pages/user-rate-comment-submission-intent The URI scheme used to launch the Myket comment submission screen for a specific application package. ```APIDOC ## Intent: myket://comment?id=[PACKAGE_NAME] ### Description This intent directs the user directly to the Myket application page to submit a rating and comment for the specified application. ### Parameters #### Path Parameters - **PACKAGE_NAME** (string) - Required - The unique package name of the application (e.g., ir.mservices.mybook). ### Usage Example ```java String url = "myket://comment?id=ir.mservices.mybook"; Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); ``` ``` -------------------------------- ### Implement Myket in Functional Components Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Use the useMyket hook to initialize and interact with the Myket billing service within functional components. ```javascript import {useMyket} from "iab-myket-reactnative/src/index"; function MyComponent() { const myketInstance = useMyket(myInAppBillingKey); // ... const someHandler = async () => { const inventory = await myketInstance.queryPurchaseProduct(true, productIds); console.log(JSON.JSON.stringify(inventory)); }; // … } ``` -------------------------------- ### Enable Logging Source: https://myket.ir/kb/pages/unity-with-gradle-fa Enables or disables internal library logs. Ensure this is set to false in Release builds. ```csharp public static void enableLogging(bool shouldEnable) ``` -------------------------------- ### enableDebugging(enableLogCat: Boolean) Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Enables or disables logging for the Myket billing module in LogCat. ```APIDOC ## enableDebugging(enableLogCat: Boolean) ### Description Enables or disables debug logs for the Myket module (tagged as 'IabHelper') in Android LogCat. ### Parameters - **enableLogCat** (Boolean) - Required - Set to true to enable logs, false to disable. ``` -------------------------------- ### queryInventoryAsync Source: https://myket.ir/kb/pages/java Retrieves the user's inventory of purchases. This method should be called upon application startup to ensure that all purchases are correctly synchronized and delivered to the user. ```APIDOC ## queryInventoryAsync ### Description Queries the user's inventory of in-app products and subscriptions. This is a critical operation to perform at application startup to prevent missing product deliveries. ### Method SDK Method Call ### Signature `mHelper.queryInventoryAsync(boolean querySkuDetails, List moreItemSkus, List moreSubSkus, QueryInventoryFinishedListener listener)` ### Parameters - **querySkuDetails** (boolean) - Whether to query details for the provided SKUs. - **moreItemSkus** (List) - List of product IDs to query. - **moreSubSkus** (List) - List of subscription IDs to query. - **listener** (QueryInventoryFinishedListener) - Callback listener to handle the result of the inventory query. ### Purchase Object Fields - **mItemType** (String) - Product type (inapp/subs) - **mOrderId** (String) - Purchase invoice number - **mPackageName** (String) - Application package name - **mSku** (String) - Product ID - **mPurchaseTime** (long) - Purchase timestamp - **mPurchaseState** (int) - Purchase state (consumed/unconsumed) - **mDeveloperPayload** (String) - Developer payload - **mToken** (String) - Purchase token - **mOriginalJson** (String) - Original JSON string from Myket server - **mSignature** (String) - Signature of the original JSON - **mIsAutoRenewing** (boolean) - Auto-renewal status ``` -------------------------------- ### Initialize IabHelper Source: https://myket.ir/kb/pages/in-app-purchase-implementation-steps Create an instance of IabHelper in your activity's onCreate method using your public key. ```java IabHelper mHelper; @Override public void onCreate(Bundle savedInstanceState) { // ... String base64EncodedPublicKey; // compute your public key and store it in base64EncodedPublicKey mHelper = new IabHelper(this, base64EncodedPublicKey); } ``` -------------------------------- ### MyketIAP.consume Source: https://myket.ir/kb/pages/iab-flutter Consumes a purchased product, allowing it to be purchased again. ```APIDOC ## MyketIAP.consume(purchase: Purchase) ### Description Sends a consumption request to Myket for a previously purchased item. ### Parameters - **purchase** (Purchase) - Required - The purchase object to consume. ``` -------------------------------- ### پیکربندی چند فروشگاهی با productFlavors Source: https://myket.ir/kb/pages/java برای پشتیبانی از چندین استور، از productFlavors در فایل build.gradle استفاده کنید. ```gradle android { flavorDimensions "store" productFlavors { myket { dimension "store" def marketApplicationId = "ir.mservices.market" def marketBindAddress ="ir.mservices.market.InAppBillingService.BIND" manifestPlaceholders = [marketApplicationId: "{marketApplicationId}", marketBindAddress: "${marketBindAddress}", marketPermission: "${marketApplicationId}.BILLING"] buildConfigField "String", "IAB_PUBLIC_KEY", “\"{MYKET_PUBLIC_KEY}\"" } otherMarket { dimension "store" def marketApplicationId = "{OTHER_MARKET_PACKAGE_NAME}" def marketBindAddress = "{OTHER_MARKET_BIND_ADDRESS}" manifestPlaceholders = [marketApplicationId: "${marketApplicationId}", marketBindAddress : "${marketBindAddress}", marketPermission : "{OTHER_MARKET_PERMISSION}"] buildConfigField "String", "IAB_PUBLIC_KEY", “\"{OTHER_MARKET_PUBLIC_KEY}\"" } } ... } ``` -------------------------------- ### Consume Products Source: https://myket.ir/kb/pages/unity-with-gradle-fa Consumes purchased products to allow them to be purchased again. ```csharp public static void consumeProduct(string sku) public static void consumeProducts(string[] skus) ``` -------------------------------- ### Verify package.json Dependency Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Ensure the dependency is correctly listed in your project's package.json file. ```json "dependencies": { "iab-myket-reactnative": "^1.0.16" } ``` -------------------------------- ### Declare Billing Permissions Source: https://myket.ir/kb/pages/unity-fa Add these permissions to the AndroidManifest.xml to enable internet access and Myket billing functionality. ```xml ``` -------------------------------- ### MyketIAB.consumeProduct Source: https://myket.ir/kb/pages/%DB%8C%D9%88%D9%86%DB%8C%D8%AA%DB%8C-unity-%D8%A8%D8%A7-gradle Consumes a purchased product. ```APIDOC ## public static void consumeProduct(string sku) ## public static void consumeProducts(string[] skus) ### Description Consumes a purchased product, removing it from the inventory so it can be purchased again. ### Parameters - **sku/skus** (string/string[]) - Required - The product ID or list of IDs to consume. ``` -------------------------------- ### MyketIAB.enableLogging Source: https://myket.ir/kb/pages/%DB%8C%D9%88%D9%86%DB%8C%D8%AA%DB%8C-unity-%D8%A8%D8%A7-gradle Enables or disables internal logging for the SDK. ```APIDOC ## public static void enableLogging(bool shouldEnable) ### Description Enables or disables logs for helper files. Ensure `shouldEnable` is set to `false` for Release builds. ### Parameters - **shouldEnable** (bool) - Required - Flag to enable or disable logging. ``` -------------------------------- ### Implement Myket in Class Components Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Connect and disconnect the Myket service within the lifecycle methods of a class component. ```javascript import myket from 'iab-myket-reactnative'; class App extends Component componentDidMount() { this.didMount = true; myket.connect(base64RSA).catch((error) => { /** * myket is not installed or RSA public key is null or empty */ this.log(error) }).then(this.retrieverProducts); } componentWillUnmount() { myket.disconnect().catch(() => this.log); } } ``` -------------------------------- ### Query Inventory Failed Event Source: https://myket.ir/kb/pages/unity-with-gradle-fa Triggered when retrieving product or purchase information fails. ```csharp public static event Action queryInventoryFailedEvent; ``` -------------------------------- ### consumeAsync(Purchase purchase, OnConsumeFinishedListener listener) Source: https://myket.ir/kb/pages/java Consumes a purchased product to allow the user to purchase it again. This is only applicable for consumable products. ```APIDOC ## consumeAsync(Purchase purchase, OnConsumeFinishedListener listener) ### Description Consumes a previously purchased product. This method is asynchronous and notifies the result via the provided listener. ### Parameters - **purchase** (Purchase) - The purchase object representing the item to be consumed. - **listener** (OnConsumeFinishedListener) - The callback to handle the result of the consumption operation. ### Exceptions - **IabAsyncInProgressException** - Thrown if another asynchronous operation is already in progress. ### Example ```java try { mHelper.consumeAsync(purchase, mConsumeFinishedListener); } catch (IabAsyncInProgressException e) { complain("Error consuming gas. Another async operation in progress."); } ``` ``` -------------------------------- ### MyketIAP.getPurchase Source: https://myket.ir/kb/pages/iab-flutter Retrieves the purchase status of a specific product. ```APIDOC ## MyketIAP.getPurchase(sku: String, querySkuDetails: bool) ### Description Checks the status of a specific product SKU. ### Parameters - **sku** (String) - Required - The product identifier. - **querySkuDetails** (bool) - Optional - If true, returns additional product details. ``` -------------------------------- ### PUT /api/partners/applications/{PACKAGE_NAME}/products/{SKU_ID} Source: https://myket.ir/kb/pages/manage-sku-items Updates the details of a specific in-app product for a given application. ```APIDOC ## [PUT] /api/partners/applications/{PACKAGE_NAME}/products/{SKU_ID} ### Description Updates an existing in-app product's details such as title, price, and active status. ### Method PUT ### Endpoint https://developer.myket.ir/api/partners/applications/{PACKAGE_NAME}/products/{SKU_ID} ### Parameters #### Path Parameters - **PACKAGE_NAME** (string) - Required - The package name of the application (e.g., org.medrik.roosterwars) - **SKU_ID** (string) - Required - The unique identifier of the in-app product (e.g., GEM2) #### Request Body - **farsiTitle** (string) - Optional - The new Persian title for the product (max 150 characters). - **price** (integer) - Optional - The new price in Rials (min 1000). - **englishTitle** (string) - Optional - The new English title for the product (max 150 characters). - **isActive** (boolean) - Optional - Whether the product is active or inactive. ### Request Example { "farsiTitle": "صد طلا", "price": 20000, "englishTitle" : "100 Gold 2000 Tuman", "isActive": false } ### Response #### Success Response (200) - **code** (integer) - Status code - **messageCode** (string) - Success message identifier - **translatedMessage** (string) - Human-readable success message #### Response Example { "code": 200, "messageCode": "Successful", "translatedMessage": "عملیات با موفقیت انجام شد." } ``` -------------------------------- ### Configure Billing Permission Source: https://myket.ir/kb/pages/in-app-purchase-implementation-steps Add this permission to your AndroidManifest.xml to enable communication with the Myket billing service. ```xml ``` -------------------------------- ### POST /api/partners/applications/{packageName}/release-bundle/commit Source: https://myket.ir/kb/pages/developer-cd Submits a previously uploaded release bundle for review by the administrator. ```APIDOC ## POST /api/partners/applications/{packageName}/release-bundle/commit ### Description Submits an uploaded release bundle for review. If isManualPublish is false, it publishes automatically after approval; if true, the developer must publish manually after approval. ### Method POST ### Endpoint https://developer.myket.i/apir/partners/applications/{packageName}/release-bundle/commit ### Parameters #### Path Parameters - **packageName** (string) - Required - The package name of the application. #### Request Body - **isManualPublish** (boolean) - Required - Determines if the app is published automatically or manually after approval. - **message** (string) - Optional - A message for the administrator regarding the review. ### Response #### Success Response (200) - **code** (integer) - Status code - **messageCode** (string) - Status message code - **translatedMessage** (string) - Human-readable success message #### Error Response (401) - Unauthorized access or insufficient permissions. ``` -------------------------------- ### پیکربندی productFlavors برای استورهای مختلف Source: https://myket.ir/kb/pages/java استفاده از productFlavors برای تعریف متغیرهای بیلد و جایگزینی مقادیر در فایل manifest برای استورهای متفاوت. ```gradle android { flavorDimensions "store" productFlavors { myket { dimension "store" def marketApplicationId = "ir.mservices.market" def marketBindAddress ="ir.mservices.market.InAppBillingService.BIND" manifestPlaceholders = [marketApplicationId: "{marketApplicationId}", marketBindAddress: "${marketBindAddress}", marketPermission: "${marketApplicationId}.BILLING"] buildConfigField "String", "IAB_PUBLIC_KEY", “"{MYKET_PUBLIC_KEY}"" } bazaar { dimension "store" def marketApplicationId = "com.farsitel.bazaar" def marketBindAddress = "ir.cafebazaar.pardakht.InAppBillingService.BIND" manifestPlaceholders = [marketApplicationId: "${marketApplicationId}", marketBindAddress : "${marketBindAddress}", marketPermission : "com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR"] buildConfigField "String", "IAB_PUBLIC_KEY", “\”{BAZAAR_PUBLIC_KEY}"" } } ... } ``` -------------------------------- ### Enable Debugging Logs Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native Toggle the visibility of Myket library logs in the Android LogCat output. ```javascript myket.enableDebugging(isEnable) ``` -------------------------------- ### وارد کردن ماژول MyketBillingModule Source: https://myket.ir/kb/pages/adding-inapp-purchase-in-react-native نحوه دسترسی به ماژول MyketBillingModule از طریق NativeModules در React Native. ```javascript import { NativeModules } from 'react-native'; const { MyketBillingModule} = NativeModules; ```