Skip to content

Commit

Permalink
Merge branch 'master' into feature/android-billing-client
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Jun 1, 2020
2 parents 26b5a55 + 3badebc commit 51b8db9
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
github: jamesmontemagno
patreon: mergeconflictfm
custom: https://www.buymeacoffee.com/jamesmontemagno
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,29 @@ Dev Feed: https://ci.appveyor.com/nuget/inappbillingplugin
|Xamarin.Android|API 14+|
|Windows 10 UWP|10+|

### Created By: [@JamesMontemagno](http://twitter.com/jamesmontemagno)
### Created By: [@JamesMontemagno](http://github.com/jamesmontemagno)
* Twitter: [@JamesMontemagno](http://twitter.com/jamesmontemagno)
* Blog: [MotzCod.es](http://motzcod.es), [Micro Blog](http://motz.micro.blog)
* Blog: [Montemagno.com](http://montemagno.com)
* Podcasts: [Merge Conflict](http://mergeconflict.fm), [Coffeehouse Blunders](http://blunders.fm), [The Xamarin Podcast](http://xamarinpodcast.com)
* Video: [The Xamarin Show on Channel 9](http://xamarinshow.com), [YouTube Channel](https://www.youtube.com/jamesmontemagno)

### Checkout my podcast on IAP
I co-host a weekly development podcast, [Merge Conflict](http://mergeconflict.fm), about technology and recently covered IAP and this library: [Merge Conflict 28: Demystifying In-App Purchases](http://www.mergeconflict.fm/57678-merge-conflict-28-demystifying-in-app-purchases)

## Version 3 Linker Settings

For linking if you are setting **Link All** you may need to add:

#### Android:
```
Plugin.InAppBilling;Xamarin.Android.Google.BillingClient;
```

#### iOS:
```
--linkskip=Plugin.InAppBilling
```

### License
The MIT License (MIT), see [LICENSE](LICENSE) file.

Expand Down
4 changes: 2 additions & 2 deletions docs/CheckAndRestorePurchases.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<bool> WasItemPurchased(string productId)
if (!connected)
{
//Couldn't connect
return;
return false;
}

//check purchases
Expand Down Expand Up @@ -66,4 +66,4 @@ public async Task<bool> WasItemPurchased(string productId)
Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](SecuringPurchases.md) documentation.


<= Back to [Table of Contents](README.md)
<= Back to [Table of Contents](README.md)
4 changes: 2 additions & 2 deletions docs/PurchaseConsumable.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task<bool> PurchaseItem(string productId, string payload)
if (!connected)
{
//we are offline or can't connect, don't try to purchase
return;
return false;
}

//check purchases
Expand All @@ -84,7 +84,7 @@ public async Task<bool> PurchaseItem(string productId, string payload)
//If we are on iOS we are done, else try to consume the purchase
//Device.RuntimePlatform comes from Xamarin.Forms, you can also use a conditional flag or the DeviceInfo plugin
if(Device.RuntimePlatform == Device.iOS)
return;
return true;

var consumedItem = await CrossInAppBilling.Current.ConsumePurchaseAsync(purchase.ProductId, purchase.PurchaseToken);

Expand Down
2 changes: 1 addition & 1 deletion docs/PurchaseNonConsumable.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<bool> PurchaseItem(string productId, string payload)
if (!connected)
{
//we are offline or can't connect, don't try to purchase
return;
return false;
}

//check purchases
Expand Down
4 changes: 2 additions & 2 deletions docs/PurchaseSubscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<bool> PurchaseItem(string productId, string payload)
if (!connected)
{
//we are offline or can't connect, don't try to purchase
return;
return false;
}

//check purchases
Expand Down Expand Up @@ -70,4 +70,4 @@ public async Task<bool> PurchaseItem(string productId, string payload)
Learn more about `IInAppBillingVerifyPurchase` in the [Securing Purchases](SecuringPurchases.md) documentation.


<= Back to [Table of Contents](README.md)
<= Back to [Table of Contents](README.md)
2 changes: 2 additions & 0 deletions docs/TestingAndTroubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ You will not be able to test any StoreKit functionality until you have an iOS Pa
* Just open the app you're trying to test
* Your app will prompt you to sign in
* Enter your credentials for your sandbox test account
* While you could e.g. read your items, you need a real device to test purchasing. Purchasing does not work on Simulators.


## Android Testing
Expand All @@ -35,6 +36,7 @@ You will not be able to test any StoreKit functionality until you have an iOS Pa
<AndroidSigningKeyAlias>ALIAS</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>PASS</AndroidSigningKeyPass>
```
* You could use the static product IDs for testing, e.g. android.test.purchased, as described in [Androids Developer Documentation](https://developer.android.com/google/play/billing/billing_testing).

## Android Troubleshooing
* If you see "You need to sign into your google account". This most likely means that you don't have an items published and active for IAB
Expand Down
14 changes: 4 additions & 10 deletions src/Plugin.InAppBilling/InAppBilling.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,16 +507,10 @@ public static void HandleActivityResult(int requestCode, Result resultCode, Inte
return;
}

if(resultCode == Result.Canceled && tcsPurchase != null && !tcsPurchase.Task.IsCompleted)
{
tcsPurchase.SetException(new InAppBillingPurchaseException(PurchaseError.UserCancelled));
return;
}

if(data == null)
{
return;
}
if (data == null)
{
return;
}

int responseCode = data.GetIntExtra(RESPONSE_CODE, 0);

Expand Down
6 changes: 3 additions & 3 deletions src/Plugin.InAppBilling/Shared/InAppBillingPurchase.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public override bool Equals(object obj) =>
(obj is InAppBillingPurchase purchase) && Equals(purchase);

public bool Equals(InAppBillingPurchase other) =>
(Id, ProductId, AutoRenewing, PurchaseToken, State, Payload) ==
(other.Id, other.ProductId, other.AutoRenewing, other.PurchaseToken, other.State, other.Payload);
(Id, TransactionDateUtc, ProductId, AutoRenewing, PurchaseToken, State, Payload) ==
(other.Id, other.TransactionDateUtc, other.ProductId, other.AutoRenewing, other.PurchaseToken, other.State, other.Payload);

public override int GetHashCode() =>
(Id, ProductId, AutoRenewing, PurchaseToken, State, Payload).GetHashCode();
(Id, TransactionDateUtc, ProductId, AutoRenewing, PurchaseToken, State, Payload).GetHashCode();

/// <summary>
/// Prints out product
Expand Down

0 comments on commit 51b8db9

Please sign in to comment.