Skip to content

Commit

Permalink
Merge pull request #27 from cafebazaar/dev
Browse files Browse the repository at this point in the history
Update Readme to version 4.0.0
  • Loading branch information
hamidrezasahraei authored Apr 8, 2023
2 parents 8fb16fd + 3c0a16e commit 887d651
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.Context
import android.content.Intent
import androidx.activity.result.contract.ActivityResultContract
import ir.cafebazaar.bazaarpay.arg.BazaarPayActivityArgs
import kotlinx.coroutines.flow.flow

/**
* An [ActivityResultContract] to start a payment.
Expand Down
89 changes: 76 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
## BazaarPay Android SDK

This document aims to help you to integrate the *BazaarPay* android SDK within your application. For
the topics out of this scope, read the corresponding documents.
<img width="600" alt="Logo" src="https://bazaar-pay.ir/wp-content/uploads/2022/12/01.svg">

[![Download](https://img.shields.io/jitpack/version/com.github.cafebazaar/bazaarpay)](https://jitpack.io/#cafebazaar/bazaarpay)
[![GitHub licence](https://img.shields.io/github/license/cafebazaar/BazaarPay)](https://www.apache.org/licenses/LICENSE-2.0)

BazaarPay is an all-in-one digital payment service that provides innovative payment solutions,
including [Direct debit](https://en.wikipedia.org/wiki/Direct_debit)
, [E-wallet](https://en.wikipedia.org/wiki/Digital_wallet),
and [BNPL](https://en.wikipedia.org/wiki/Buy_now,_pay_later). Our goal is to simplify money
management and help businesses increase sales.

This project is the SDK for integrating BazaarPay within your Android applications. For additional
information about BazaarPay, please visit our [website](https://bazaarpay.ir/).

### Requirements

Expand All @@ -11,28 +22,65 @@ the topics out of this scope, read the corresponding documents.

## Setup

`BazaarPay` is available through the JitPack repository. You can declare this repository in your
project `build.gradle` file:
### Configure the repositories

`BazaarPay` is available through the *JitPack* repository. You can declare this repository in your
build script as follows:

<details open>
<summary>Kotlin DSL</summary>

```kotlin
repositories {
maven { url = uri("https://jitpack.io") }
}
```

</details>

<details>
<summary>Groovy DSL</summary>

```groovy
repositories {
maven { url 'https://jitpack.io' }
}
```

Add the dependency to your module `build.gradle` file:
</details>

### Add the dependency

After repository configuration, add a dependency on BazaarPay to your module's `build.gradle`
file:

<details open>
<summary>Kotlin DSL</summary>

```kotlin
dependencies {
implementation("com.github.cafebazaar:bazaarpay:4.0.0")
}
```

</details>

<details>
<summary>Groovy DSL</summary>

```groovy
dependencies {
implementation 'com.github.cafebazaar:bazaarpay:[latest_version]'
implementation 'com.github.cafebazaar:bazaarpay:4.0.0'
}
```

</details>

## Usage

### 1. Register Payment Callback

*BazaarPay* uses
BazaarPay uses
the [Activity Result API](https://developer.android.com/training/basics/intents/result). Register
the payment callback by calling the `registerForActivityResult` with an instance
of `StartBazaarPay` as its `contract` parameter. The callback provides you with a boolean that
Expand Down Expand Up @@ -66,18 +114,16 @@ bazaarPayLauncher.launch(options)
you [generated before](#requirements). But there are also other optional parameters that you can
configure to your needs:

* `phoneNumber` - the default phone number to pre-fill the login screen's input field. It uses a
null value by default, resulting in no pre-filled input.
* `isInDarkMode` - enables Dark Mode for the UI elements of the payment flow, which are in Light Mode
by default.
* `phoneNumber` - pre-fills the input field of the login screen with this number.
* `isInDarkMode` - enables Dark Mode for the UI elements of the payment flow.

### 3. Commit Checkout Token

You have to commit the *Checkout Token* after successful payment. There is a suspend `commit()`
function for this purpose that you can call from a coroutine scope:

```kotlin
// Inside onSuccess callback of launchBazaarPay
// Inside isSuccessful branch of the registered payment callback
myScope.launch {
commit(
checkoutToken = "CHECKOUT_TOKEN",
Expand All @@ -93,4 +139,21 @@ call it from a [WorkManager](https://developer.android.com/topic/libraries/archi
worker or a Service for safety reasons.

> Although sending tokens through the SDK is possible, we recommend this happens on the server
> side.
> side.
License
--------

Copyright 2022 Cafebazaar, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

0 comments on commit 887d651

Please sign in to comment.