BigCommerce API Webhook event payload with address created/updated is missing customer_id - webhooks

From the WebHook documentation for a store/customer/address/updated/store/customer/address/created events should have following payload:
{
"scope": "store/customer/address/created",
"store_id": "1025646",
"data": {
"type": "customer",
"id": 60,
"address": {
"customer_id": 32
}
},
"hash": "416ca9c01779515de91824aa1cac9012ee691e7a",
"created_at": 1561481620,
"producer": "stores/{store_hash}"
}
However, in the logs we don't see the "address" part. The payload is always coming as:
{
created_at: 1573847377
data: {
id: 2246136
type: "customer"
}
hash: "%hash%"
producer: "%producer%"
scope: "store/customer/address/updated"
store_id: "%storeid%"
}
And the payload.data.id is not the customer id, as fetching customer by given ID always results in 404.
Fetching address with given id is also impossible, as the resource url should include customer_id which is absent in the response.
Contacted BigCommerce support already, but maybe someone had solved this issue already?
Saw relevant question in the BigCommerce's community, but it was also unanswered.

I have encountered a similar problem, and believe I have isolated the conditions under which it occurs.
I am building an app with MEAN stack that uses bigcommerce API/webhooks.
When I tried to create a customer address in-app, it makes an API request to BigCommerce and creates customer addresses in BigCommerce. Via the webhooks, I have implemented the store_customer_address_created hook event.
So there are two cases when the address webhook event is being triggered:
When the customer address is created in-app and it sends an address creation request via the API to BigCommerce.
When the customer address is directly created in the BigCommerce admin.
Here are the responses from those:
"scope": "store/customer/address/created",
"store_id": "1025646",
"data": {
"type": "customer",
"id": 60,
},
"hash": "416ca9c01779515de91824aa1cac9012ee691e7a",
"created_at": 1561481620,
"producer": "stores/{store_hash}"
}
{
"scope": "store/customer/address/created",
"store_id": "1025646",
"data": {
"type": "customer",
"id": 60,
"address": {
"customer_id": 32
}
},
"hash": "416ca9c01779515de91824aa1cac9012ee691e7a",
"created_at": 1561481620,
"producer": "stores/{store_hash}"
}
As you can see, the address field is not included when the customer address is being created by the API. I’m not sure if it is designed by the BigCommerce team, or a special case. But I think we can identify if the customer address is being created by the BigCommerce admin directly or via the API myself based on this distinction.
I believe you are encountering the first case on your end.
I hope this helps and please update me if you have any other opinions.

It is fairly strange to see this webhook response without the address field, and I haven't had any luck replicating this with scope for store/customer/address/updated. Are you working with any other code beyond this webhook or testing the webhook event specifically?

Related

Stripe Orders API tax callback

Trying to setup dynamic tax calcuation using Stripe Orders API. Using these docs:
https://stripe.com/docs/orders
https://stripe.com/docs/orders/dynamic-shipping-taxes
result = {
"order_update": {
"items": [
{
"parent": None,
"type": "tax",
"description": "Sales taxes",
"amount": 100,
"currency": "usd"
}
],
"shipping_methods": [
{
"id": "free_shipping",
"description": "Free 7-day shipping",
"amount": 0,
"currency": "usd",
"delivery_estimate": {
"type": "exact",
"date": "2020-08-11"
},
"tax_items": []
}
]
}
}
print(result)
return Response(result, status=status.HTTP_200_OK)
Even dummy response without any sophisticated computations failed to create an order object with HTTP 402 error for script trying to create Order
Creating order with no tax specified works as well and allows to create order.
Webservice running a callback receives a request from the Stripe as it must and works as well.
Stripe support says only "we no longer recommend developing your integration around this system" and does not answer directy if they turn off this feature.
If they turn off this feature I do not understand why it is available in the dashboard.
The issue was in the middleware of my service. It transformed response keys from snake_case to camelCase. Resolved.

How can I setup taxes and make them included in the subscription price paypal sdk

So I live in europe and we are obligated to have taxes already included in the price displayed to the user and I was wondering how I could do this with Paypal sdk.
My billing_plan_attributes:
billing_plan_attributes = {
"name": request.args['name'],
"description": request.args['description'],
"merchant_preferences": {
"auto_bill_amount": "yes",
"cancel_url": "https://ruby-eu.com/profile/settings/paypal/cancel/token",
"initial_fail_amount_action": "continue",
"max_fail_attempts": "1",
"return_url": 'https://ruby-eu.com/profile/settings/paypal/subscribe/execute',
"setup_fee": {
"currency": request.args['currency'],
"value": request.args['setup_fee']
}
},
"payment_definitions": [
{
"amount": {
"currency": request.args['currency'],
"value": request.args['amount']
},
"cycles": request.args['cycles'],
"frequency": request.args['frequency'],
"frequency_interval": request.args['frequency_interval'],
"name": request.args['payment_name'],
"type": request.args['payment_type'],
}
],
"type": request.args['type']
}
I tried adding
"taxes": {
"percentage": "23",
"inclusive": True
}
inside merchant_preferences, payment_defenitions and under type but when I run it they return
Problem while creating a new plan: Incoming JSON request does not map to API request
and I don't know how could I fix this issue.
In case you're wondering if the problem is somewhere else I removed the taxes from the JSON and run and it worked.
First of all know that the depcrecated billing plan object in the Python SDK does NOT correspond to the new plans object in the new Subscriptions API. If you want to use the Subscriptions API (and you probably should), you need to integrate with direct HTTPS API calls, NOT any of the old SDKs. Basically, look at the CURL calls you see here: https://developer.paypal.com/docs/subscriptions/integrate/ ... and implement their equivalents from Python.
The billing plans objects of the Subscriptions API do support the syntax you were trying to add, so my guess is that is where you got it from: https://developer.paypal.com/docs/api/subscriptions/v1/#plans_create

Request timeout in API.AI

I have an API.ai agent that sends a request (comes from the user) to a webhook which needs a lot of processing (more than 5 sec) to get the answer. As far as I know, that there is no way to increase the response timeout in API.ai
So, I have created 2 intents. The first one simply will call my webhook to start the processing the result, and at the same time the webhook will reply to the user, "Your request is under processing...".
The second intent has an event and action. The purpose of the new event is just to display the result to the user.
Once the result is ready, my backend application will send a curl statement to trigger the event in the second intent with the necessary parameter modifications like sessionID, v, and time zone … etc.
I have received the following JSON from API.AI (I created an example to simplify my case):
{ "id": "de31ee96-c42f-4f2d-8461-ee39279ec2ed", "timestamp": "2017-09-27T13:39:46.932Z", "lang": "en", "result": {
"source": "agent",
"resolvedQuery": "custom_event",
"action": "test",
"actionIncomplete": false,
"parameters": {
"user_name": "Sam"
},
"contexts": [
{
"name": "welcoming-followup",
"parameters": {
"name.original": "",
"user_name": "Sam",
"name": "",
"user_name.original": ""
},
"lifespan": 2
}
],
"metadata": {
"intentId": "c196a388-16ac-4966-b55c-7cd999a7d680",
"webhookUsed": false,
"webhookForSlotFillingUsed": "false",
"intentName": "Welcoming"
},
"fulfillment": {
"speech": "Hello Sam",
"messages": [
{
"type": 0,
"speech": "Hello Sam"
}
]
},
"score": 1.0 }, "status": {
"code": 200,
"errorType": "success" }, "sessionId": "67cb28fd-6871-750c-d668-d0b736b763ec" }
Here is the curl statement that was sent by my backend.
The curl statement is: curl -X POST -H "Content-Type: application/json; charset=utf-8" -H "Authorization: Bearer I INSERTED THE CORRECT CODE HERE" --data "{'event':{ 'name': 'custom_event', 'data': {'name': 'Sam'}}, 'timezone':'America/New_York', 'lang':'en', 'sessionId':'a6ac2555-4b19-40f8-92ec-397f6a042dde'}" "https://api.api.ai/v1/query?v=20150910"
As shown from the above JSON, the API.ai agent received the trigger successfully. But, The response that I have specified in the “Response Section” does not appear to the user.
I attached a screenshot for the second intent in the API.ai agent.
Note: I tried the agent in developer console, WebDemo and Slack. None of them shown to me (as a user) the specified response.
I am not sure if I did something wrong?
screenshot of the second intent
API.AI is not really meant to handle event-driven activities. It is meant to be the intermediary in a conversation - so the normal pattern is:
User says something
API.AI processes this, possibly with a webhook, and sends a response.
Devices such as Google Home do not have a way to get a notification, so unless the user says something (step 1), then you will never get to step 2.
When you try to trigger it manually, API.AI is treating your trigger as the step 1, and it is replying to your trigger. It has no way to send that reply back to the Assistant because it isn't having a conversation with the Assistant at that moment - it is having a conversation with however you manually triggered it.
There isn't really a good way to do what you want right now. We know notifications are coming to the Assistant eventually (it was announced at I/O 2017), but we don't know if it will have an API or what it will look like. The Transaction API does have notifications as part of it, but Transactions are meant for activities where you are purchasing or reserving something. If you need to, you can use something like Firebase Cloud Messaging to let your user know they can ask for the result, but that's a sub-optimal experience.

Create room reservations using Domino data services REST API

I've been attempting to create room bookings using the Domino data services REST API but I seem to be missing a trick.
Sending a POST request to the document endpoint I am able to submit and create a reservation document which appears in the Rooms and resource view but the underlying room still shows as available in the notes client.
Here is a sample of the request body:
{
"#authors": [
"CN=Andrew Jones/O=MyCorp",
""
],
"#form": "Reservation",
"From": "CN=Andrew Jones/O=MyCorp",
"Chair": "CN=Andrew Jones/O=MyCorp",
"AltChair": "CN=Andrew Jones/O=MyCorp",
"Principal": "CN=Andrew Jones/O=MyCorp",
"SequenceNum": 1,
"OrgState": "5",
"ResourceType": "1",
"ResourceName": "Room/Office",
"ROOM": "Room/Office#MyCorp",
"Capacity": 1,
"AppointmentType": "3",
"StartTimeZone": "Z=0$DO=1$DL=3 -1 1 10 -1 1$ZX=47$ZN=GMT",
"EndTimeZone": "Z=0$DO=1$DL=3 -1 1 10 -1 1$ZX=47$ZN=GMT",
"TOPIC": "Test",
"SendTo": "CN=Room/O=Office",
"SelectedRR": "CN=Room/O=Office",
"$BusyName":"CN=Room/O=Office",
"Encrypt": "0",
"Categories": "",
"RouteServers": "CN=dominonode/O=MyCorp",
"DeliveredDate": { "data":"2017-03-09T12:38:34Z","type":"datetime"},
"StartDate": {"data":"2017-03-09T20:00:00Z","type":"datetime"},
"StartTime": {"data":"2017-03-09T20:00:00Z","type":"datetime"},
"StartDateTime": {"data":"2017-03-09T20:00:00Z","type":"datetime"},
"EndDate": {"data":"2017-03-09T21:00:00Z","type":"datetime"},
"EndTime": {"data":"2017-09-03T21:00:00Z","type":"datetime"},
"EndDateTime": {"data":"2017-03-09T21:00:00Z","type":"datetime"},
"CalendarDateTime": {"data":"2017-03-09T20:00:00Z","type":"datetime"},
"UpdateSeq": 1,
"Author": "CN=Andrew Jones/O=MyCorp",
"ResourceOwner": "",
"ReservedFor": "CN=Andrew Jones/O=MyCorp",
"ReservedBy": "CN=Andrew Jones/O=MyCorp",
"RQStatus": "A",
"Purpose": "API Test",
"NoticeType": "A",
"Step": 3,
"Site": "Office",
"ReserveDate": {"data":"2017-03-09T20:00:00Z","type":"datetime"}
}
This question suggests I should instead be trying to create a Calendar event but everything I send seems to get rejected with bad request, including the sample
I've also looked at another question which suggests I need to create an appointment and then a notice document for the room, but whilst I can create these documents, it doesn't seem to create a reservation.
Has anyone tried this and got it to work or am I just joining the elephant's graveyard?
I recommend registering a special "user" to act as the booking agent. Then you can use the calendar API to book any room. I think this approach will work better than the data API.
Details:
Register a new "user" to act as the booking agent. Let's call the user "Room Agent/MyCorp". The user's mail file is "mail/ragent.nsf".
Make sure the calendar API is enabled on a mail server with a replica of "mail/ragent.nsf".
When someone uses your tablet app to book a room, the app sends a request to create an event on the room agent's calendar (POST /mail/ragent.nsf/api/calendar/events). The new event should include the room in the list of attendees.
The calendar API sends an invitation to the room (actually the resource database). As long as the room is not already booked, the resource database accepts the invitation and the room becomes busy for that time slot.
This saves you from having to deal with the data API and the intricacies of the resource database. Your tablet app just needs to know the mail server host name, the name of the mail file, and the room agent's credentials. I also like the idea of being able to "audit" all bookings originating from your tablet app. You'll be able to find all the events and notices (accept or decline) in the room agent's mail file.
One disadvantage is booking will not be instantaneous, but the resource database should be able to accept an invitation in a matter of seconds.
By the way, here is some sample JSON input for your POST request:
{
"events":[
{
"summary":"Calendar API test",
"location":"test",
"description":"test",
"start":{"date":"2018-01-01","time":"13:00:00","utc":true},
"end":{"date":"2018-01-01","time":"14:00:00","utc":true},
"organizer":{"email":"ragent#mycorp.com"},
"attendees":[
{
"role":"req-participant",
"userType":"room",
"status":"needs-action",
"rsvp":true,
"email":"room#mycorp.com"
}
]
}
]
}
It's important to specify "userType":"room" for the attendee. Otherwise, the resource database won't accept the invitation.

SurveyMonkey Webhook Event Data

I am having difficulty interpreting the results of the webhook event data being returned. If this is the data being returned:
{
"name":"Test Webhook",
"event_id":"EVENT ID HERE",
"object_type":"response",
"object_id":"OBJECT ID HERE",
"event_datetime":"2017-01-12T15:10:18.667701+00:00",
"event_type":"response_completed"
}
I understand that the object_id corresponds to the responseId but I am trying to figure out where the surveyId is?
When we get the event data back, we need to make an API call to:
'surveys/'.$surveyId.'/responses/'.$responseId.'/details' so that we can get the details for processing.
Any help is greatly appreciated.
The webhook data sent to your subscription URL has recently been updated. See the details in the docs.
The payload has some new values, it looks something like this now (depending on your event type):
{
"name": "My Webhook",
"filter_type": "collector", (or survey, it's based on how they configure the webhook)
"filter_id": "123456789",
"event_type": "response_completed",
"event_id": "123456789",
"object_type": "response",
"object_id": "123456",
"event_datetime": "2016-01-01T21:56:31.182613+00:00",
"resources": {
"respondent_id": "123456789",
"recipient_id": "123456789",
"collector_id": "123456789",
"survey_id": "123456789",
"user_id": "123456789"
}
}
So if your event was "response_completed" then object_id is the response ID. If you filtered to a specific type of survey then the filter_id is the survey ID.
As well there is a resources key with a bunch of relevant IDs.

Resources