@pipedream/shift4 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,129 @@
1
+ import { ConfigurationError } from "@pipedream/platform";
2
+ import { TYPE_OPTIONS } from "../../common/constants.mjs";
3
+ import { parseObject } from "../../common/utils.mjs";
4
+ import shift4 from "../../shift4.app.mjs";
5
+
6
+ export default {
7
+ key: "shift4-create-charge",
8
+ name: "Create Charge",
9
+ description: "Creates a new charge object. [See the documentation](https://dev.shift4.com/docs/api#charges-create-a-new-charge)",
10
+ version: "0.0.1",
11
+ type: "action",
12
+ props: {
13
+ shift4,
14
+ customerId: {
15
+ propDefinition: [
16
+ shift4,
17
+ "customerId",
18
+ ],
19
+ optional: true,
20
+ },
21
+ amount: {
22
+ propDefinition: [
23
+ shift4,
24
+ "amount",
25
+ ],
26
+ },
27
+ currency: {
28
+ propDefinition: [
29
+ shift4,
30
+ "currency",
31
+ ],
32
+ },
33
+ type: {
34
+ type: "string",
35
+ label: "Type",
36
+ description: "The type of the charge.",
37
+ options: TYPE_OPTIONS,
38
+ optional: true,
39
+ },
40
+ description: {
41
+ propDefinition: [
42
+ shift4,
43
+ "description",
44
+ ],
45
+ optional: true,
46
+ },
47
+ card: {
48
+ propDefinition: [
49
+ shift4,
50
+ "card",
51
+ ],
52
+ optional: true,
53
+ },
54
+ paymentMethod: {
55
+ type: "string",
56
+ label: "Payment Method",
57
+ description: "Payment method details or identifier.",
58
+ optional: true,
59
+ },
60
+ flow: {
61
+ type: "object",
62
+ label: "Flow",
63
+ description: "Details specific to the payment method charge.",
64
+ optional: true,
65
+ },
66
+ captured: {
67
+ type: "boolean",
68
+ label: "Captured",
69
+ description: "Whether this charge should be immediately captured.",
70
+ optional: true,
71
+ },
72
+ shipping: {
73
+ type: "object",
74
+ label: "Shipping",
75
+ description: "Shipping details. Sample object: `{name: \"string\", address: {line1: \"string\", line2: \"string\", zip: \"string\", city: \"string\", state: \"string\", country: \"country represented as two-letter ISO country code\"}}`",
76
+ optional: true,
77
+ },
78
+ billing: {
79
+ type: "object",
80
+ label: "Billing",
81
+ description: "Billing details. Sample object: `{name: \"string\", email: \"string\", address: {line1: \"string\", line2: \"string\", zip: \"string\", city: \"string\", state: \"string\", country: \"country represented as two-letter ISO country code\"}, vat: \"string\"}`",
82
+ optional: true,
83
+ },
84
+ threeDSecure: {
85
+ type: "object",
86
+ label: "3D Secure",
87
+ description: "3D Secure options.",
88
+ optional: true,
89
+ },
90
+ metadata: {
91
+ propDefinition: [
92
+ shift4,
93
+ "metadata",
94
+ ],
95
+ optional: true,
96
+ },
97
+ },
98
+ async run({ $ }) {
99
+ if (!this.customerId && !this.card && !this.paymentMethod) {
100
+ throw new ConfigurationError("Either **CustomerId**, **Card** or **PaymentMethod** is required!");
101
+ }
102
+
103
+ try {
104
+ const response = await this.shift4.createCharge({
105
+ $,
106
+ data: {
107
+ amount: this.amount,
108
+ currency: this.currency,
109
+ type: this.type,
110
+ description: this.description,
111
+ customerId: this.customerId,
112
+ card: this.card && parseObject(this.card),
113
+ paymentMethod: this.paymentMethod && parseObject(this.paymentMethod),
114
+ flow: this.flow && parseObject(this.flow),
115
+ captured: this.captured,
116
+ shipping: this.shipping && parseObject(this.shipping),
117
+ billing: this.billing && parseObject(this.billing),
118
+ threeDSecure: this.threeDSecure && parseObject(this.threeDSecure),
119
+ metadata: this.metadata && parseObject(this.metadata),
120
+ },
121
+ });
122
+
123
+ $.export("$summary", `Successfully created charge with Id: ${response.id}`);
124
+ return response;
125
+ } catch ({ message }) {
126
+ throw new ConfigurationError(JSON.parse(message).error.message);
127
+ }
128
+ },
129
+ };
@@ -0,0 +1,52 @@
1
+ import { parseObject } from "../../common/utils.mjs";
2
+ import shift4 from "../../shift4.app.mjs";
3
+
4
+ export default {
5
+ key: "shift4-create-customer",
6
+ name: "Create Customer",
7
+ description: "Creates a new customer object. [See the documentation](https://dev.shift4.com/docs/api#customers-create-a-customer)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ shift4,
12
+ email: {
13
+ type: "string",
14
+ label: "Email",
15
+ description: "The email address of the customer.",
16
+ },
17
+ description: {
18
+ type: "string",
19
+ label: "Description",
20
+ description: "A description for the customer.",
21
+ optional: true,
22
+ },
23
+ card: {
24
+ propDefinition: [
25
+ shift4,
26
+ "card",
27
+ ],
28
+ optional: true,
29
+ },
30
+ metadata: {
31
+ propDefinition: [
32
+ shift4,
33
+ "metadata",
34
+ ],
35
+ optional: true,
36
+ },
37
+ },
38
+ async run({ $ }) {
39
+ const response = await this.shift4.createCustomer({
40
+ $,
41
+ data: {
42
+ email: this.email,
43
+ description: this.description,
44
+ card: this.card && parseObject(this.card),
45
+ metadata: this.metadata && parseObject(this.metadata),
46
+ },
47
+ });
48
+
49
+ $.export("$summary", `Successfully created customer with Id: ${response.id}`);
50
+ return response;
51
+ },
52
+ };
@@ -0,0 +1,93 @@
1
+ import { parseObject } from "../../common/utils.mjs";
2
+ import shift4 from "../../shift4.app.mjs";
3
+
4
+ export default {
5
+ key: "shift4-create-plan",
6
+ name: "Create Plan",
7
+ description: "Creates a new plan object. [See the documentation](https://dev.shift4.com/docs/api#plan-create)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ shift4,
12
+ amount: {
13
+ propDefinition: [
14
+ shift4,
15
+ "amount",
16
+ ],
17
+ description: "Subscription charge amount in minor units of a given currency. For example, 10€ is represented as \"1000\", and 10¥ is represented as \"10\".",
18
+ },
19
+ currency: {
20
+ propDefinition: [
21
+ shift4,
22
+ "currency",
23
+ ],
24
+ description: "Subscription charge currency represented as a three-letter ISO currency code.",
25
+ },
26
+ interval: {
27
+ type: "string",
28
+ label: "Interval",
29
+ description: "The interval at which a plan is set to recur. Could be 'day', 'week', 'month', or 'year'.",
30
+ options: [
31
+ "day",
32
+ "week",
33
+ "month",
34
+ "year",
35
+ ],
36
+ },
37
+ name: {
38
+ type: "string",
39
+ label: "Name",
40
+ description: "The name of the plan.",
41
+ },
42
+ intervalCount: {
43
+ type: "integer",
44
+ label: "Interval Count",
45
+ description: "The number of intervals between each subscription billing. For example, if `interval`=`month` and `intervalCount`=`3`, subscriptions created with this plan will be billed every 3 months.",
46
+ optional: true,
47
+ },
48
+ billingCycles: {
49
+ type: "integer",
50
+ label: "Billing Cycles",
51
+ description: "The number of billing cycles for the payment period. If left blank, the subscription will continue indefinitely.",
52
+ optional: true,
53
+ },
54
+ trialPeriodDays: {
55
+ type: "integer",
56
+ label: "Trial Period Days",
57
+ description: "The number of trial period days granted when subscribing a customer to this plan.",
58
+ optional: true,
59
+ },
60
+ recursTo: {
61
+ propDefinition: [
62
+ shift4,
63
+ "recursTo",
64
+ ],
65
+ optional: true,
66
+ },
67
+ metadata: {
68
+ propDefinition: [
69
+ shift4,
70
+ "metadata",
71
+ ],
72
+ optional: true,
73
+ },
74
+ },
75
+ async run({ $ }) {
76
+ const {
77
+ shift4,
78
+ metadata,
79
+ ...data
80
+ } = this;
81
+
82
+ const response = await shift4.createPlan({
83
+ $,
84
+ data: {
85
+ ...data,
86
+ metadata: metadata && parseObject(metadata),
87
+ },
88
+ });
89
+
90
+ $.export("$summary", `Successfully created plan with Id: '${response.id}'`);
91
+ return response;
92
+ },
93
+ };
@@ -0,0 +1,102 @@
1
+ import shift4 from "../../shift4.app.mjs";
2
+
3
+ export default {
4
+ key: "shift4-create-token",
5
+ name: "Create Token",
6
+ description: "Creates a new token object. [See the documentation](https://dev.shift4.com/docs/api#token-create)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ shift4,
11
+ number: {
12
+ type: "string",
13
+ label: "Card Number",
14
+ description: "Card number without any separators.",
15
+ },
16
+ expMonth: {
17
+ type: "string",
18
+ label: "Expiration Month",
19
+ description: "Card expiration month.",
20
+ },
21
+ expYear: {
22
+ type: "string",
23
+ label: "Expiration Year",
24
+ description: "Card expiration year.",
25
+ },
26
+ cvc: {
27
+ type: "string",
28
+ label: "CVC",
29
+ description: "Card security code.",
30
+ },
31
+ cardholderName: {
32
+ type: "string",
33
+ label: "Cardholder Name",
34
+ description: "Name of the cardholder.",
35
+ optional: true,
36
+ },
37
+ addressLine1: {
38
+ type: "string",
39
+ label: "Address Line 1",
40
+ description: "First line of the address.",
41
+ optional: true,
42
+ },
43
+ addressLine2: {
44
+ type: "string",
45
+ label: "Address Line 2",
46
+ description: "Second line of the address.",
47
+ optional: true,
48
+ },
49
+ addressCity: {
50
+ type: "string",
51
+ label: "City",
52
+ description: "City of the address.",
53
+ optional: true,
54
+ },
55
+ addressState: {
56
+ type: "string",
57
+ label: "State",
58
+ description: "State of the address.",
59
+ optional: true,
60
+ },
61
+ addressZip: {
62
+ type: "string",
63
+ label: "Zip Code",
64
+ description: "Zip code of the address.",
65
+ optional: true,
66
+ },
67
+ addressCountry: {
68
+ type: "string",
69
+ label: "Country",
70
+ description: "Country represented as a three-letter ISO country code.",
71
+ optional: true,
72
+ },
73
+ fraudCheckData: {
74
+ type: "object",
75
+ label: "Fraud Check Data",
76
+ description: "Additional data used for fraud protection.",
77
+ optional: true,
78
+ },
79
+ },
80
+ async run({ $ }) {
81
+ const {
82
+ shift4,
83
+ fraudCheckData,
84
+ ...data
85
+ } = this;
86
+
87
+ const fraudCheck = fraudCheckData
88
+ ? JSON.stringify(fraudCheckData)
89
+ : undefined;
90
+
91
+ const response = await shift4.createToken({
92
+ $,
93
+ data: {
94
+ ...data,
95
+ fraudCheckData: fraudCheck,
96
+ },
97
+ });
98
+
99
+ $.export("$summary", `Successfully created token with Id: '${response.id}'`);
100
+ return response;
101
+ },
102
+ };
@@ -0,0 +1,20 @@
1
+ export const LIMIT = 100;
2
+
3
+ export const TYPE_OPTIONS = [
4
+ {
5
+ label: "First Recurring",
6
+ value: "first_recurring",
7
+ },
8
+ {
9
+ label: "Subsequent Recurring",
10
+ value: "subsequent_recurring",
11
+ },
12
+ {
13
+ label: "Merchant Initiated",
14
+ value: "merchant_initiated",
15
+ },
16
+ {
17
+ label: "Customer Initiated",
18
+ value: "customer_initiated",
19
+ },
20
+ ];
@@ -0,0 +1,22 @@
1
+ export const parseObject = (obj) => {
2
+ if (Array.isArray(obj)) {
3
+ return obj.map((item) => {
4
+ if (typeof item === "string") {
5
+ try {
6
+ return JSON.parse(item);
7
+ } catch (e) {
8
+ return item;
9
+ }
10
+ }
11
+ return item;
12
+ });
13
+ }
14
+ if (typeof obj === "string") {
15
+ try {
16
+ return JSON.parse(obj);
17
+ } catch (e) {
18
+ return obj;
19
+ }
20
+ }
21
+ return obj;
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/shift4",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Pipedream Shift4 Components",
5
5
  "main": "shift4.app.mjs",
6
6
  "keywords": [
@@ -11,5 +11,8 @@
11
11
  "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
12
12
  "publishConfig": {
13
13
  "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "@pipedream/platform": "^1.5.1"
14
17
  }
15
18
  }
package/shift4.app.mjs CHANGED
@@ -1,11 +1,191 @@
1
+ import { axios } from "@pipedream/platform";
2
+ import { LIMIT } from "./common/constants.mjs";
3
+
1
4
  export default {
2
5
  type: "app",
3
6
  app: "shift4",
4
- propDefinitions: {},
7
+ propDefinitions: {
8
+ amount: {
9
+ type: "integer",
10
+ label: "Amount",
11
+ description: "The charge amount in minor units of a given currency. For example, 10€ is represented as '1000'.",
12
+ },
13
+ card: {
14
+ type: "string",
15
+ label: "Card",
16
+ description: "Card token, card details or card identifier.",
17
+ },
18
+ currency: {
19
+ type: "string",
20
+ label: "Currency",
21
+ description: "The charge currency represented as a three-letter ISO currency code.",
22
+ },
23
+ customerId: {
24
+ type: "string",
25
+ label: "Customer ID",
26
+ description: "Identifier of the customer that will be associated with this charge.",
27
+ async options({ prevContext }) {
28
+ const { list } = await this.listCustomers({
29
+ params: {
30
+ limit: LIMIT,
31
+ startingAfterId: prevContext.lastId,
32
+ },
33
+ });
34
+
35
+ return {
36
+ options: list.map(({
37
+ id: value, email: label,
38
+ }) => ({
39
+ label,
40
+ value,
41
+ })),
42
+ context: {
43
+ lastId: list.length
44
+ ? list[list.length - 1].id
45
+ : null,
46
+ },
47
+ };
48
+ },
49
+ },
50
+ description: {
51
+ type: "string",
52
+ label: "Description",
53
+ description: "A description for the charge.",
54
+ optional: true,
55
+ },
56
+ metadata: {
57
+ type: "object",
58
+ label: "Metadata",
59
+ description: "Metadata object.",
60
+ },
61
+ orderIdentifier: {
62
+ type: "string",
63
+ label: "Order Identifier",
64
+ description: "The identifier of the order related to the charge that was updated.",
65
+ },
66
+ recursTo: {
67
+ type: "string",
68
+ label: "Recurs To",
69
+ description: "The plan to which this plan will recur after the billing cycles have completed.",
70
+ async options({ prevContext }) {
71
+ const { list } = await this.listPlans({
72
+ params: {
73
+ limit: LIMIT,
74
+ startingAfterId: prevContext.lastId,
75
+ },
76
+ });
77
+
78
+ return {
79
+ options: list.map(({
80
+ id: value, name: label,
81
+ }) => ({
82
+ label,
83
+ value,
84
+ })),
85
+ context: {
86
+ lastId: list.length
87
+ ? list[list.length - 1].id
88
+ : null,
89
+ },
90
+ };
91
+ },
92
+ },
93
+ },
5
94
  methods: {
6
- // this.$auth contains connected account data
7
- authKeys() {
8
- console.log(Object.keys(this.$auth));
95
+ _baseUrl() {
96
+ return "https://api.shift4.com";
97
+ },
98
+ _auth() {
99
+ return {
100
+ username: `${this.$auth.api_key_secret}`,
101
+ password: "",
102
+ };
103
+ },
104
+ _makeRequest({
105
+ $ = this, path, ...otherOpts
106
+ }) {
107
+ return axios($, {
108
+ ...otherOpts,
109
+ url: this._baseUrl() + path,
110
+ auth: this._auth(),
111
+ });
112
+ },
113
+ createCharge(opts = {}) {
114
+ return this._makeRequest({
115
+ method: "POST",
116
+ path: "/charges",
117
+ ...opts,
118
+ });
119
+ },
120
+ createPlan(opts = {}) {
121
+ return this._makeRequest({
122
+ method: "POST",
123
+ path: "/plans",
124
+ ...opts,
125
+ });
126
+ },
127
+ createToken(opts = {}) {
128
+ return this._makeRequest({
129
+ method: "POST",
130
+ path: "/tokens",
131
+ ...opts,
132
+ });
133
+ },
134
+ createCustomer(opts = {}) {
135
+ return this._makeRequest({
136
+ method: "POST",
137
+ path: "/customers",
138
+ ...opts,
139
+ });
140
+ },
141
+ listCustomers(opts = {}) {
142
+ return this._makeRequest({
143
+ path: "/customers",
144
+ ...opts,
145
+ });
146
+ },
147
+ listEvents(opts = {}) {
148
+ return this._makeRequest({
149
+ path: "/events",
150
+ ...opts,
151
+ });
152
+ },
153
+ listPlans(opts = {}) {
154
+ return this._makeRequest({
155
+ path: "/plans",
156
+ ...opts,
157
+ });
158
+ },
159
+ async *paginate({
160
+ fn, params = {}, maxResults = null, filterTypes, ...opts
161
+ }) {
162
+ let hasMore = false;
163
+ let count = 0;
164
+ let lastId = null;
165
+
166
+ do {
167
+ params.limit = LIMIT;
168
+ params.startingAfterId = lastId;
169
+ const {
170
+ list,
171
+ hasMore: hasMoreItems,
172
+ } = await fn({
173
+ params,
174
+ ...opts,
175
+ });
176
+ for (const d of list) {
177
+ if (filterTypes.includes(d.type)) {
178
+ yield d;
179
+
180
+ if (maxResults && ++count === maxResults) {
181
+ return count;
182
+ }
183
+ }
184
+ }
185
+
186
+ hasMore = hasMoreItems;
187
+
188
+ } while (hasMore);
9
189
  },
10
190
  },
11
- };
191
+ };
@@ -0,0 +1,34 @@
1
+ import common from "../common/base.mjs";
2
+ import sampleEmit from "./test-event.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "shift4-charge-updated",
7
+ name: "New Charge Updated",
8
+ description: "Emit new event when a charge object is updated.",
9
+ version: "0.0.1",
10
+ type: "source",
11
+ dedupe: "unique",
12
+ methods: {
13
+ ...common.methods,
14
+ getFilterTypes() {
15
+ return [
16
+ "CHARGE_SUCCEEDED",
17
+ "CHARGE_FAILED",
18
+ "CHARGE_UPDATED",
19
+ "CHARGE_CAPTURED",
20
+ "CHARGE_REFUNDED",
21
+ "CHARGE_DISPUTE_CREATED",
22
+ "CHARGE_DISPUTE_UPDATED",
23
+ "CHARGE_DISPUTE_WON",
24
+ "CHARGE_DISPUTE_LOST",
25
+ "CHARGE_DISPUTE_FUNDS_WITHDRAWN",
26
+ "CHARGE_DISPUTE_FUNDS_RESTORED",
27
+ ];
28
+ },
29
+ getSummary(item) {
30
+ return `New charge updated event with Id: ${item.id}`;
31
+ },
32
+ },
33
+ sampleEmit,
34
+ };
@@ -0,0 +1,49 @@
1
+ export default {
2
+ "id": "event_1234567890",
3
+ "created": 1234567890,
4
+ "objectType": "event",
5
+ "type": "CHARGE_UPDATED",
6
+ "data": {
7
+ "id": "char_1234567890",
8
+ "created": 1234567890,
9
+ "objectType": "charge",
10
+ "amount": 2000,
11
+ "amountRefunded": 0,
12
+ "currency": "USD",
13
+ "card": {
14
+ "id": "card_1234567890",
15
+ "created": 1234567890,
16
+ "objectType": "card",
17
+ "first6": "401200",
18
+ "last4": "0007",
19
+ "fingerprint": "BMophBOvfsd234h",
20
+ "expMonth": "07",
21
+ "expYear": "2027",
22
+ "cardholderName": "",
23
+ "customerId": "cust_1234567890",
24
+ "brand": "Visa",
25
+ "type": "Credit Card",
26
+ "country": "CH",
27
+ "addressLine1": "",
28
+ "addressLine2": "",
29
+ "addressCity": "",
30
+ "addressState": "",
31
+ "addressZip": "",
32
+ "addressCountry": "",
33
+ "issuer": "SHIFT4 TEST"
34
+ },
35
+ "customerId": "cust_1234567890",
36
+ "captured": true,
37
+ "refunded": false,
38
+ "disputed": false,
39
+ "fraudDetails": {
40
+ "status": "safe",
41
+ "score": 0
42
+ },
43
+ "avsCheck": {
44
+ "result": "unavailable"
45
+ },
46
+ "status": "successful",
47
+ "clientObjectId": "client_char_1234567890"
48
+ }
49
+ }
@@ -0,0 +1,63 @@
1
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
2
+ import shift4 from "../../shift4.app.mjs";
3
+
4
+ export default {
5
+ props: {
6
+ shift4,
7
+ db: "$.service.db",
8
+ timer: {
9
+ type: "$.interface.timer",
10
+ default: {
11
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
12
+ },
13
+ },
14
+ },
15
+ methods: {
16
+ _getLastDate() {
17
+ return this.db.get("lastDate") || 0;
18
+ },
19
+ _setLastDate(created) {
20
+ this.db.set("lastDate", created);
21
+ },
22
+ generateMeta(item) {
23
+ return {
24
+ id: item.id,
25
+ summary: this.getSummary(item),
26
+ ts: item.created,
27
+ };
28
+ },
29
+ async startEvent(maxResults = 0) {
30
+ const lastDate = this._getLastDate();
31
+
32
+ const data = this.shift4.paginate({
33
+ fn: this.shift4.listEvents,
34
+ maxResults,
35
+ params: {
36
+ created: {
37
+ gt: lastDate,
38
+ },
39
+ },
40
+ filterTypes: this.getFilterTypes(),
41
+ });
42
+
43
+ const responseArray = [];
44
+ for await (const item of data) {
45
+ responseArray.push(item);
46
+ }
47
+
48
+ if (responseArray.length) this._setLastDate(responseArray[0].created);
49
+
50
+ for (const item of responseArray.reverse()) {
51
+ this.$emit(item, this.generateMeta(item));
52
+ }
53
+ },
54
+ },
55
+ hooks: {
56
+ async deploy() {
57
+ await this.startEvent(25);
58
+ },
59
+ },
60
+ async run() {
61
+ await this.startEvent();
62
+ },
63
+ };
@@ -0,0 +1,24 @@
1
+ import common from "../common/base.mjs";
2
+ import sampleEmit from "./test-event.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "shift4-new-charge",
7
+ name: "New Charge",
8
+ description: "Emit new event when a new charge is successfully created.",
9
+ version: "0.0.1",
10
+ type: "source",
11
+ dedupe: "unique",
12
+ methods: {
13
+ ...common.methods,
14
+ getFilterTypes() {
15
+ return [
16
+ "CHARGE_SUCCEEDED",
17
+ ];
18
+ },
19
+ getSummary(item) {
20
+ return `New charge created event with Id: ${item.id}`;
21
+ },
22
+ },
23
+ sampleEmit,
24
+ };
@@ -0,0 +1,46 @@
1
+ export default {
2
+ "id": "event_1234567890",
3
+ "created": 1234567890,
4
+ "objectType": "event",
5
+ "type": "CHARGE_SUCCEEDED",
6
+ "data": {
7
+ "id": "char_1234567890",
8
+ "created": 1234567890,
9
+ "objectType": "charge",
10
+ "amount": 2000,
11
+ "amountRefunded": 0,
12
+ "currency": "USD",
13
+ "card": {
14
+ "id": "card_1234567890",
15
+ "created": 1234567890,
16
+ "objectType": "card",
17
+ "first6": "401200",
18
+ "last4": "0007",
19
+ "fingerprint": "BMophBO0Q123564mrty2VT",
20
+ "expMonth": "07",
21
+ "expYear": "2027",
22
+ "cardholderName": "",
23
+ "customerId": "cust_1234567890",
24
+ "brand": "Visa",
25
+ "type": "Credit Card",
26
+ "country": "CH",
27
+ "addressLine1": "",
28
+ "addressLine2": "",
29
+ "addressCity": "",
30
+ "addressState": "",
31
+ "addressZip": "",
32
+ "addressCountry": "",
33
+ "issuer": "SHIFT4 TEST"
34
+ },
35
+ "customerId": "cust_1234567890",
36
+ "captured": true,
37
+ "refunded": false,
38
+ "disputed": false,
39
+ "avsCheck": {
40
+ "result": "unavailable"
41
+ },
42
+ "status": "successful",
43
+ "clientObjectId": "client_char_1234567890"
44
+ },
45
+ "log": "log_1234567890"
46
+ }
@@ -0,0 +1,24 @@
1
+ import common from "../common/base.mjs";
2
+ import sampleEmit from "./test-event.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "shift4-new-customer",
7
+ name: "New Customer",
8
+ description: "Emit new event when a new customer is created.",
9
+ version: "0.0.1",
10
+ type: "source",
11
+ dedupe: "unique",
12
+ methods: {
13
+ ...common.methods,
14
+ getFilterTypes() {
15
+ return [
16
+ "CUSTOMER_CREATED",
17
+ ];
18
+ },
19
+ getSummary(item) {
20
+ return `New customer created event with Id: ${item.id}`;
21
+ },
22
+ },
23
+ sampleEmit,
24
+ };
@@ -0,0 +1,15 @@
1
+ export default {
2
+ "id": "event_1234567890",
3
+ "created": 1234567890,
4
+ "objectType": "event",
5
+ "type": "CUSTOMER_CREATED",
6
+ "data": {
7
+ "id": "cust_1234567890",
8
+ "created": 1234567890,
9
+ "objectType": "customer",
10
+ "email": "email@test.com",
11
+ "description": "description",
12
+ "metadata": {}
13
+ },
14
+ "log": "log_1234567890"
15
+ }