Skip to content

Commit

Permalink
Merge pull request #1 from showdpro/version4Update
Browse files Browse the repository at this point in the history
Version4 update
  • Loading branch information
tushar09 authored Aug 6, 2021
2 parents 23b7022 + 303dc35 commit 7d4ef44
Show file tree
Hide file tree
Showing 47 changed files with 1,378 additions and 1,138 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified CHANGELOG.md
100644 → 100755
Empty file.
Empty file modified ISSUE_TEMPLATE.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
15 changes: 11 additions & 4 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Android In-App Billing v3 Library [![Build Status](https://travis-ci.org/anjlab/android-inapp-billing-v3.svg?branch=master)](https://travis-ci.org/anjlab/android-inapp-billing-v3) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.anjlab.android.iab.v3/library/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.anjlab.android.iab.v3/library)
# Android In-App Billing v4 Library [![Build Status](https://travis-ci.org/anjlab/android-inapp-billing-v3.svg?branch=master)](https://travis-ci.org/anjlab/android-inapp-billing-v3) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.anjlab.android.iab.v3/library/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.anjlab.android.iab.v3/library)

This is a simple, straight-forward implementation of the Android v3 In-app billing API.
This is a simple, straight-forward implementation of the Android v4 In-app billing API.

It supports: In-App Product Purchases (both non-consumable and consumable) and Subscriptions.

Expand Down Expand Up @@ -45,8 +45,9 @@ public class SomeActivity extends Activity implements BillingProcessor.IBillingH
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

bp = new BillingProcessor(this, "YOUR LICENSE KEY FROM GOOGLE PLAY CONSOLE HERE", this);
bp.initialize();
bp = new BillingProcessor(this,LICENSE_KEY,MERCHANT_ID,this);
bp.connect(this); //Connection required based on google Version 4 for inapp lib
bp.initialize(); //Bind to playstore with history check
// or bp = BillingProcessor.newBillingProcessor(this, "YOUR LICENSE KEY FROM GOOGLE PLAY CONSOLE HERE", this);
// See below on why this is a useful alternative
}
Expand Down Expand Up @@ -88,6 +89,7 @@ public class SomeActivity extends Activity implements BillingProcessor.IBillingH
```

* override Activity's onActivityResult method:

```java
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Expand All @@ -96,6 +98,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}
```
The data obtained from the onActivityResult are the purchase JsonData and the purchase Signature.
For those interested in further payment checks, you can save the order purchaseToken (unique for all order) to you server and retrieve the token
to validate the order before offering value to app users. This token can be obtained from data and saved to your server.

* Call `purchase` method for a BillingProcessor instance to initiate purchase or `subscribe` to initiate a subscription:

Expand Down Expand Up @@ -142,8 +147,10 @@ public void onDestroy() {
The basic `new BillingProcessor(...)` actually binds to Play Services inside the constructor. This can, very rarely, lead to a race condition where Play Services are bound and `onBillingInitialized()` is called before the constructor finishes, and can lead to NPEs. To avoid this, we have the following:
```java
bp = BillingProcessor.newBillingProcessor(this, "YOUR LICENSE KEY FROM GOOGLE PLAY CONSOLE HERE", this); // doesn't bind
bp.connect(this); //Connection required based on google Version 4 for inapp lib
bp.initialize(); // binds
```
In addition to the above, the current in-app billing requires the initialization and connection to the play services, this form the most significant part of the implementation of this library.

## Testing In-app Billing

Expand Down
Empty file modified UPGRADING.md
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.7.0'
}
}
Expand All @@ -32,7 +32,7 @@ allprojects {
java {
srcDir 'src'
exclude 'com/anjlab/android/iab/v3/Security.java'
exclude 'com/android/vending/billing/IInAppBillingService.aidl'
exclude 'com/android/billingclient/api'
}
}
}
Expand Down
Empty file modified checkstyle.xml
100644 → 100755
Empty file.
Empty file modified gradle/wrapper/gradle-wrapper.jar
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jul 16 09:35:53 MSK 2019
#Sun Jul 11 10:16:56 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
180 changes: 90 additions & 90 deletions gradlew.bat
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windowz variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windowz variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
29 changes: 15 additions & 14 deletions library/build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ apply plugin: 'signing'
apply plugin: 'checkstyle'

group 'com.anjlab.android.iab.v3'
version '1.1.0'
version '1.2.0'

android {
compileSdkVersion 26
buildToolsVersion '28.0.3'
compileSdkVersion 30
buildToolsVersion '30.0.3'

defaultConfig {
versionCode 1
versionCode 2
versionName project.version
minSdkVersion 9
targetSdkVersion 26
minSdkVersion 14
targetSdkVersion 30
consumerProguardFiles 'progress-proguard.txt'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}

testOptions.unitTests {
Expand All @@ -33,10 +33,11 @@ android {
}

dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.billingclient:billing:2.0.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.4.0'
implementation 'androidx.annotation:annotation:1.2.0'
//implementation 'com.android.billingclient:billing:2.0.1' //Old version that works but obsolete
implementation 'com.android.billingclient:billing:4.0.0'
}

configurations.archives.extendsFrom configurations.default
Expand Down Expand Up @@ -78,9 +79,9 @@ uploadArchives {
}

pom.project {
name 'Android In-App Billing v3 Library'
name 'Android In-App Billing v4 Library'
packaging 'aar'
description 'A lightweight implementation of Android In-app Billing Version 3'
description 'A lightweight implementation of the current Android In-app Billing Version 4.'
url 'https://github.com/anjlab/android-inapp-billing-v3'

scm {
Expand Down Expand Up @@ -134,7 +135,7 @@ android.libraryVariants.all { variant ->
copy {
from task.archivePath
into '../sample/libs'
rename { String fileName -> 'anjlab-iabv3-current.jar' }
rename { String fileName -> 'anjlab-iabv4-current.jar' }
}
}
artifacts.add('archives', task);
Expand Down
Empty file modified library/progress-proguard.txt
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions library/src/androidTest/java/com/anjlab/android/iab/v3/BillingHistoryRecordTest.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.json.JSONException;
import org.junit.Before;
import org.junit.Test;

import static junit.framework.Assert.assertEquals;

public class BillingHistoryRecordTest
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified library/src/androidTest/resources/purchase_info.json
100644 → 100755
Empty file.
Empty file modified library/src/androidTest/resources/sku_in_app.json
100644 → 100755
Empty file.
Empty file modified library/src/androidTest/resources/sku_subscription.json
100644 → 100755
Empty file.
Empty file.
Empty file modified library/src/androidTest/resources/sku_subscription_trial.json
100644 → 100755
Empty file.
Empty file modified library/src/androidTest/resources/transaction_details.json
100644 → 100755
Empty file.
3 changes: 3 additions & 0 deletions library/src/main/java/com/anjlab/android/iab/v3/BillingBase.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class BillingBase
this.context = context;
}

public BillingBase() {
}

Context getContext()
{
return context;
Expand Down
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit 7d4ef44

Please sign in to comment.