Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/payhip/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/payhip",
"version": "0.1.0",
"version": "0.1.1",
"description": "Pipedream Payhip Components",
"main": "payhip.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,6 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1"
"@pipedream/platform": "^3.1.0"
}
}
38 changes: 38 additions & 0 deletions components/payhip/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import payhip from "../../payhip.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
props: {
payhip,
http: {
type: "$.interface.http",
customResponse: true,
},
db: "$.service.db",
},
methods: {
isRelevant() {
return true;
},
generateMeta() {
throw new ConfigurationError("generateMeta is not implemented");
},
},
async run(event) {
this.http.respond({
status: 200,
});

const { body } = event;
if (!body) {
return;
}

if (!this.isRelevant(body)) {
return;
}

const meta = this.generateMeta(body);
this.$emit(body, meta);
},
};
26 changes: 26 additions & 0 deletions components/payhip/sources/customer-charged/customer-charged.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "payhip-customer-charged",
name: "Customer Charged (Instant)",

Check warning on line 7 in components/payhip/sources/customer-charged/customer-charged.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a customer is charged. Webhook of type \"paid\" must be created in Payhip Developer settings. [See the documentation](https://help.payhip.com/article/115-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
isRelevant(event) {
return event.type === "paid";
},
generateMeta(event) {
return {
id: event.id,
summary: `${event.customer_email} charged $${event.price}`,
ts: event.date,
};
},
},
sampleEmit,
};
32 changes: 32 additions & 0 deletions components/payhip/sources/customer-charged/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export default {
"id": "ZGjVj5x4GN",
"email": "johndoe@example.com",
"currency": "USD",
"price": 900,
"vat_applied": false,
"ip_address": "72.334.28.154",
"items": [
{
"product_id": "2804256",
"product_name": "The Adventures of Sherlock Holmes",
"product_key": "RGsF",
"product_permalink": "https://payhip.com/b/RGsF",
"quantity": "1",
"on_sale": false,
"used_coupon": false,
"used_social_discount": false,
"used_cross_sell_discount": false,
"used_upgrade_discount": false,
"promoted_by_affiliate": false,
"has_variant": false
}
],
"payment_type": "card",
"stripe_fee": 48,
"payhip_fee": 33,
"unconsented_from_emails": false,
"is_gift": false,
"date": 1703693218,
"type": "paid",
"signature": "dbcdccb0dfc5a57rh704bc75d7bbb18hdd3ee85f4081d5c4adbff934622919d8"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "payhip-new-subscription-created",
name: "New Subscription Created (Instant)",
description: "Emit new event when a new subscription is created. Webhook of type \"subscription.created\" must be created in Payhip Developer settings. [See the documentation](https://help.payhip.com/article/115-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
isRelevant(event) {
return event.type === "subscription.created";
},
generateMeta(event) {
return {
id: event.subscription_id,
summary: `New Subscription: ${event.subscription_id}`,
ts: event.date_subscription_started,
};
},
},
sampleEmit,
};
15 changes: 15 additions & 0 deletions components/payhip/sources/new-subscription-created/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default {
"subscription_id": "rdWQN75zjq",
"customer_id": "Q7zqVMy5Bg",
"status": "active",
"customer_email": "johndoe@example.com",
"plan_name": "Silver Plan",
"product_name": "My Course",
"product_link": "nb7fD",
"gdpr_consent": "Yes",
"date_subscription_started": 1703694529,
"customer_first_name": "John",
"customer_last_name": "Doe",
"type": "subscription.created",
"signature": "dbcdccb0dfc5a57rh704bc75d7bbb18hdd3ee85f4081d5c4adbff934622919d8"
}
26 changes: 26 additions & 0 deletions components/payhip/sources/payment-refunded/payment-refunded.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "payhip-payment-refunded",
name: "Payment Refunded (Instant)",

Check warning on line 7 in components/payhip/sources/payment-refunded/payment-refunded.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a payment is refunded. Webhook of type \"refunded\" must be created in Payhip Developer settings. [See the documentation](https://help.payhip.com/article/115-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
isRelevant(event) {
return event.type === "refunded";
},
generateMeta(event) {
return {
id: event.id,
summary: `Payment Refunded: ${event.id}`,
ts: event.date_created,
};
},
},
sampleEmit,
};
34 changes: 34 additions & 0 deletions components/payhip/sources/payment-refunded/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export default {
"id": "ZGjVj5x4GN",
"email": "johndoe@example.com",
"currency": "USD",
"price": 900,
"vat_applied": false,
"ip_address": "72.334.28.154",
"items": [
{
"product_id": "2804256",
"product_name": "The Adventures of Sherlock Holmes",
"product_key": "RGsF",
"product_permalink": "https://payhip.com/b/RGsF",
"quantity": "1",
"on_sale": false,
"used_coupon": false,
"used_social_discount": false,
"used_cross_sell_discount": false,
"used_upgrade_discount": false,
"promoted_by_affiliate": false,
"has_variant": false
}
],
"payment_type": "card",
"stripe_fee": 48,
"payhip_fee": 33,
"unconsented_from_emails": false,
"is_gift": false,
"amount_refunded": 900,
"date_refunded": 1703693410,
"date_created": 1703693218,
"type": "refunded",
"signature": "dbcdccb0dfc5a57rh704bc75d7bbb18hdd3ee85f4081d5c4adbff934622919d8"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "payhip-subscription-canceled",
name: "Subscription Canceled (Instant)",

Check warning on line 7 in components/payhip/sources/subscription-canceled/subscription-canceled.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
description: "Emit new event when a subscription is canceled. Webhook of type \"subscription.deleted\" must be created in Payhip Developer settings. [See the documentation](https://help.payhip.com/article/115-webhooks)",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
isRelevant(event) {
return event.type === "subscription.deleted";
},
generateMeta(event) {
return {
id: event.subscription_id,
summary: `Subscription Canceled: ${event.subscription_id}`,
ts: event.date_subscription_deleted,
};
},
},
sampleEmit,
};
16 changes: 16 additions & 0 deletions components/payhip/sources/subscription-canceled/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
"subscription_id": "rdWQN75zjq",
"customer_id": "Q7zqVMy5Bg",
"status": "canceled",
"customer_email": "johndoe@example.com",
"plan_name": "Silver Plan",
"product_name": "My Course",
"product_link": "nb7fD",
"gdpr_consent": "Yes",
"date_subscription_started": 1703694529,
"date_subscription_deleted": 1703694700,
"customer_first_name": "John",
"customer_last_name": "Doe",
"type": "subscription.deleted",
"signature": "dbcdccb0dfc5a57rh704bc75d7bbb18hdd3ee85f4081d5c4adbff934622919d8"
}
Loading
Loading