Skip to content

Commit

Permalink
Update IAP plugin to version 5.3.0+300
Browse files Browse the repository at this point in the history
  • Loading branch information
fuatbakkal committed Aug 2, 2021
1 parent e8abb1e commit ca07ec7
Show file tree
Hide file tree
Showing 41 changed files with 720 additions and 1,986 deletions.
Binary file removed flutter-hms-iap/.docs/homeScreen.jpg
Binary file not shown.
11 changes: 11 additions & 0 deletions flutter-hms-iap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
## 5.3.0+300

* [Breaking Change] Added null-safety support.
* Updated Huawei IAP SDK version to 5.3.0.300
* isSupportAppTouch parameter is added to isEnvReady API for AppTouch.
* Added carrierId and country to IsEnvReadyResult for obtaining the carrier ID and the country of the currently signed-in ID.
* Added a class of constants, named SignAlgorithmConstants, which contains the algorithm that you pass for calling a certain IapClient API.
* Added signatureAlgorithm to ConsumeOwnedPurchaseReq, OwnedPurchasesReq and PurchaseIntentReq classes to specify signature algorithm to sign the result data.
* Added signatureAlgorithm to ConsumeOwnedPurchaseResult, OwnedPurchasesResult and PurchaseResultInfo to verify the signature algorithm.

## 5.0.2+301

* Updated HMSLogger.

## 5.0.2+300
Expand Down
1,469 changes: 20 additions & 1,449 deletions flutter-hms-iap/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion flutter-hms-iap/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ android {
}

dependencies {
implementation 'com.huawei.hms:iap:5.0.2.300'
implementation 'com.huawei.hms:iap:5.3.0.300'
implementation 'com.google.code.gson:gson:2.8.5'
}
1 change: 0 additions & 1 deletion flutter-hms-iap/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions flutter-hms-iap/android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
22 changes: 4 additions & 18 deletions flutter-hms-iap/android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

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

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,28 +64,14 @@ echo location of your Java installation.

goto fail

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

if not "%OS%" == "Windows_NT" goto win9xME_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=%*

: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%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,21 @@ public class MethodCallHandlerImpl implements MethodCallHandler, ActivityResultL
hmsLogger = HMSLogger.getInstance(mActivity.getApplicationContext());
}

private void isEnvReady(@NonNull final Result result) {
private void isEnvReady(@NonNull final MethodCall call, @NonNull final Result result) {
final String isEnvReadyMethodName = "isEnvReady";
final Boolean isSupportAppTouch = call.argument("isSupportAppTouch") == null
? null
: ValueGetter.getBoolean("isSupportAppTouch", call);
hmsLogger.startMethodExecutionTimer(isEnvReadyMethodName);
mIapClient.isEnvReady()
.addOnSuccessListener(new DefaultSuccessListener<>(result, mGson, hmsLogger, isEnvReadyMethodName))
.addOnFailureListener(new IsEnvReadyFailureListener(this, result, REQUEST_IS_ENVIRONMENT_READY, hmsLogger));
if(isSupportAppTouch == null) {
mIapClient.isEnvReady()
.addOnSuccessListener(new DefaultSuccessListener<>(result, mGson, hmsLogger, isEnvReadyMethodName))
.addOnFailureListener(new IsEnvReadyFailureListener(this, result, REQUEST_IS_ENVIRONMENT_READY, hmsLogger));
} else{
mIapClient.isEnvReady(isSupportAppTouch)
.addOnSuccessListener(new DefaultSuccessListener<>(result, mGson, hmsLogger, isEnvReadyMethodName))
.addOnFailureListener(new IsEnvReadyFailureListener(this, result, REQUEST_IS_ENVIRONMENT_READY, hmsLogger));
}
}

private void isSandboxActivated(@NonNull final Result result) {
Expand Down Expand Up @@ -119,13 +128,17 @@ private void createPurchaseIntent(@NonNull final MethodCall call, @NonNull final
final String reservedInfor = call.argument("reservedInfor") == null
? null
: ValueGetter.getString("reservedInfor", call);
final String signatureAlgorithm = call.argument("signatureAlgorithm") == null
? null
: ValueGetter.getString("signatureAlgorithm", call);

//Constructing request
final PurchaseIntentReq request = new PurchaseIntentReq();
request.setProductId(productId);
request.setPriceType(priceType);
request.setDeveloperPayload(developerPayload);
request.setReservedInfor(reservedInfor);
request.setSignatureAlgorithm(signatureAlgorithm);

//Create purchase intent from IAP service
final String createPurchaseIntentMethodName = "createPurchaseIntent";
Expand All @@ -144,11 +157,15 @@ private void consumeOwnedPurchase(@NonNull final MethodCall call, @NonNull final
final String developerChallenge = call.argument("developerChallenge") == null
? null
: ValueGetter.getString("developerChallenge", call);
final String signatureAlgorithm = call.argument("signatureAlgorithm") == null
? null
: ValueGetter.getString("signatureAlgorithm", call);

//Constructing request
final ConsumeOwnedPurchaseReq request = new ConsumeOwnedPurchaseReq();
request.setDeveloperChallenge(developerChallenge);
request.setPurchaseToken(purchaseToken);
request.setSignatureAlgorithm(signatureAlgorithm);

// Call service from IAP service
final String consumeOwnedPurchaseMethodName = "consumeOwnedPurchase";
Expand All @@ -164,6 +181,9 @@ private void consumeOwnedPurchase(@NonNull final MethodCall call, @NonNull final
private void obtainOwnedPurchaseRecord(@NonNull final MethodCall call, @NonNull final Result result) {
//Arguments
final int priceType = ValueGetter.getInt("priceType", call);
final String signatureAlgorithm = call.argument("signatureAlgorithm") == null
? null
: ValueGetter.getString("signatureAlgorithm", call);
final String continuationToken = call.argument("continuationToken") == null
? null
: ValueGetter.getString("continuationToken", call);
Expand All @@ -172,6 +192,7 @@ private void obtainOwnedPurchaseRecord(@NonNull final MethodCall call, @NonNull
final OwnedPurchasesReq request = new OwnedPurchasesReq();
request.setContinuationToken(continuationToken);
request.setPriceType(priceType);
request.setSignatureAlgorithm(signatureAlgorithm);

//Obtain record from IAP service
final String obtainOwnedPurchaseRecordMethodName = "obtainOwnedPurchaseRecord";
Expand All @@ -190,11 +211,15 @@ private void obtainOwnedPurchases(@NonNull final MethodCall call, @NonNull final
final String continuationToken = call.argument("continuationToken") == null
? null
: ValueGetter.getString("continuationToken", call);
final String signatureAlgorithm = call.argument("signatureAlgorithm") == null
? null
: ValueGetter.getString("signatureAlgorithm", call);

//Constructing request
final OwnedPurchasesReq request = new OwnedPurchasesReq();
request.setContinuationToken(continuationToken);
request.setPriceType(priceType);
request.setSignatureAlgorithm(signatureAlgorithm);

//Obtain owned purchase from IAP service
final String obtainOwnedPurchasesMethodName = "obtainOwnedPurchases";
Expand Down Expand Up @@ -231,7 +256,7 @@ private void startIapActivity(@NonNull final MethodCall call, final Result resul
public void onMethodCall(@NonNull final MethodCall call, @NonNull final Result result) {
switch (call.method) {
case "isEnvReady":
isEnvReady(result);
isEnvReady(call, result);
break;
case "isSandboxActivated":
isSandboxActivated(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class HMSLogger {

private static final String PLATFORM = "Flutter";

private static final String VERSION = "5.0.2.301";
private static final String VERSION = "5.3.0.300";

private static final String SERVICE = "Cross-Platform";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static JSONObject getJSONFromPurchaseResultInfo(final PurchaseResultInfo
jsonObject.put("errMsg", obj.getErrMsg());
jsonObject.put("inAppPurchaseData", obj.getInAppPurchaseData());
jsonObject.put("inAppDataSignature", obj.getInAppDataSignature());
jsonObject.put("signatureAlgorithm", obj.getSignatureAlgorithm());
} catch (final JSONException e) {
Log.e(TAG, e.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,13 @@ public static String getString(final String key, final MethodCall call) {
throw new IllegalArgumentException();
}
}

public static Boolean getBoolean(final String key, final MethodCall call){
final Object value = call.argument(key);
if (value instanceof Boolean) {
return (Boolean) value;
} else {
throw new IllegalArgumentException();
}
}
}
1 change: 0 additions & 1 deletion flutter-hms-iap/example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit ca07ec7

Please sign in to comment.