Getting the price from AppStore webhook - app-store

I accept webhooks from AppStore, but I'm wondering why there's no price the user paid for the subscription? I mean in transaction info JWSTransactionDecodedPayload. Also I couldn't find any other API methods to get the price.
The reason I need the price, because there may be different cost and commission the customer has to pay, depending on his country or something else.

We can only get the price from client with SKProduct in Original StoreKit by SKProductsRequest, or with Product in StoreKit 2 by products(for:) for now.
Or we get the price from App Store Connect with ProductID configured on Apple. However, price currency is related with AppleID, means we also need currency to confirm how much user paid.
I think why receipt not contains price is also for this reason. Apple could not represent all prices with different currency in a receipt, so only provide ProductID for us to query.

Related

Apple In App Purchase with Introductory Offer (SKProductDiscountPaymentModePayUpFront)

I am writing a SwiftUI app and I am looking for some advice.
I setup a product identifier in AppStore connect
Lets say it's
com.example.subscription_service_1
The monthly price is $39.99
I want to have an introductory offer for $19.99 if a buyer chooses a 12 month pay up front
SKProductDiscountPaymentModePayUpFront
When the IAP is triggered, the customer ONLY gets to see ONE option. They see the Pay Up Front.
I am not sure if I am doing something wrong or if this is how it's designed.
I felt that Apple always allowed customers to choose their options.
Please advise what I must do (without creating unnecessary product Identifiers).
I am not sure if I understand you correctly, but if you want to charge the user $39.99 monthly and grant him an introductory offer when he chooses one year, then you have to create two subscriptions: one monthly subscription with the price of $39.99 and a yearly subscription with a price of whatever you want. You then have to create the introductory offer of $19.99 within App Store Connect for the yearly subscription.

PayPal Adaptive Payment - multiple currency issues

I'm having a real headache with these damn Adaptive Payments for PayPal! So far, I've got it working - but now I'm trying to resolve some issues with it.
Why on earth don't they just let you request a payment in the sellers currency? I'm acting as a 3rd party system for people- so they list on my site, and then the buyer purchases from our site - but the money gets sent direct to them (via our account, with Adaptive payments - so we can do IPN requests). The problem here, is that not everyone will use the same currency.
To get around this, I've been using the ConvertCurrency feature ( https://developer.paypal.com/docs/classic/api/adaptive-payments/ConvertCurrency_API_Operation/ ). This works OK - as I can then give the prices to the buyer in their desired currency.
However, when I then send to paypal to make the payment - it requires multiple payments (at once) to be done in just 1 currency. So for example, I have:
Seller 1- $50 US
Seller 2- 10 EUR
I convert those into GBP, which gives me say £30 and £8 - so a total of £38. This payment goes through, but the problem arises when the IPN gets run. If the person receiving the funds hasn't already setup the account to accept in that currency, the get a message about "accepting" the funds, as seen here:
https://www.paypal.com/uk/cgi-bin/webscr?cmd=p/sell/mc/mc_receive-outside
Until they have decided on what to do there, I can't do squat with the payment - as it comes back with the status:
'transaction[0].pending_reason' => 'MULTI_CURRENCY',
I know for a fact the buyers are not going to like having to wait for a confirmation of their order. Why can't I just get it to accept in that currency, and convert automatically into their primary currency?
The other bad thing about this, is that I doubt the seller is going to be the amount they expect. PayPal are going to take their commission when doing the conversion 1 way, and then again when the person receiving it goes to convert it into their own currency.
How does eBay, etsy and other large sites that offer multiple purchases handle this? Its driving me up the wall!
Ok, well its not really a "solution", but its the route I'm going to have to go down - as I can't see any other option.
Now, I'm storing the converted amounts into my DB, and then showing those to the buyers (these numbers are updated via a cron, 2 times a day).
The buyer then gets shown the prices in their own currency, but when they go to paypal it actually asks for the money in the sellers currency. This means that the artist will always have the correct incoming currency, and I will not get that annoying issue.
If all goes to plan, the price the buyer see's on our site, should be the same as the amount they get charged,as I'm using the ConvertCurrency API to convert the amounts into the most up to date prices.
Hopefully this helps someone else, if they come across this post.

Handling refunds of an in-app purchase with iTunes

I work for a company offering in-app purchases. I am trying to have our purchase statistics alright after a user has obtained a refund for an in-app purchase with iTunes connect.
I have read the iTunes connect sales and trends guide (pdf) and know how to retrieve sales for a given period of time with the auto-ingestion tool provided.
Unfortunately, the report I get does not contain any field that would allow me to know precisely which purchase or user was refunded. I just know about the amount and Apple id, so here comes my question:
Is there a way to add custom fields when creating a new in-app purchase so that I could pass my order_id to be retrieved it in the sales report?
That is the only way I see to know exactly which purchase on our side was refunded.
Thank you in advance!

StoreKit on iOS - autorenewable subscription - How to know whether it is a free trial or not?

In iTunes Connect it is possible to give a free trial period for autorenewable subscriptions.
App > Manage In App Purchases > Subscription Basic > 1 Month > Offer a free trial?
How can I get this information on the client? SKProduct does not have any information about this as I can see. Since we're having a marketing campaign it is very confusing for the end user to not see information about the product has a trial period.
Of course it is possible to fetch this kind of information from a server I maintain, but then we'll have the overhead with updating both our server and iTunes Connect. So I don't accept this kind of answer unless it is wired up to retrieving that trial period information from Apple's services.
TLDR; It is not possible. You need to manage this information yourself.
When you process an SKPayment you get back a receipt. You should verify those receipts regularly for subscriptions (e.g. before downloading new content) as the user might have cancelled the subscription. When the user does cancel the subscription or the subscription expires you get back a descriptive error when verifying the purchase's receipt.
Moreover the receipt gives you all the information you need: for a given product you know which trial period you grant. Therefore when a purchase is made you could store the purchase date given from the purchase receipt in your model object or in the NSUserDefaults or in the Keychain alongside the purchase data. At this point you know when the trial is expired and verify that the subscription is still valid. If you can't you might want to disable access to the content until you're able to do so.
For more informations about purchase receipts and subscriptions check out the In-App Purchase Guide by Apple.
On the client side you usually identify the different products and characteristics by their product identifier as the App Store does not deliver certain information such as subscription period and free trial period.
So if your product ID is for example:
com.domain.app.product_paid1month_free7days you split the ID on the client side and know that the paid subscription duration is 1 month and the product has a free trial period of 7 days.
Of course one approach would be to transmit the product ID to your own server to get its characteristics as response. This way you can maintain the product list continuously without updating the binary and across versions.
SKProduct > introductoryPrice
Available since iOS 11.2
https://developer.apple.com/documentation/storekit/skproduct/2936878-introductoryprice?language=objc

Price of iphone in-app purchase, server-side

How can a server determine the amount of an iphone in-app purchase ?
The server receives the purchase's receipt sent by the app and uses this to validate it.
This returns some informations like a transaction_id, product_id, etc; but no amount or user details.
Since the amount depends on the currency and the user's country, how can I get the amount of the purchase on the server ?
From the same document, you can get product details localized through the SKProduct class, check this
If you are asking about how do the server knows it, when you setup an in-app purchase on the server you choose the price as tier, each tier has the price in different currencies so when you send the in-app purchase product id in the request, it check its price you setup and reflects it in the corresponding currency.
For device locale, check this and for device language check this but to get it from the server itself, Apple doesn't provide an API for it.
Now it is possible to set a different price for each country so the mapping of in app purchase to a pricing tier can be cumbersome.
You can get the price as the user see it in the UI and the price locale from the client and then send that information to your server.
For renewals - You can see renewals by verifying the receipt data on the server side and use the price sent by the client in the first transaction.