MS Graph, Calendar deltalink shows appointment as deleted when it is not - microsoft-graph-api

I'm using MS Graph to sync appointments between an Office 365 calendar and our app. I've set up a subscription for the resource and receive notifications for the created, updated and deleted events. I then use the deltalink I have stored for the subscription to get the changes. Most of the time this works very well.
However, sometimes after receiving a notification and using the deltalink, the results will show the appointment as deleted when it really isn't. IE, in the json it will only show "#removed":{"reason":"deleted"} and the id of the appointment. However when I then get the appointment with this id through the /calendar/events/{itemId} endpoint, I do get all the information of this appointment, meaning it's not deleted or it wouldn't even exist.
Once a subscription is in this state it doesn't appear to recover as the next deltalink will have the same problem. Deleting the subscription and getting a new deltalink will fix it.
I have no idea what causes this as the deltalink does get the right appointment, it just gives the wrong information for the appointment. I know that when I use an out of date deltalink I get a SyncStateNotFound error, but that's not the case here.

Related

what should I do when user upgrade subscribe in apple app purchase

Now when user upgrade the auto renew subscribe product in apple app purchase, the apple server will send a DID_CHANGE_RENEWAL_STATUS message to my develop server. Now I am received the message successfully. But I did not know what should I do to handle the DID_CHANGE_RENEWAL_STATUS message properly. I read the doc and search from internet and tell me the apple will take effect the new upgraded subscribtion the next period. what should I do when received the DID_CHANGE_RENEWAL_STATUS message?
I have think one way that save the new upgraded subscribe record and mark the new subscribed record not valid until recieved switch message from apple server. should I do it like this?
now I am get the subscribe product by using product id and expire date, I must add another field to mark the new upgraded product not valid. I just want to know how to handle the DID_CHANGE_RENEWAL_STATUS message the best way. The same as downgrade auto renew product, any suggestion is appriciate.
This event is only telling you that the product_id will change.
As you said, in case of an up-grade/cross-grade, it will change right away. In case of a down-grade it will change at the next expires_date.
To know if you should change the current product associated to your user, look into the last element of the latest_receipt_info (ordered by web_order_line_item_id) and check the product_id. If its value match the upgraded product, you should change, otherwise no.
If it didn't change, you'll get the new product:
in case of an up-grade/cross-grade: an INTERACTIVE_RENEWAL S2S will succeed to the DID_CHANGE_RENEWAL_STATUS (and you'll have to check the latest_receipt_info.product_id property, as described before)
in case of down-grade: since the expires_date will be past, you'll need to check with the /verifyReceipt API if the subscription has been renewed. By looking to the product_id property, you'll detect the down-grade.

MS Graph Api - Group Membership Change Notification - Not receiving notification after User who is a Member is hard deleted

I am currently set up for Change Notifications at the individual Group resource level(/groups/{guid}), with changeType of (updated, deleted) and am acting on Group changes with a delta link, including membership changes. My delta link is doing a $select of displayName and members.
I've noticed during testing that, if a User is deleted from Graph who is a member of the Group, a Change Notification is not sent. After some research, I found that when the User is deleted, they are first soft deleted in Graph, and retain their group membership until permanently deleted (see the 'Some things to note' section here https://learn.microsoft.com/en-us/graph/delta-query-groups#deltalink-response)
However, when I permanently delete the User, I am still not getting any Change Notifications. I am just wondering if I am doing something wrong? I am correctly getting Membership updates on Users added or removed from the Group, and DisplayName changes as well. Or perhaps I have found a bug?
From the question, I can see you are subscribed to group changes, which correctly sends change notifications when changes are made to the group or the group itself is deleted. I tested this and was able to receive this notification:
The issue in this case is that your application is not subscribed to Change Notifications at the individual User resource level /users which would send a change notification when the user is deleted. A few things to be aware of with regards to change notifications:
Certain limits apply to Azure AD based resources (users, groups) and will generate errors when exceeded
For users and groups, the maximum length of the subscription is 4230 minutes(under 3 days)
Please find further documentation here: creating a subscription

iOS IAP subscriptions/App Store Server to Server Notifications. Replacing the verifyReceipt API with unified_receipt

I'm in the process of upgrading an existing iOS IAP subscription system that already makes use of App Store Server Notifications. My existing solution is using the now deprecated latest_receipt, latest_receipt_info, latest_expired_receipt and latest_expired_receipt_info fields. According to Apple, these fields are now all replaced with the single unified_receipt field.
After watching all the required WWDC videos and sifting through the little documentation available I'm still left with a few unanswered questions.
The latest_receipt_info field is documented as:
An array that contains the latest 100 in-app purchase transactions of the decoded value in latest_receipt.
This means that this array will contain the customer's entire transaction history. This will not only include the relevant subscription but also any transactional products the customer may have purchased.
My question here is how can I find the relevant transaction in this array? The relevant transaction in this case would be the one that triggered the event (e.g. CANCEL). I need this transaction in order to update our backend database to reflect the current subscription status. For example, to update the subscription end date to the cancellation_date on a CANCEL event .
I have a similar question regarding the pending_renewal_info array. It's unclear to me from the existing documentation if all customers with an active (or maybe even expired?) subscription will always have an entry in this array.
An array of elements that refers to auto-renewable subscription renewals that are open or failed in the past.
I also need to find the relevant transaction in this field to do things like toggle the subscription status on a DID_CHANGE_RENEWAL_STATUS event or update the billing status on a DID_FAIL_TO_RENEW event. From the docs it doesn't look like there is enough info in the pending_renewal_info alone to compute the current subscription renewal status.
Overall my question really boils down to:
Can I be sure that there will be an entry in both unified_receipt.latest_receipt_info and unified_receipt.pending_renewal_info that matches the top level event auto_renew_product_id? And if so how should I find the relevant object in the respective array? Will there only be a single entry for each auto_renew_product_id or should I search the array and pull out the first match?
I found out that the transactions inside unified_receipt.latest_receipt_info array are ordered by purchased date from the latest to the oldest. And sure that you can found out the the top level event auto_renew_product_id.
However, for updating the subscription status or billing status, I utilize the return value from /verifyRecipt, which you can get by requesting to the Apple verifyReceipt server with receipt-data and password(https://developer.apple.com/documentation/appstorereceipts/verifyreceipt). Noted that the input receipt-data is unified_receipt.latest_receipt, and the responses share the same structure as unified_receipt.

Transaction identifier filed in transaction receipt is different from another user

I am doing one application.In that i am using InAppPurchase concept.In that i am implementing auto renewal subscription.Whenever i subscribe for product,I am sending the receipt to apple server from my server.In that i am getting the response from apple.That response contain different fields.In that fields,i want to know about transactionIdentier.Is this fileds is different from every payment.Means whenever i subscribe first time whatever i get is this same as whatever i get at the time of renewal.And if another user subscribe for same item then that person also get the same transactionIdentifier or different one.
I think the answer you are looking for is that all users and all transactions get a unique transactionIdentifier (which unless I've misread is a string of numbers). If you want the transactionIdentifier from when the user first subscribed, I believe you can get that from transaction.originalTransaction during SKPaymentTransactionStateRestored and I believe that is the same as looking for the original_transaction_id field on your server.

Paypal subscriptions IPN - problem with users subscribing multiple times

I'm using paypal subscriptions and the instant payment notification (IPN) to handle subscribers on my site.
For the most part it works well but there is one occasional problem I've encountered.
Usually if a user cancels their subscription, I wait for the "end of term" (subscr_eot) notification before disabling access to my site.
So if they prepay for the whole month, and then cancel right away, they still have access for the rest of the month (as it should be).
But some users are having this problem where they:
Cancel their subscription
Before the "end of term" is reached they decide to re-subscribe
When the "end of term" is reached for their first subscription, my app receives the notification and fires off an email to the user with something like "your account has been disabled, if you ever want to sign up again, you can re-subscribe by clicking here".
This confuses them because they are thinking...that's weird, I thought I subscribed like a week ago (and they did). So they go subscribe AGAIN. Now they have two concurrent running subscriptions to my site and I get a support email in a month or two ("wtf you billed me twice this month jerk!!")
So I haven't found a good way to fix this. I guess the best solution would be to do an additional API call when the "end of term" notification is received which asks paypal "hey did this person already re-subscribe?". If so then no need to fire off that email. But I haven't seen any way to do this API call yet.
Another solution is to disable their account immediately when they cancel (the "subscr_cancel" notification) but then I get different angry support emails "hey I prepaid for the whole month why was my account disabled already!!".
Anyone else solved this?
I know this is an old thread, but I haven't seen an actual answer to this question, so if someone happens to wonder across this like I did, here's a solution.
If someone cancels their account (subscr_cancel) before their end of term (subscr_eot) I would set it up in my database to handle it. For instance, if you have a "Users" table in your database, just add a new "int" field and call it "Term." By default, this field should be set to "0." Then, inside of your IPN, set it up so that if a user cancels their subscription before the end of the term, it sets the "Term" field for that user to "1." If that user goes back and re-subscribes to your services, have the IPN update the "Term" field for that user back to "0."
Then, inside of your mailing script, just have it check the "Term" field for that user when it runs for the end of term. If it's set to "0" then don't send the email. If it's set to "1" then send the email saying, "Adios!"
As far as I know there is no paypal api to examine subscriptions if you are using website payment standard/pro buttons, which I assume you are.
I deal with this by keeping the active/cancel/resubscribe state in my database and update the state based on the IPN messages I get from paypal. I map the IPN messages to my uses with the custom field in the button, which is sent back on every IPN message.
There are also a lot of third parties which help you manage this process since paypal's api is a little weak in this area. Recurly is one I've looked at and plan to implement, and there are others out there as well.
Cite: Re: When is subscr_eot issued?
If you started accepting subscriptions after November 2009, the subscriber ID's will start 'I-' - and will not return a 'subscr_eot' at the end of their time. Paypal expect you to keep note of how long they are subscribed for and update the account to downgrade (or whatever) when that period expires, unless the customer pays again in the meantime.
How to prevent duplicate PayPal payments?
You would want to add a unique identifier to the "invoice" parameter; and enable "Block duplicate payments" within the 'Profile' > 'My selling tools' section on your account at www.paypal.com

Resources