HTTP POST - Webshop - payhip.com

Hello everybody,

i have a small shop that can send information via webhooks. I would like to use this interface to be informed about an item that has been sold.

Here’s the info on what’s provided there:
https://payhip.com/support/webhooks/

I would be happy if someone can help me implement it.

Greeting

You need to setup an end point to receive the data and translate it into something that openHAB understands and send the data through.

What do you imagine happening when you get the data?

You could just create a string item and post to that install the rest docs to have a look. What version of openHAB is this for?

Hi, thanks for your answer.
I would like to see the price and create a rule from it.
But transferring the value to openhab -> Thing -> Item -> Rule … I need help for that.
I am using openHAB3.

Ok I am using oh2 still for my production that is connected to the cloud connector but this should still work.

Install the https://myopenhab.org/ cloud connector integration
openHAB Cloud Connector - System Integrations | openHAB
Its free for users but costs the foundation and every dollar helps Donate | openHAB if you can.

Create a String Item maybe Webhook for example

Now in payhip set the webhook to goto

https://email:password@home.myopenhab.org/rest/items/Webhook

change @ in email to %40

This is the first step in getting the JSON message into openHAB

Hey.

my oh3 is already connected to the cloud.
I created an item called “Webhook” and created it as the “String” type.

Then to test I went to “https://reqbin.com/”. → Picture attached.
But the values do not reach the system. Do I have to see that under items in the cloud?

Result:

Hey

I still tested a bit.
If I change from “JSON” to “text” on https://reqbin.com/, the values arrive in the oh3.
Unfortunately I need “JSON”.

Yeah 415 is a unsupported media type but its all just data and of you get that data into openHAB you can do something with it.

Assuming you get text data into your string item Webhook

In settings/transformations install JSONpath transformation.

Time to create a rule where When Webhook received a command.

Then add action / run script / Rule DSL

Then write what you want to happen when data comes in :slight_smile:

val price = transform("JSONPATH", "$.price", Webhook.state.toString)
logInfo("Order Recieved", "Price = " + price)

Code tab

triggers:
  - id: "1"
    configuration:
      itemName: Webhook
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: |-
        val price = transform("JSONPATH", "$.price", Webhook.state.toString)
        logInfo("Order Recieved", "Price = " + price)
    type: script.ScriptAction

Now you should see the price in your log file.

Great. I followed your instructions and it works when it comes as TEXT.
I’m trying to contact the shop owner / host to see if it is possible to switch to TEXT.

How do I get the value in an item now?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.