{"id":18750735,"url":"https://github.com/cafebazaar/bazaarpay","last_synced_at":"2026-03-01T04:37:15.008Z","repository":{"id":62928835,"uuid":"489705723","full_name":"cafebazaar/BazaarPay","owner":"cafebazaar","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-27T10:31:49.000Z","size":1377,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-09-27T12:18:57.632Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://bazaarpay.ir","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cafebazaar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-05-07T15:05:46.000Z","updated_at":"2025-09-27T10:30:01.000Z","dependencies_parsed_at":"2023-02-14T00:45:22.434Z","dependency_job_id":"fccd9b90-e245-4d3a-924b-4eed98d88e6d","html_url":"https://github.com/cafebazaar/BazaarPay","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/cafebazaar/BazaarPay","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2FBazaarPay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2FBazaarPay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2FBazaarPay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2FBazaarPay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cafebazaar","download_url":"https://codeload.github.com/cafebazaar/BazaarPay/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2FBazaarPay/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29960253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"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":[],"created_at":"2024-11-07T17:12:56.247Z","updated_at":"2026-03-01T04:37:14.999Z","avatar_url":"https://github.com/cafebazaar.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"## BazaarPay Android SDK\n\n\u003cimg width=\"600\" alt=\"Logo\" src=\"https://bazaar-pay.ir/wp-content/uploads/2022/12/01.svg\"\u003e\n\n[![Download](https://img.shields.io/jitpack/version/com.github.cafebazaar/bazaarpay)](https://jitpack.io/#cafebazaar/bazaarpay)\n[![GitHub licence](https://img.shields.io/github/license/cafebazaar/BazaarPay)](https://www.apache.org/licenses/LICENSE-2.0)\n\nBazaarPay is an all-in-one digital payment service that provides innovative payment solutions,\nincluding [Direct debit](https://en.wikipedia.org/wiki/Direct_debit)\n, [E-wallet](https://en.wikipedia.org/wiki/Digital_wallet),\nand [BNPL](https://en.wikipedia.org/wiki/Buy_now,_pay_later). Our goal is to simplify money\nmanagement and help businesses increase sales.\n\nThis project is the SDK for integrating BazaarPay within your Android applications. For additional\ninformation about BazaarPay, please visit our [website](https://bazaarpay.ir/).\n\n### Requirements\n\n- The SDK requires Android 4.2 (API level 17) or higher.\n- You need a *Checkout Token* or a *PaymentURL* before starting a payment. *Checkout Token* is a\n  unique identifier that provides\n  essential payment information. Check out [this]() documentation on how to generate one.\n\n## Setup\n\n### Configure the repositories\n\n`BazaarPay` is available through the *JitPack* repository. You can declare this repository in your\nbuild script as follows:\n\n\u003cdetails open\u003e\n\u003csummary\u003eKotlin DSL\u003c/summary\u003e\n\n```kotlin\nrepositories {\n    maven { url = uri(\"https://jitpack.io\") }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eGroovy DSL\u003c/summary\u003e\n\n```groovy\nrepositories {\n    maven { url 'https://jitpack.io' }\n}\n```\n\n\u003c/details\u003e\n\n### Add the dependency\n\nAfter repository configuration, add a dependency on BazaarPay to your module's `build.gradle`\nfile:\n\n\u003cdetails open\u003e\n\u003csummary\u003eKotlin DSL\u003c/summary\u003e\n\n```kotlin\ndependencies {\n    implementation(\"com.github.cafebazaar:bazaarpay:5.3.6\")\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eGroovy DSL\u003c/summary\u003e\n\n```groovy\ndependencies {\n    implementation 'com.github.cafebazaar:bazaarpay:5.3.6'\n}\n```\n\n\u003c/details\u003e\n\n## Usage\n\n### 1. Register Payment Callback\n\nBazaarPay uses\nthe [Activity Result API](https://developer.android.com/training/basics/intents/result). Register\nthe payment callback by calling the `registerForActivityResult` with an instance\nof `StartBazaarPay` as its `contract` parameter. The callback provides you with a boolean that\nindicates whether the payment was successful or not:\n\n```kotlin\nval bazaarPayLauncher = registerForActivityResult(StartBazaarPay()) { isSuccessful -\u003e\n    if (isSuccessful) {\n        // A successful payment.\n    } else {\n        // An unsuccessful payment (Canceled by the user).\n    }\n}\n```\n\nThe happy path of this `if` statement is the place you need to [commit](#3-commit-paymentURL)\nthe *paymentURL*.\n\n### 2. Launch Payment\n\nRegistering the payment callback will return a payment launcher instance. You can start a payment\nflow by calling the `launch()` function on the payment launcher. It takes an instance of\nthe `BazaarPayOptions` as its parameter:\n\n```kotlin\nval options = BazaarPayOptions\n    .paymentUrl(paymentURL = paymentURL)\n    .authToken(authToken = AUTO_LOGIN_TOKEN) //optional (autoLogin)\n    .build()\nbazaarPayLauncher.launch(options)\n```\n\n`BazaarPayOptions` has a mandatory `paymentURL` parameter which is the URL\nyou [generated before](#requirements). But there are also other optional parameters that you can\nconfigure to your needs:\n\n* `phoneNumber` - pre-fills the input field of the login screen with this number.\n* `authToken` - Optional input for autoLogin\n\n### 3. Commit paymentURL\n\nYou have to commit the *Payment URL* after successful payment. There is a suspend `commit()`\nfunction for this purpose that you can call from a coroutine scope:\n\n```kotlin\n// Inside isSuccessful branch of the registered payment callback\nmyScope.launch {\n    commit(\n        paymentURL = \"PAYMENT_URL\",\n        context = requireContext(),\n        onSuccess = { },\n        onFailure = { }\n    )\n}\n```\n\nOtherwise, if you are using other technologies, you need to implement this yourself. It is better to\ncall it from a [WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager)\nworker or a Service for safety reasons.\n\n\u003e Although sending tokens through the SDK is possible, we recommend this happens on the server\n\u003e side.\n\n# DirectPay Contract\n\nDirectPay is a feature that enables direct payment from the merchant without user intervention,\nparticularly useful for cases like automatic subscription renewal. You can find more information\nabout DirectPay [here](https://github.com/BazaarPay/Docs/blob/main/persian/DirectPay.md).\n\nThis SDK allows you to obtain permission from the user for DirectPay. We will explain more about it\nbelow. First, let's register the contract callback.\n\n```kotlin\nval bazaarPayDirectPayContractLauncher = registerForActivityResult(\n    StartDirectPayFinalizeContract()\n) { isSuccessful -\u003e\n    if (isSuccessful) {\n        // A successful directPay contract.\n    } else {\n        // An unsuccessful directPay contract (or canceled by the user).\n    }\n}\n```\n\n\u003e To provide a better user experience, please display appropriate messages to users in both\n\u003e successful and unsuccessful scenarios, informing them of the outcome.\n\n## Launch DirectPayContract\n\nTo initiate a payment flow, you can call the `launch()` function on the directPayContract launcher.\nIt\nrequires an instance of `DirectPayContractOptions` as its parameter:\n\n```kotlin\n val options = DirectPayContractOptions(\n    contractToken = contractToken,\n    message = message, //optional\n    phoneNumber = phone, //optional\n    authToken = AUTO_LOGIN_TOKEN //optional (autoLogin)\n)\nbazaarPayDirectPayContractLauncher.launch(options)\n```\n\n# BazaarPay Login API\n\nSome functionalities in BazaarPay like getBalance, need BazaarPay login (in case you don't want to\nuse autoLogin), for login in BazaarPay you\nneed to make a login launcher:\n\n```kotlin\nval bazaarPayLoginLauncher = registerForActivityResult(StartLogin()) { isSuccessful -\u003e\n    if (isSuccessful) {\n        // A successful login.\n    } else {\n        // An unsuccessful login.\n    }\n}\n```\n\nAnd then `launch()` the `bazaarPayLoginLauncher` like below:\n\n```kotlin\n val options = BazaarPayLoginOptions(phoneNumber = phone)\nbazaarPayLoginLauncher.launch(options)\n```\n\n# BazaarPay Balance\n\nYou can get user's balance from BazaarPay. There is a suspend `getBazaarPayBalance()`\nfunction for this purpose that you can call from a coroutine scope:\n\n```kotlin\nmyScope.launch {\n    getBazaarPayBalance(\n        context = requireContext(),\n        authToken = AUTO_LOGIN_TOKEN, //optional\n        onSuccess = { },\n        onFailure = { },\n        onLoginNeeded = {\n            // here you should use BazaarPay Login API, or use autoLogin\n        }\n    )\n}\n```\n\n\u003e authToken is an optional parameter that helps you get user balance without login\n\n# Open increase balance screen directly\n\nYou can open increase balance screen directly and get the result like below:\n\n```kotlin\n val bazaarPayIncreaseBalanceLauncher = registerForActivityResult(StartIncreaseBalance()) { isSuccessful -\u003e\n    if (isSuccessful) {\n        // A successful increase balance.\n    } else {\n        // An unsuccessful increase balance.\n    }\n}\n```\n\nAnd then `launch()` the `bazaarPayIncreaseBalanceLauncher` like below:\n\n```kotlin\n val options = IncreaseBalanceOptions(\n    authToken = AUTO_LOGIN_TOKEN, //optional \n)\nbazaarPayIncreaseBalanceLauncher.launch(options)\n```\n\nLicense\n--------\n\n    Copyright 2022 Cafebazaar, Inc.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafebazaar%2Fbazaarpay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcafebazaar%2Fbazaarpay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafebazaar%2Fbazaarpay/lists"}