mirror of https://github.com/tasks/tasks
parent
9c0ba990ae
commit
5731489e9c
@ -1,28 +0,0 @@
|
|||||||
package org.tasks.billing;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
public class PurchaseHelper {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public PurchaseHelper() {}
|
|
||||||
|
|
||||||
public boolean purchase(
|
|
||||||
final Activity activity,
|
|
||||||
final String sku,
|
|
||||||
final String pref,
|
|
||||||
final int requestCode,
|
|
||||||
final PurchaseHelperCallback callback) {
|
|
||||||
callback.purchaseCompleted(false, sku);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleActivityResult(
|
|
||||||
PurchaseHelperCallback callback, int requestCode, int resultCode, Intent data) {}
|
|
||||||
|
|
||||||
public void disposeIabHelper() {}
|
|
||||||
|
|
||||||
public void consumePurchases() {}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package org.tasks.billing;
|
||||||
|
|
||||||
|
import com.android.billingclient.api.Purchase;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
public class SignatureVerifier {
|
||||||
|
@Inject
|
||||||
|
public SignatureVerifier() {}
|
||||||
|
|
||||||
|
public boolean verifySignature(Purchase purchase) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,34 +0,0 @@
|
|||||||
package org.tasks.billing;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import org.tasks.preferences.Preferences;
|
|
||||||
|
|
||||||
public class PurchaseHelper {
|
|
||||||
|
|
||||||
private Preferences preferences;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public PurchaseHelper(Preferences preferences) {
|
|
||||||
this.preferences = preferences;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean purchase(
|
|
||||||
final Activity activity,
|
|
||||||
final String sku,
|
|
||||||
final String pref,
|
|
||||||
final int requestCode,
|
|
||||||
final PurchaseHelperCallback callback) {
|
|
||||||
preferences.setBoolean(pref, true);
|
|
||||||
callback.purchaseCompleted(true, sku);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleActivityResult(
|
|
||||||
PurchaseHelperCallback callback, int requestCode, int resultCode, Intent data) {}
|
|
||||||
|
|
||||||
public void disposeIabHelper() {}
|
|
||||||
|
|
||||||
public void consumePurchases() {}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package org.tasks.billing;
|
||||||
|
|
||||||
|
import com.android.billingclient.api.Purchase;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
public class SignatureVerifier {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public SignatureVerifier() {}
|
||||||
|
|
||||||
|
public boolean verifySignature(Purchase purchase) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package org.tasks.billing;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import com.android.billingclient.api.Purchase;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import org.tasks.R;
|
||||||
|
import org.tasks.injection.ForApplication;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
public class SignatureVerifier {
|
||||||
|
|
||||||
|
private final String billingKey;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public SignatureVerifier(@ForApplication Context context) {
|
||||||
|
billingKey = context.getString(R.string.gp_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean verifySignature(Purchase purchase) {
|
||||||
|
try {
|
||||||
|
return Security.verifyPurchase(
|
||||||
|
billingKey, purchase.getOriginalJson(), purchase.getSignature());
|
||||||
|
} catch (IOException e) {
|
||||||
|
Timber.e(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue