Converting InAppBilling.Plugin to Amazon
-
Hello Guys, I have create a Android application in Xamarin and i would like to also have in on Amazon store. It uses in App purchases Currently im implementing those purchases with this code:
public async Task WasItemPurchased(string productId)
{
var billing = CrossInAppBilling.Current;
var result = false;
try
{
var connected = await billing.ConnectAsync(ItemType.InAppPurchase);if (!connected)
{
//Couldn't connect
return false;
}//check purchases
var verify = new InAppBillingVerify();
var purchases = await billing.GetPurchasesAsync(ItemType.InAppPurchase, verify);//check for null just incase
if (purchases?.Any(p => p.ProductId == productId) ?? false)
{
//Purchase restored
Preferences.Set(productId, true);
return true;
}
else
{
//no purchases found
//Toast.MakeText(this, GetString(Resource.String.Options_RestoreUnavailable), ToastLength.Long);
return false;
}
}
catch (InAppBillingPurchaseException purchaseEx)
{
var message = string.Empty;
switch (purchaseEx.PurchaseError)
{
case PurchaseError.AppStoreUnavailable:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);
break;
case PurchaseError.BillingUnavailable:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorBillingUnavailable);
break;
case PurchaseError.PaymentInvalid:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentInvalid);
break;
case PurchaseError.PaymentNotAllowed:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentNotAllowed);
break;
case PurchaseError.AlreadyOwned:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAlreadyOwned);
Preferences.Set(productId, true);
result = true;
break;
}//Decide if it is an error we care about
if (string.IsNullOrWhiteSpace(message))
return false;//Display message to user
//Toast.MakeText(this, message, ToastLength.Long);
}
catch (Exception exception)
{
Crashes.TrackError(exception);
//Something has gone wrong
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);
//Toast.MakeText(this, GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable), ToastLength.Long);
}
finally
{
await billing.DisconnectAsync();
} -
Hello Guys, I have create a Android application in Xamarin and i would like to also have in on Amazon store. It uses in App purchases Currently im implementing those purchases with this code:
public async Task WasItemPurchased(string productId)
{
var billing = CrossInAppBilling.Current;
var result = false;
try
{
var connected = await billing.ConnectAsync(ItemType.InAppPurchase);if (!connected)
{
//Couldn't connect
return false;
}//check purchases
var verify = new InAppBillingVerify();
var purchases = await billing.GetPurchasesAsync(ItemType.InAppPurchase, verify);//check for null just incase
if (purchases?.Any(p => p.ProductId == productId) ?? false)
{
//Purchase restored
Preferences.Set(productId, true);
return true;
}
else
{
//no purchases found
//Toast.MakeText(this, GetString(Resource.String.Options_RestoreUnavailable), ToastLength.Long);
return false;
}
}
catch (InAppBillingPurchaseException purchaseEx)
{
var message = string.Empty;
switch (purchaseEx.PurchaseError)
{
case PurchaseError.AppStoreUnavailable:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);
break;
case PurchaseError.BillingUnavailable:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorBillingUnavailable);
break;
case PurchaseError.PaymentInvalid:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentInvalid);
break;
case PurchaseError.PaymentNotAllowed:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentNotAllowed);
break;
case PurchaseError.AlreadyOwned:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAlreadyOwned);
Preferences.Set(productId, true);
result = true;
break;
}//Decide if it is an error we care about
if (string.IsNullOrWhiteSpace(message))
return false;//Display message to user
//Toast.MakeText(this, message, ToastLength.Long);
}
catch (Exception exception)
{
Crashes.TrackError(exception);
//Something has gone wrong
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);
//Toast.MakeText(this, GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable), ToastLength.Long);
}
finally
{
await billing.DisconnectAsync();
}We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in! Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in! Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
Well i cant understand the API, at all and that is why i dont have code to demonstrate. Can you give me an example of a successful purchase and a check if a purchase exist already? What is this function: GetPurchaseUpdates? Update to what? What is the Response of the Purchase function? How i can know of a purchase was successful? Where i can find a list will all possible responses?
-
Well i cant understand the API, at all and that is why i dont have code to demonstrate. Can you give me an example of a successful purchase and a check if a purchase exist already? What is this function: GetPurchaseUpdates? Update to what? What is the Response of the Purchase function? How i can know of a purchase was successful? Where i can find a list will all possible responses?
If you are trying to handle anything to do with real money - and you are - then you shouldn't be getting code (or anything else) from a "random website"! Never, ever, accept code from a insecure website to handle anything to do with real money. You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties. Only get such code from Amazon themselves - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be! So start looking for API tutorials which explain how to do it, and then check that against the official API documentation. You need to understand this stuff if you are going to use it - or you could well end up coding from a cell ... :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
-
If you are trying to handle anything to do with real money - and you are - then you shouldn't be getting code (or anything else) from a "random website"! Never, ever, accept code from a insecure website to handle anything to do with real money. You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties. Only get such code from Amazon themselves - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be! So start looking for API tutorials which explain how to do it, and then check that against the official API documentation. You need to understand this stuff if you are going to use it - or you could well end up coding from a cell ... :laugh:
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!
I ask for an example of an API i dont know where this danger that will put you in a cell come from :P
-
Hello Guys, I have create a Android application in Xamarin and i would like to also have in on Amazon store. It uses in App purchases Currently im implementing those purchases with this code:
public async Task WasItemPurchased(string productId)
{
var billing = CrossInAppBilling.Current;
var result = false;
try
{
var connected = await billing.ConnectAsync(ItemType.InAppPurchase);if (!connected)
{
//Couldn't connect
return false;
}//check purchases
var verify = new InAppBillingVerify();
var purchases = await billing.GetPurchasesAsync(ItemType.InAppPurchase, verify);//check for null just incase
if (purchases?.Any(p => p.ProductId == productId) ?? false)
{
//Purchase restored
Preferences.Set(productId, true);
return true;
}
else
{
//no purchases found
//Toast.MakeText(this, GetString(Resource.String.Options_RestoreUnavailable), ToastLength.Long);
return false;
}
}
catch (InAppBillingPurchaseException purchaseEx)
{
var message = string.Empty;
switch (purchaseEx.PurchaseError)
{
case PurchaseError.AppStoreUnavailable:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);
break;
case PurchaseError.BillingUnavailable:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorBillingUnavailable);
break;
case PurchaseError.PaymentInvalid:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentInvalid);
break;
case PurchaseError.PaymentNotAllowed:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorPaymentNotAllowed);
break;
case PurchaseError.AlreadyOwned:
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAlreadyOwned);
Preferences.Set(productId, true);
result = true;
break;
}//Decide if it is an error we care about
if (string.IsNullOrWhiteSpace(message))
return false;//Display message to user
//Toast.MakeText(this, message, ToastLength.Long);
}
catch (Exception exception)
{
Crashes.TrackError(exception);
//Something has gone wrong
RestorePurchasesStatusMessage = GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable);
//Toast.MakeText(this, GetString(Resource.String.Options_PaidFunctions_ErrorAppStoreUnavailable), ToastLength.Long);
}
finally
{
await billing.DisconnectAsync();
}Many of the calls from your original link are explained a bit further here. IAP Plugin Methods and Events | Cross-Platform Plugins[^] You may have some luck finding some examples by exploring the iap forum here: All Posts in In-App Purchasing (IAP) 2.0 - Forums[^], or the app store forum from either link.
-
Many of the calls from your original link are explained a bit further here. IAP Plugin Methods and Events | Cross-Platform Plugins[^] You may have some luck finding some examples by exploring the iap forum here: All Posts in In-App Purchasing (IAP) 2.0 - Forums[^], or the app store forum from either link.
Okz thanks