Subscription Purchase in Unity iOS - ios

My app contains subscription based functionality for purchase. So which way I require to move ahead into this?
When I search for this in Google, I always found Consumable and Non-Consumable product purchase related help.
I want to move ahead with Renewable Subscription purchase. At present I have Prime31 plugin with following source code written:
#if UNITY_ANDROID
var productId = GameConstants.SKU_PURCHASE_9999_COINS;
#elif UNITY_IOS
var productId = GameConstants.SKU_PURCHASE_9999_COINS;
#endif
IAP.purchaseConsumableProduct (productId, (didSucceed, error) => {
Debug.Log ("purchasing product " + productId + " result: " + didSucceed);
if (didSucceed) {
}
});
Whether using same code, Can I use for Subscription purchase?
What is alternative way for me to implement Subscription purchase?

Related

Apple product list price and purchase dialog price both are showing different

My product list are dynamic, name and price both are coming from app store.
I have only one product and that original app store product price is 9,99€ Tier 8.
await inAppPurchase.queryProductDetails(_kIds).productDetails;
When I get this product in my iOS app at that time product details price is 8,99€.
viewModel
.getInstance()
.buyNonConsumable(purchaseParam: viewModel.initPurchaseProducts())
.whenComplete(() {})
.catchError((onError) {
showToast(Constants.purchaseFail, success: 0);
print("catch error error $onError");
});
When I call buyNonConsumable function then this purchase dialog show 9,99€
I am testing on TestFlight and xCode. The IAP is not on production.
I have used this package : https://pub.dev/packages/in_app_purchase
Dart Version : 2.18.4
Flutter SDK : 3.8.8
Application snap
Does anyone have any ideas about this price difference problem? Any suggestion would be most appreciated.
Thanks in advance!!

In-App Purchase Display Name and Description not properly loading - Swift 4

I am trying to enable In-App Purchases in Swift 4 for iOS and I can not get the Display Name and Description to properly show up (or load) in the app when I test. I do get the error handing message that I put in if (products.count == 0) {. I can't get the Product Title and Product Description that I set up in AppStoreConnect to properly load when I test my app. Instead the code thinks that there are no products because it runs the code in the if (products.count == 0) { closure. I quadruple checked everything else (i.e. Bundle ID, Product ID, StoreKit's imported, the delegates are set up, everything on the AppStoreConnect side is set up, etc.). There are no Xcode Warnings and the In-App Purchase status is "Ready To Submit". Any suggestions?
var product: SKProduct?
var productID = "myProductID"
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
var products = response.products
if (products.count == 0) {
productTitle.text = "Warning" // GETS DISPLAYED
productDescripton.text = "Unable to connect to In-App Purchase." // GETS DISPLAYED
} else {
product = products[0]
productTitle.text = product?.localizedTitle
productDescripton.text = product?.localizedDescription
buyButton.isEnabled = true
buyButton.alpha = 1.0
}
let invalid = response.invalidProductIdentifiers
for product in invalid {
print("\(product)")
}
}
If you are a rookie at integrating In-App Purchases, then you should read this. If you have clean code and you think that you set everything up properly in App Store Connect, but still can't test properly. Specifically, if your products array is showing empty when it shouldn't be. Then, make sure that you have done the following:
1) Set up a Sandbox Tester via Users and Access in App Store Connect. This needs to be set up with an email that is not already used with iTunes, App Store, or Apple.
2) Filled out all of the necessary forms in Agreements, Tax, and Banking via App Store Connect. You'll know that everything is filled out when Paid Applications shows an Active Status.
3) Are testing on a real device that has been signed out of iTunes and App Store.
Common things that will cause this without warning are:
Your products aren't in the 'Ready to Submit' stage. This is most often from a missing screenshot, which is required even for Sandbox (you can upload a blank image for sandbox testing).
You haven't signed the 'Paid Applications' agreement in App Store Connect
Here's a good blog post that covers everything in a little more detail: Configuring In-app Products is Hard

Gdx-Pay iOS store, can't find product info

I have a working implementation of gdx-pay for Android using the Google App Store. I did that following this: https://bitbucket.org/just4phil/gdxpayexample/src/.
I am now trying to get it working on iOS, but can't find any docs on how to do that. In the project linked above there is no "ios app store" or any changes made to the ios-project. Does anyone have a link to an example working with ios?
I tried some stuff out and got this far:
IOSResolver:
public class IOSResolver extends PlatformResolver {
public IOSResolver(MyGdxGame myGame) {
super(myGame);
PurchaseManagerConfig config = myGame.purchaseManagerConfig;
initializeIAP(null, myGame.purchaseObserver, config);
installIAP();
}
IOSLauncher:
#Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
config.orientationLandscape = false;
config.orientationPortrait = true;
config.useCompass = false;
config.useAccelerometer = false;
game = new MyGdxGame(new IOSPlatform());
return new IOSApplication(game, config);
}
#Override
public boolean didFinishLaunching(UIApplication application, UIApplicationLaunchOptions launchOptions) {
boolean finished = super.didFinishLaunching(application, launchOptions);
game.setPlatformResolver(new IOSResolver(game));
return finished;
}
Core:
// ---- IAP: define products ---------------------
purchaseManagerConfig = new PurchaseManagerConfig();
purchaseManagerConfig.addOffer(new Offer().setType(OfferType.ENTITLEMENT).setIdentifier(ios_productId));
This gives me the error:
[GdxPay/AppleIOS] Requesting product info for test.product.id
2017-02-20 16:58:58.089803 IOSLauncher[5611:2144625] [info] gdx-pay: calls purchasemanager.purchase()
[GdxPay/AppleIOS] Error purchasing product (wrong product info count returned: 0)!
com.badlogic.gdx.utils.GdxRuntimeException: java.lang.RuntimeException: Error purchasing product (wrong product info count returned: 0)!
at com.scene2d.space_camp.MyGdxGame$1.handlePurchaseError(MyGdxGame.java)
at com.badlogic.gdx.pay.ios.apple.PurchaseManageriOSApple$AppleProductsDelegatePurchase.didReceiveResponse(PurchaseManageriOSApple.java)
at com.badlogic.gdx.pay.ios.apple.PurchaseManageriOSApple$AppleProductsDelegatePurchase.$cb$productsRequest$didReceiveResponse$(PurchaseManageriOSApple.java)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java)
at com.scene2d.tut.IOSLauncher.main(IOSLauncher.java)
Caused by: java.lang.RuntimeException: Error purchasing product (wrong product info count returned: 0)!
... 5 more
I registered the app on iTunes Connect and set up a product. However I did not post binaries, do I need to for testing IAP? It shows this message in iTunes Connect:
Your first In-App Purchase must be submitted with a new app version.
Select it from the app’s In-App Purchases section and click Submit.
Once your binary has been uploaded and your first In-App Purchase has
been submitted for review, additional In-App Purchases can be
submitted using the table below.
Is there no way to test without uploading the actual app?
I had this same issue and was seeing the same error message.
I think the two keys to getting your IAPs work are the following:
Use a real device for testing, not an emulated one.
Sign in with a sandbox account, not a real one.
Create your sandbox account on itunesconnect.
Build your app and install it onto your ipad/iphone using xcode.
On your device, go into settings and logout. This is important.
Run your app and make a purchase. You will be prompted to login. Use your sandbox account.
I did this and it worked.

Unity In-App Purchase Local Validation is slow

I'm currently changing our game's in-app purchasing model from an older add-in to unity's built-in service. Up until now there have been no issues testing payments and validating receipts, both live and using sandbox accounts.
Following the Unity guides I have developed a store, and can successfully make new payments with a sandbox account, however local validation takes around 2 minutes on an iPad Air 2. Is this normal? Our previous add-in validated receipt data using the App Store, and took only a few seconds.
private bool CheckReceipt()
{
#if UNITY_EDITOR
Debug.Log("IAP: Default for editor, receipt valid.");
return true;
#elif UNITY_ANDROID || UNITY_IOS
try
{
CrossPlatformValidator validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
AppleTangle.Data(), Application.bundleIdentifier);
Product product = controller.products.WithID(ProductID);
string receipt = product.receipt;
if (receipt == null)
{
Debug.Log("IAP: No receipt.");
return false;
}
Debug.Log("IAP: Validating receipt...");
IPurchaseReceipt[] result = validator.Validate(receipt);
return result[0].productID == ProductID;
}
catch (IAPSecurityException e)
{
Debug.Log("IAP: Invalid receipt, not unlocking content");
return false;
}
#endif
}
In mode "Sandbox" this time for validation very real, when you change paying to "Battle" mode all stand normal

Check if user has valid auto-renewable subscription with Parse iOS SDK

I'm trying to implement an application with auto-renewable subscription. Users should pay to access all functions of my application. I already use Parse as backend for my application. It provides some API methods for inAppPurchases but there is nothing said about auto-renewable type. The only thing I have found is some two years old threads in the blog it is said that receipt verification was implemented only for downloadable purchases.
I have tried to use as it called in docs "Simple purchase" and it works fine but I can't figure out how can I check if my user already bought subscription or not.
Does anybody know is there way to do it via Parse API or This should implemented in another way?
As mentioned, receipt validation is only built into the Parse SDK for downloadable content, but it is fairly simple to to create a Cloud Code function that POSTs the app receipt to the iTunes Store for validation. Here are the Apple docs for server side validation: Validating Receipts with the App Store
Here is a what a basic function would look like:
Parse.Cloud.define('validateReceipt', function (request, response) {
var receiptAsBase64EncodedString = request.params.receiptData;
var postData = {
method: 'POST',
url: 'http://buy.itunes.apple.com/verifyReceipt',
body: { 'receipt-data': receiptAsBase64EncodedString,
'password': SHARED_SECRET }
}
Parse.Cloud.httpRequest(postData).then(function (httpResponse) {
// httpResponse is a Parse.Cloud.HTTPResponse
var json = httpResponse.data; // Response body as a JavaScript object.
var validationStatus = json.status; // App Store validation status code
var receiptJSON = json.receipt; // Receipt data as a JSON object
// TODO: You'll need to check the IAP receipts to retrieve the
// expiration date of the auto-renewing subscription, and
// determine if it is expired yet.
var subscriptionIsActive = true;
if (subscriptionIsActive) {
return response.success('Subscription Active');
}
else {
return response.error('Subscription Expired');
}
});
});
See Receipt Fields for details on interpreting the receipt JSON. It's fairly straight forward for iOS 7+, but auto-renewing subscription receipts for iOS 6 and earlier are tedious.

Resources