Skip to content
This repository was archived by the owner on Oct 20, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 12 additions & 8 deletions android/src/main/java/com/idehub/Billing/InAppBillingBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Map;

public class InAppBillingBridge extends ReactContextBaseJavaModule implements ActivityEventListener, BillingProcessor.IBillingHandler {

ReactApplicationContext _reactContext;
String LICENSE_KEY = null;
BillingProcessor bp;
Expand Down Expand Up @@ -396,15 +397,18 @@ private Boolean isIabServiceAvailable() {
return BillingProcessor.isIabServiceAvailable(_reactContext);
}

@Deprecated
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
if (bp != null)
bp.handleActivityResult(requestCode, resultCode, intent);
}
@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
if (requestCode != PromiseConstants.PURCHASE_FLOW_REQUEST_CODE) {
return;
}

public void onActivityResult(final Activity activity, final int requestCode, final int resultCode, final Intent intent) {
if (bp != null)
bp.handleActivityResult(requestCode, resultCode, intent);
int responseCode = data.getIntExtra(PromiseConstants.RESPONSE_CODE, PromiseConstants.BILLING_RESPONSE_RESULT_OK);
if (resultCode == Activity.RESULT_OK && responseCode == PromiseConstants.BILLING_RESPONSE_RESULT_OK) {
resolvePromise(PromiseConstants.PURCHASE_OR_SUBSCRIBE, true);
} else {
rejectPromise(PromiseConstants.PURCHASE_OR_SUBSCRIBE, "An error has occured. Code " + requestCode);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
public class PromiseConstants {
public static final String OPEN = "OPEN_PROMISE";
public static final String PURCHASE_OR_SUBSCRIBE = "PURCHASE_OR_SUBSCRIBE_PROMISE";
public static final int PURCHASE_FLOW_REQUEST_CODE = 32459;
public static final int BILLING_RESPONSE_RESULT_OK = 0;
public static final String RESPONSE_CODE = "RESPONSE_CODE";
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-billing",
"version": "2.4.0",
"version": "2.4.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll review this PR in more detail later. But please do not manually update the version number in PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this? As part of these changes we expect the version to be incremented. It doesn't make sense for us to downgrade this as we increment it for proper cache/references in lockfiles.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you do for forks is not up to me. But for upstream, i.e. this repository, I want to increment the version myself. This is because I might add other changes along with this version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! Thanks @cbrevik -- we will update this.

"description": "React Native bridge for InApp Billing on Android",
"main": "index.js",
"scripts": {
Expand Down