Skip to content

update sample android to last version #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 51 additions & 53 deletions README _JAVA.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,71 @@
ZarinPal In App Billing - Purchase SDK | MPG
============================================
ZarinPal Purchase SDK Provides payment methods on your Android Application.
# ZarinPal In App Billing - Purchase SDK | MPG

ZarinPal Purchase SDK Provides payment methods on your Android Application.

# Introduction

Introduction
=============
ZarinPal 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.


<p align="center" width="100%">
<img src="https://raw.githubusercontent.com/ZarinPal/Android-SDK/master/logo%20%E2%80%93%201.png" alt="sample" width="300" height="100"/>
</p>

# Requirements

Requirements
============

* Android 5.0 (API level 21) and above
* Android Gradle Plugin 3.5.1
* Gradle 5.4.1+
* AndroidX (as of v11.0.0)
- Android 5.0 (API level 21) and above
- Android Gradle Plugin 3.5.1 and above(this 8.1.4)
- Gradle 5.4.1 and above (this 8.5)
- AndroidX (as of v11.0.0)

Installation
============
# Installation

**Step 1**

Add this to your root build.gradle at the end of repositories.

```gradle
allprojects {
ext.zarinpalSdkVersion = (LATEST_VERSION_REALEASE) //inform of Releases: https://github.com/ZarinPal/Android-SDK/releases
repositories {
...
mavenCentral()
}
```
```

**Step 2**

Add the dependency:

```gradle
dependencies {
implementation 'com.zarinpal:payment-provider:ext.zarinpalSdkVersion'
}
```

```

If your project and business trusted to ZarinPal, SDK ables to providing **Mobile Payment Gateway** on your App so You should add the **MPG** dependency:

```gradle
dependencies {
implementation 'com.zarinpal:payment-provider:ext.zarinpalSdkVersion'
implementation 'com.zarinpal:mpg:ext.zarinpalSdkVersion'
}
```
```

How to use
==========
# How to use

- add Permissions in your `Manifest.xml`:

* add Permissions in your `Manifest.xml`:
```xml
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
```
```

Initialize the billing client
=============================
# Initialize the billing client

**Step 1**

* `ZarinPalClientBilling` provides to create the billing client instance:
- `ZarinPalClientBilling` provides to create the billing client instance:

```java

BillingClientStateListener listener = new BillingClientStateListener() {
Expand All @@ -92,30 +88,30 @@ Initialize the billing client
.setNightMode(AppCompatDelegate.MODE_NIGHT_YES)
.build();

```

```

**Step 2**

For start purchase you need a `Purchase` instance, `Purchase` has 3 type of Payment:

* as **Payment Request** by `asPaymentRequest()`
* as **Authority ID** by `asAuthority()`
* as **Sku ID** by `asSku()`
- as **Payment Request** by `asPaymentRequest()`
- as **Authority ID** by `asAuthority()`
- as **Sku ID** by `asSku()`

If you would create payment Authority on Client, You must use `asPayementRequest()`, this method needs below parameters:

**Require Parameters:**

* Merchant id: An unique ID of your business payment gateway.
* Amount: Amount of Purchase.
* Callback URL: A valid `URI` or `URL` Address for sending result purchase.
* Description: A Content for showing payer.
- Merchant id: An unique ID of your business payment gateway.
- Amount: Amount of Purchase.
- Callback URL: A valid `URI` or `URL` Address for sending result purchase.
- Description: A Content for showing payer.

**Optional Parameters:**

* Mobile: Valid Mobile number of payer.
* Email: Valid Email Address of payer.
- Mobile: Valid Mobile number of payer.
- Email: Valid Email Address of payer.

```java
Purchase purchase = Purchase.newBuilder().asPaymentRequest(
Expand All @@ -124,15 +120,18 @@ If you would create payment Authority on Client, You must use `asPayementRequest
"http:\\YOUR_SEVER_URL.com",
"1000IRR Purchase"
).build();
```
```

Maybe You had `Authority`, here You must use `asAuthority()`

```java
Purchase purchase = Purchase.newBuilder()
.asAuthority("AUTHORITY_RESOLVED")
.build();
```
```

for `Sku` purchase:

```java
Purchase purchase = Purchase.newBuilder()
.asSku("SKU_ID") // SKU_ID is an Id that you've generated on ZarinPal panel.
Expand All @@ -142,6 +141,7 @@ for `Sku` purchase:
**Step 3**

You must call `purchase` method to begin flow payment:

```java
client.launchBillingFlow(purchase, new FutureCompletionListener<Receipt>() {
@Override
Expand All @@ -158,22 +158,22 @@ You must call `purchase` method to begin flow payment:
}
}
});
```
```

**Step 4**

Finally if your eligible to have payment process through **MPG** You should adding `usesCleartextTraffic` to application tag in your `Manifest.xml`

```xml

<application
android:name="..."
android:usesCleartextTraffic="true"
....
\>
```
```

SKU Query
=========
# SKU Query

The ZarinPal Library stores the query results in a List of SkuPurchased objects. You can then call `querySkuPurchased` and you appear sku purchased with inforamtion in your view and provide service.

Expand All @@ -183,8 +183,8 @@ The ZarinPal Library stores the query results in a List of SkuPurchased objects.
.setSkuList(skus)
.orderByMobile("0935******")
.build();


client.querySkuPurchased(skuQuery, new FutureCompletionListener<List<SkuPurchased>>() {
@Override
public void onComplete(TaskResult<List<SkuPurchased>> task) {
Expand All @@ -198,20 +198,18 @@ The ZarinPal Library stores the query results in a List of SkuPurchased objects.
}
}
});
````
```

Features
========
# Features

**Dark Mode**

```java
client.setNightMode(AppCompatDelegate.MODE_NIGHT_YES)
```
```

**Appear Invoice**

```java
client.enableShowInvoice()
```

```
Loading