{"id":25216365,"url":"https://github.com/zarinpal/android-sdk-kotlin","last_synced_at":"2025-09-10T18:41:16.349Z","repository":{"id":275432870,"uuid":"926063072","full_name":"ZarinPal/Android-SDK-Kotlin","owner":"ZarinPal","description":"ZarinPal Android Client in-App Billing","archived":false,"fork":false,"pushed_at":"2025-08-25T09:53:28.000Z","size":444,"stargazers_count":2,"open_issues_count":12,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-25T11:45:51.530Z","etag":null,"topics":["android","android-library","androidlibrary"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZarinPal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-02T13:15:57.000Z","updated_at":"2025-08-25T09:50:12.000Z","dependencies_parsed_at":"2025-08-25T11:19:50.705Z","dependency_job_id":"deb3b75d-ff56-429e-8f42-ee47ef0e5fcb","html_url":"https://github.com/ZarinPal/Android-SDK-Kotlin","commit_stats":null,"previous_names":["zarinpal/android-sdk-kotlin"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ZarinPal/Android-SDK-Kotlin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZarinPal%2FAndroid-SDK-Kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZarinPal%2FAndroid-SDK-Kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZarinPal%2FAndroid-SDK-Kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZarinPal%2FAndroid-SDK-Kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZarinPal","download_url":"https://codeload.github.com/ZarinPal/Android-SDK-Kotlin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZarinPal%2FAndroid-SDK-Kotlin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274506608,"owners_count":25298539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","androidlibrary"],"created_at":"2025-02-10T19:17:50.554Z","updated_at":"2025-09-10T18:41:16.340Z","avatar_url":"https://github.com/ZarinPal.png","language":"Java","readme":"ZarinPal In App Billing - Purchase SDK | MPG\n============================================\nZarinPal Purchase SDK Provides payment methods on your Android Application.\n[پارسی](https://www.zarinpal.com/docs/sdk/android/installation.html)\n\n\nIntroduction\n=============\nZarinPal in-app purchases are the simplest solution to selling digital products or content on Android apps. So many app developers who want to sell digital goods or offer premium membership to users can simply use the it, in-app billing process for smooth and easy checkouts.\n\n\n\u003cp align=\"center\" width=\"100%\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/alirezabashi98/zarinpal-sdk/main/new_logo.svg\" alt=\"sample\" width=\"300\" height=\"100\"/\u003e\n\u003c/p\u003e\n\n\nRequirements\n============\n\n*   Android 7.0 (API level 24) and above\n\nInstallation\n============\n\n**Step 1**\n\nAdd this to your root settings.gradle at the end of repositories.\n```gradle\n    dependencyResolutionManagement {\n    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n    repositories {\n        ...\n        maven { url = uri(\"https://jitpack.io\") }\n        }\n    }\n```    \n\n**Step 2**\n\nAdd the dependency:\n```gradle\n    dependencies {\n        implementation(\"com.github.ZarinPal:Android-SDK-Kotlin:v.1.1.2\")\n    }\n```\n\nHow to use\n==========\n\n*   add Permissions in your `Manifest.xml`:\n```xml\n   \u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e\n```    \n\nInitialize the billing client\n=============================\n\n**Step 1**\n* To start using the SDK, you need to configure the settings for `merchant_id` and `sandbox`. These settings allow you to use the SDK in either sandbox (testing) or live mode. In certain specific cases, such as refunds or transaction management, you may also need an `access_token`.\n```kotlin\nimport com.example.zarinpal.ZarinPal\nimport com.example.zarinpal.data.remote.dto.Config\n\nval zarinPal = ZarinPal(\n    Config(\n        merchantId = \"your-merchant-id\",\n        packageName = \"your.package.name\",//required parameter\n        token = \"your-access-token\",\n        sandBox = true\n    )\n)\n```    \n\n**Step 2 - Payment Request**\n* The `createPayment` method allows you to create a new payment request and redirect the user to the payment gateway. This method is used to send payment-related information and receive an `authority` to guide the user to the payment page.\n```kotlin\nimport com.example.zarinpal.ZarinPal\nimport com.example.zarinpal.data.remote.dto.create.CreatePaymentDataResponse\nimport com.example.zarinpal.data.remote.dto.create.CreatePaymentRequest\n\nval request = CreatePaymentRequest(\n    amount = 20000,\n    callbackUrl = \"https://yourwebsite.com/callback\",\n    description = \"test\"\n)\n\nCoroutineScope(Dispatchers.IO).launch {\n    try{\n        val response =\n            zarinPal.createPayment(request, redirectUrl = {  paymentGatewayUri, status -\u003e\n                if (status == 100)\n                    Log.v(\"ZP_Log\",paymentGatewayUri)\n            })\n        Log.v(\"ZP_Log\",\"$response\")\n    } catch (ex: Exception) {\n        ex.printStackTrace()\n    }\n}\n```    \n\n**Payment Verification**\n* The `paymentVerify` method allows you to check and verify the transaction status after the user returns from the payment gateway. Using this method, you can validate the payment details and confirm the transaction if the payment was successful.\n```kotlin\nimport com.example.zarinpal.ZarinPal\nimport com.example.zarinpal.data.remote.dto.verification.PaymentVerificationDataResponse\nimport com.example.zarinpal.data.remote.dto.verification.PaymentVerifyRequest\n\nval request = PaymentVerifyRequest(\n    amount = amount,\n    authority = \"your authority\"\n)\n\nCoroutineScope(Dispatchers.IO).launch {\n    try{\n        val response = zarinPal.paymentVerify(request)\n        Log.v(\"ZP_Log\",\"$response\")\n    } catch (ex: Exception) {\n        ex.printStackTrace()\n    }\n}\n```   \n\n**Transaction Inquiry**\n* The `paymentInquiry` method allows you to check and inquire about the status of a transaction. This method is used when you want to obtain more detailed information about the transaction status after creating a payment request or confirming a payment.\n```kotlin\nimport com.example.zarinpal.ZarinPal\nimport com.example.zarinpal.data.remote.dto.inquiry.PaymentInquiryDataResponse\nimport com.example.zarinpal.data.remote.dto.inquiry.PaymentInquiryRequest\n\nval request = PaymentInquiryRequest(authority = \"authority\")\n\nCoroutineScope(Dispatchers.IO).launch {\n    try{\n        val response = zarinPal.paymentInquiry(request)\n        Log.v(\"ZP_Log\",\"$response\")\n    } catch (ex: Exception) {\n        ex.printStackTrace()\n    }\n}\n```  \n\n**Inquiry of Unverified Transactions**\n\n* The method for inquiring unverified transactions allows you to retrieve a list of unverified transactions from the payment gateway. This method can be used to review transactions whose status has not yet been determined.\n\n```kotlin\nimport com.example.zarinpal.ZarinPal\nimport com.example.zarinpal.data.remote.dto.unVerified.PaymentUnVerifiedDataResponse\nimport com.example.zarinpal.data.remote.dto.unVerified.PaymentUnVerifiedRequest\nimport com.example.zarinpal.data.remote.dto.Config\n\nval zarinPal = ZarinPal(\n    Config(\n        merchantId = \"your-merchant-id\",\n    )\n)\n\nCoroutineScope(Dispatchers.IO).launch {\n    try{\n        val response = zarinPal.paymentUnVerified()\n        Log.v(\"ZP_Log\",\"$response\")\n    } catch (ex: Exception) {\n        ex.printStackTrace()\n    }\n}\n```   \n\n**Transaction Reversal**\n\n* The `transactionReversal` method allows you to reverse successful transactions that occurred within 30 minutes of the payment, refunding the amount to the buyer's account without any fees.\n* To use this service, your server's IP must be configured for the payment gateway. Otherwise, you will encounter error 62-.\n\n```kotlin\nimport com.example.zarinpal.ZarinPal\nimport com.example.zarinpal.data.remote.dto.Config\nimport com.example.zarinpal.data.remote.dto.reverse.PaymentReverseDataResponse\nimport com.example.zarinpal.data.remote.dto.reverse.PaymentReverseRequest\n\nval zarinPal = ZarinPal(\n    Config(\n        merchantId = \"your-merchant-id\",\n    )\n)\n\n\nCoroutineScope(Dispatchers.IO).launch {\n    try{\n        val request = PaymentReverseRequest(\n            authority = \"authority\"\n        )\n        val response = zarinPal.paymentReverse(request)\n        Log.v(\"ZP_Log\",\"$response\")\n    } catch (ex: Exception) {\n        ex.printStackTrace()\n    }\n}\n```    \n\n**Refund**\n\n* The `refund` method allows you to instantly or in batch cycles refund the full amount or a part of it to the buyer's account in case of order changes or cancellations, incorrect payments, or any other requirement to return the funds.\n\n```kotlin\nimport com.example.zarinpal.ZarinPal\nimport com.example.zarinpal.data.remote.dto.Config\nimport com.example.zarinpal.data.remote.dto.reverse.PaymentReverseDataResponse\nimport com.example.zarinpal.data.remote.dto.reverse.PaymentReverseRequest\n\nval zarinPal = ZarinPal(\n    Config(\n        merchantId = \"your-merchant-id\",\n    )\n)\n\n\nCoroutineScope(Dispatchers.IO).launch {\n    try{\n        val request = PaymentReverseRequest(\n            authority = \"authority\"\n        )\n        val response = zarinPal.paymentReverse(request)\n        Log.v(\"ZP_Log\",\"$response\")\n    } catch (ex: Exception) {\n        ex.printStackTrace()\n    }\n}\n```  \n\n**Transaction List**\n\n* The `transactionList` method allows you to retrieve all transactions related to a specific terminal. This method can be used to view the status of transactions and filter them.\n\n```kotlin\nimport com.example.zarinpal.ZarinPal\nimport com.example.zarinpal.data.remote.dto.Config\nimport com.example.zarinpal.ZarinPal\nimport com.example.zarinpal.data.remote.dto.transaction.Session\nimport com.example.zarinpal.data.remote.dto.transaction.TransactionRequest\nimport com.example.zarinpal.data.remote.enum.FilterEnum\n\nval zarinPal = ZarinPal(\n    Config(\n        token = \"your-access-token\",\n    )\n)\n\nCoroutineScope(Dispatchers.IO).launch {\n    try{\n        val request = TransactionRequest(\n            terminalId = textFieldTerminalId.text,\n            filter = FilterEnum.ALL,\n            limit = 25,\n            offset = 0\n        )\n        val response = zarinPal.getTransactions(request)\n        Log.v(\"ZP_Log\",\"$response\")\n    } catch (ex: Exception) {\n        ex.printStackTrace()\n    }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzarinpal%2Fandroid-sdk-kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzarinpal%2Fandroid-sdk-kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzarinpal%2Fandroid-sdk-kotlin/lists"}