How to get payment Details at PayPal Subscription with php? - events

Im setting up a subscription with PayPal and php. So far I know that if the event PAYMENT.SALE.COMPLETED is called the payment was successful. To process the payment at my webhook I need more details about the payment (Who payed? What plan or subscription?). How can I get more details? Is it about the IDs?
This is the event body of an test event:
{
"id": "WH-2WR32451HC0233532-67976317FL4543714",
"create_time": "2014-10-23T17:23:52Z",
"resource_type": "sale",
"event_type": "PAYMENT.SALE.COMPLETED",
"summary": "A successful sale payment was made for $ 0.48 USD",
"resource": {
"parent_payment": "PAY-1PA12106FU478450MKRETS4A",
"update_time": "2014-10-23T17:23:04Z",
"amount": {
"total": "0.48",
"currency": "USD"
},
"payment_mode": "ECHECK",
"create_time": "2014-10-23T17:22:56Z",
"clearing_time": "2014-10-30T07:00:00Z",
"protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
"protection_eligibility": "ELIGIBLE",
"links": [
...
],
"id": "80021663DE681814L",
"state": "completed"
},
"links": [
...

A real (non-webhook-test-simulator) event should have the subscription ID (I-#### number) of the subscription that the payment corresponds to. You should have stored that ID in your own user's profile at subscription creation time.
Another approach is to pass your own custom_id at subscription creation time.
You can test all of this in sandbox mode.

Related

How to send an Adaptive card to Compose Box after calling microsoftTeams.tasks.submitTask(data) from botframework

I'm trying to implement a team Messaging Extensions app which include a compose action, a task module and a bot. The action is defined in the app manifest file to bring up a html page through a task module(step 1), the html page collects user data and uses "microsoftTeams.tasks.submitTask(data)" to submit data to the bot(step 2), then close the dialog(step 3). Once the bot receives the data, it sends an Adaptive card to the compose box(step 4) so the user can post the card to chat.
My question here is how the Step 4 can be implemented in my bot. I am looking at the TeamsActivityHandler.onTeamsTaskModuleSubmit() method, I can see the submitted data, and I can return a TaskModuleResponse object which can be either a text message or an other task module. However I can't find any documentation or code samples to send an Adaptive card to the compose box.
Any suggestion will be appreciated.
Here is the definition of the action in my app manifest:
"composeExtensions": [
{
"botId": "b675870e-697f-4672-b4f2-64adafcxxxxx",
"canUpdateConfiguration": true,
"commands": [
{
"id": "commandId",
"type": "action",
"title": "new customer",
"fetchTask": false,
"context": [
"compose",
],
"taskInfo": {
"title": "create new customer",
"width": "medium",
"height": "medium",
"url": "https://fd5b-205-211-178-000.ngrok.io/upload.html"
}
}
]
}
]
Please go through the below documentation for your reference:
https://learn.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/what-are-messaging-extensions#action-commands
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/51.teams-messaging-extensions-action

Microsoft Graph Communications - Bot joining call - Microsoft Teams

Ok. So let me try to set the stage here.
I have a Microsoft Teams Application that has a Bot (Bot Framework v4) associated with it.
I have a use case where when a specific type of compliance activity happens, I need my bot to join the scheduled meeting and participate.
I am able to send a meeting invitation to an email account associated with the bot, and the bot accepts the invite.
According to this documentation, I should be able to join the meeting in progress.
(https://learn.microsoft.com/en-us/graph/api/application-post-calls?view=graph-rest-1.0&tabs=http) - Specifically "Example 5"
According to what I am reading, once you have the required Graph Permissions on your App Id that's associated, you only need 3 pieces of information to join the call (Passed in through a communications/call/create).
Post to https://graph.microsoft.com/v1.0/communications/calls :
Body:
{
"#odata.type": "#microsoft.graph.call",
"callbackUri": "https://bot.contoso.com/callback",
"requestedModalities": [
"audio"
],
"mediaConfig": {
"#odata.type": "#microsoft.graph.serviceHostedMediaConfig",
"preFetchMedia": []
},
"chatInfo": {
"#odata.type": "#microsoft.graph.chatInfo",
"threadId": "19:meeting_XXXXXXXXXXXXXXXX#thread.v2",
"messageId": "0"
},
"meetingInfo": {
"#odata.type": "#microsoft.graph.organizerMeetingInfo",
"organizer": {
"#odata.type": "#microsoft.graph.identitySet",
"user": {
"#odata.type": "#microsoft.graph.identity",
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"displayName": "Drew Jenkel"
}
},
"tenantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"allowConversationWithoutHost": true
}
}
Upon doing this, I'm getting a 403 / Forbidden:
{
"error": {
"code": "7505",
"message": "Request authorization tenant mismatch.",
"innerError": {
"request-id": "30739bd2-37b2-4bfc-9c52-36d72a4aa54e",
"date": "2020-06-08T16:47:36"
}
}
}
Has anyone seen anything this this?

How do we get to know to which response user has reacted(like/dislike) on MS teams?

We need help in understanding how Microsoft teams like and dislike works with BotFramework. When user clicks on like option provided in background we are getting reactionID but how do we get to know for which specific message user has given his feedback. Do we have this feasibility on Teams?
You can find it in the replyToId. Example from the docs:
The messageReaction event is sent when a user adds or removes his or her reaction to a message which was originally sent by your bot. replyToId contains the ID of the specific message.
{
"reactionsAdded": [
{
"type": "like"
}
],
"type": "messageReaction",
"timestamp": "2017-10-16T18:45:41.943Z",
"id": "f:9f78d1f3",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0O-Iy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA",
"aadObjectId": "c33aafc4-646d-4543-9d4c-abd28e4d2110"
},
"conversation": {
"isGroup": true,
"id": "19:3629591d4b774aa08cb0887902eee7c1#thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterLocal"
},
"channelData": {
"channel": {
"id": "19:3629591d4b774aa08cb0887902eee7c1#thread.skype"
},
"team": {
"id": "19:efa9296d959346209fea44151c742e73#thread.skype"
},
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
},
"replyToId": "1:19uJ8TZA1cZcms7-2HLOW3pWRF4nSWEoVnRqc0DPa_kY"
}
Note, however, that this replyToId is specific to Teams and I don't believe it will persist if you set it yourself. Once you have that, you can update the activity.
If you're trying to analyze which messages are reacted to, you might want to log the outgoing activity's Id and Text in TurnContext.OnSendActivities. Then, when a reaction comes in, you can use the new Activity Handler to handle the message and add the reaction to your log. I believe this would come in OnUnrecognizedActivityTypeAsync. This is similar to the previous link, update the activity.

Trustpilot invitation api weird result

Trying to create invitations using their API, I get a proper result back, however the status is "notsent". There is zero debug information to go by, so I'm wondering if anyone else has seen this and might have ideas for fixing the issue.
Here's an example of a response I got from their api:
{
"businessUnitId": "<business unit id here>",
"businessUserId": "<business user id here>",
"createdTime": "2018-10-02T09:58:35.135569Z",
"id": "<invitation id here>",
"locale": "da-DK",
"preferredSendTime": "2018-10-09T09:58:34Z",
"recipient": {
"email": "<email goes here>",
"name": "<name goes here>"
},
"redirectUri": "http://trustpilot.com",
"referenceId": "<our ref id>",
"replyTo": "trustpilot#boozt.com",
"sender": {
"email": "noreply.invitations#trustpilotmail.com",
"name": "Booztlet.com"
},
"sentTime": null,
"source": "InvitationApi",
"status": "notsent",
"tags": [],
"templateId": "57cfc1a660e1cc0620b53a38"
}
So, the NotSent status code is expected for new invitations. This is because invitations are sent asynchronously - at around the time you put in as your "preferredSendTime".
If you login to your account at https://businessapp.b2b.trustpilot.com/#/invitations/invitation-history, you should be able to see the invitation you created, and whether it was sent or not (since you specified October 9th as your preferredSendTime, the invitation will still be queued until that point)

Is there any way to get refund details (ie. which items have been returned)?

I am working on integration and need to get the refunded items inventory adjusted in our ERP. But I'm not getting any information about what items have actually been returned. I've tried the refunds as well as the payments endpoints.
"refunds": [
{
"type": "PARTIAL",
"created_at": "2017-08-03",
"processed_at": "2017-08-03",
"reason": "Returned Goods",
"refunded_money": {
"amount": -1100,
"currency_code": "USD"
},
"payment_id": "XXXXXXXXX",
"merchant_id": "XXXXXXXXXXX",
"refunded_processing_fee_money": {
"amount": 0,
"currency_code": "USD"
}
=====> ITEM_ID????
}]
Have you looked at the v1 Payments endpoint? That should have the itemization information you need for each refund.
Most developers use the inventory endpoints to do full syncs of other inventory management systems however.

Resources