From 0cd53acb4aee5b657d5f96baf683353b2179a845 Mon Sep 17 00:00:00 2001 From: kylebuilds Date: Sun, 29 Oct 2023 16:28:25 -0700 Subject: [PATCH 1/3] stripe actions/triggers --- packages/pieces/stripe/src/index.ts | 58 ++- .../src/lib/actions/create-subscription.ts | 49 ++ .../stripe/src/lib/actions/search-charge.ts | 31 ++ .../stripe/src/lib/actions/search-customer.ts | 71 +-- .../stripe/src/lib/actions/search-invoice.ts | 31 ++ .../pieces/stripe/src/lib/common/index.ts | 118 +++-- .../pieces/stripe/src/lib/common/samples.ts | 493 ++++++++++++++++++ .../src/lib/trigger/canceled-subscription.ts | 42 ++ .../lib/trigger/checkout-session-complete.ts | 42 ++ .../src/lib/trigger/invoice-payment-failed.ts | 42 ++ .../stripe/src/lib/trigger/new-customer.ts | 46 +- .../stripe/src/lib/trigger/new-dispute.ts | 42 ++ .../stripe/src/lib/trigger/new-invoice.ts | 39 ++ .../stripe/src/lib/trigger/new-payment.ts | 111 +--- .../stripe/src/lib/trigger/new-refund.ts | 39 ++ .../src/lib/trigger/new-subscription.ts | 185 ++----- .../stripe/src/lib/trigger/payment-failed.ts | 190 +------ .../src/lib/trigger/updated-subscription.ts | 42 ++ 18 files changed, 1134 insertions(+), 537 deletions(-) create mode 100644 packages/pieces/stripe/src/lib/actions/create-subscription.ts create mode 100644 packages/pieces/stripe/src/lib/actions/search-charge.ts create mode 100644 packages/pieces/stripe/src/lib/actions/search-invoice.ts create mode 100644 packages/pieces/stripe/src/lib/common/samples.ts create mode 100644 packages/pieces/stripe/src/lib/trigger/canceled-subscription.ts create mode 100644 packages/pieces/stripe/src/lib/trigger/checkout-session-complete.ts create mode 100644 packages/pieces/stripe/src/lib/trigger/invoice-payment-failed.ts create mode 100644 packages/pieces/stripe/src/lib/trigger/new-dispute.ts create mode 100644 packages/pieces/stripe/src/lib/trigger/new-invoice.ts create mode 100644 packages/pieces/stripe/src/lib/trigger/new-refund.ts create mode 100644 packages/pieces/stripe/src/lib/trigger/updated-subscription.ts diff --git a/packages/pieces/stripe/src/index.ts b/packages/pieces/stripe/src/index.ts index 0262a035fd..99a676bd23 100644 --- a/packages/pieces/stripe/src/index.ts +++ b/packages/pieces/stripe/src/index.ts @@ -1,25 +1,53 @@ import { PieceAuth, createPiece } from '@activepieces/pieces-framework'; -import {stripeNewPayment} from "./lib/trigger/new-payment"; -import {stripeNewCustomer} from "./lib/trigger/new-customer"; -import {stripePaymentFailed} from "./lib/trigger/payment-failed"; +import { stripeNewPayment } from './lib/trigger/new-payment'; +import { stripeNewCustomer } from './lib/trigger/new-customer'; +import { stripePaymentFailed } from './lib/trigger/payment-failed'; import { stripeNewSubscription } from './lib/trigger/new-subscription'; import { stripeCreateCustomer } from './lib/actions/create-customer'; import { stripeCreateInvoice } from './lib/actions/create-invoice'; import { stripeSearchCustomer } from './lib/actions/search-customer'; - +import { stripeCreateSubscription } from './lib/actions/create-subscription'; +import { stripeSearchCharge } from './lib/actions/search-charge'; +import { stripeSearchInvoice } from './lib/actions/search-invoice'; +import { stripeCanceledSubscription } from './lib/trigger/canceled-subscription'; +import { stripeCheckoutSessionComplete } from './lib/trigger/checkout-session-complete'; +import { stripeInvoicePaymentFailed } from './lib/trigger/invoice-payment-failed'; +import { stripeNewDispute } from './lib/trigger/new-dispute'; +import { stripeNewInvoice } from './lib/trigger/new-invoice'; +import { stripeNewRefund } from './lib/trigger/new-refund'; +import { stripeUpdatedSubscription } from './lib/trigger/updated-subscription'; export const stripeAuth = PieceAuth.SecretText({ - displayName:"Secret API Key", - required:true, - description:"Secret key acquired from your Stripe dashboard" -}) + displayName: 'Secret API Key', + required: true, + description: 'Secret key acquired from your Stripe dashboard', +}); export const stripe = createPiece({ - displayName: "Stripe", - minimumSupportedRelease: '0.5.0', - logoUrl: 'https://cdn.activepieces.com/pieces/stripe.png', - authors: ['ashrafsamhouri', 'lldiegon'], - auth: stripeAuth, - actions: [stripeCreateCustomer, stripeCreateInvoice, stripeSearchCustomer], - triggers: [stripeNewPayment, stripeNewCustomer, stripePaymentFailed, stripeNewSubscription], + displayName: 'Stripe', + minimumSupportedRelease: '0.5.0', + logoUrl: 'https://cdn.activepieces.com/pieces/stripe.png', + authors: ['ashrafsamhouri', 'lldiegon', 'TaskMagicKyle'], + auth: stripeAuth, + actions: [ + stripeCreateCustomer, + stripeCreateInvoice, + stripeSearchCustomer, + stripeCreateSubscription, + stripeSearchCharge, + stripeSearchInvoice, + ], + triggers: [ + stripeNewPayment, + stripeNewCustomer, + stripePaymentFailed, + stripeNewSubscription, + stripeCanceledSubscription, + stripeCheckoutSessionComplete, + stripeInvoicePaymentFailed, + stripeNewDispute, + stripeNewInvoice, + stripeNewRefund, + stripeUpdatedSubscription, + ], }); diff --git a/packages/pieces/stripe/src/lib/actions/create-subscription.ts b/packages/pieces/stripe/src/lib/actions/create-subscription.ts new file mode 100644 index 0000000000..807f267b57 --- /dev/null +++ b/packages/pieces/stripe/src/lib/actions/create-subscription.ts @@ -0,0 +1,49 @@ +import { createAction, Property } from '@activepieces/pieces-framework'; +import { httpClient, HttpMethod } from '@activepieces/pieces-common'; +import { stripeAuth } from '../..'; +import { stripeCommon } from '../common'; + +export const stripeCreateSubscription = createAction({ + name: 'create_subscription', + auth: stripeAuth, + displayName: 'Create Subscription', + description: 'Create a subscription in stripe', + props: { + customer_id: Property.ShortText({ + displayName: 'Customer ID', + description: 'Stripe Customer ID', + required: true, + }), + price_id: stripeCommon.prices, + quantity: Property.Number({ + displayName: 'Quantity', + description: 'Quantity of the subscription', + required: true, + }), + }, + async run(context) { + const subscription = { + customer: context.propsValue.customer_id, + items: [ + { + price: context.propsValue.price_id, + quantity: context.propsValue.quantity, + }, + ], + }; + + const response = await httpClient.sendRequest({ + method: HttpMethod.POST, + url: 'https://api.stripe.com/v1/invoices', + headers: { + Authorization: 'Bearer ' + context.auth, + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: { + customer: subscription.customer, + items: subscription.items, + }, + }); + return response.body; + }, +}); diff --git a/packages/pieces/stripe/src/lib/actions/search-charge.ts b/packages/pieces/stripe/src/lib/actions/search-charge.ts new file mode 100644 index 0000000000..91215c190a --- /dev/null +++ b/packages/pieces/stripe/src/lib/actions/search-charge.ts @@ -0,0 +1,31 @@ +import { createAction, Property } from '@activepieces/pieces-framework'; +import { httpClient, HttpMethod } from '@activepieces/pieces-common'; +import { stripeAuth } from '../..'; + +export const stripeSearchCharge = createAction({ + name: 'search_charge', + auth: stripeAuth, + displayName: 'Search Charge', + description: 'Search for a charge in stripe by ID', + props: { + charge_id: Property.ShortText({ + displayName: 'Charge ID', + description: undefined, + required: true, + }), + }, + async run(context) { + const charge = { + id: context.propsValue.charge_id, + }; + const response = await httpClient.sendRequest({ + method: HttpMethod.GET, + url: 'https://api.stripe.com/v1/charges/' + charge.id, + headers: { + Authorization: 'Bearer ' + context.auth, + 'Content-Type': 'application/x-www-form-urlencoded', + }, + }); + return response.body; + }, +}); diff --git a/packages/pieces/stripe/src/lib/actions/search-customer.ts b/packages/pieces/stripe/src/lib/actions/search-customer.ts index a2a1e183bc..67ad1623ee 100644 --- a/packages/pieces/stripe/src/lib/actions/search-customer.ts +++ b/packages/pieces/stripe/src/lib/actions/search-customer.ts @@ -1,34 +1,41 @@ -import { createAction, Property } from "@activepieces/pieces-framework"; -import { httpClient, HttpMethod } from "@activepieces/pieces-common"; -import { stripeAuth } from "../.."; +import { createAction, Property } from '@activepieces/pieces-framework'; +import { httpClient, HttpMethod } from '@activepieces/pieces-common'; +import { stripeAuth } from '../..'; export const stripeSearchCustomer = createAction({ - name: 'search_customer', - auth: stripeAuth, - displayName:'Search Customer', - description: 'Search for a customer in stripe by email', - props: { - email: Property.ShortText({ - displayName: 'Email', - description: undefined, - required: true, - }), - }, - async run(context) { - const customer = { - email: context.propsValue.email, - } - const response = await httpClient.sendRequest({ - method: HttpMethod.GET, - url: 'https://api.stripe.com/v1/customers/search', - headers: { - "Authorization": 'Bearer ' + context.auth, - "Content-Type": "application/x-www-form-urlencoded", - }, - body: { - "query": "email:" + "'" + customer.email + "'", - } - }) - return response.body; - } -}) \ No newline at end of file + name: 'search_customer', + auth: stripeAuth, + displayName: 'Search Customer', + description: 'Search for a customer in stripe by email or ID', + props: { + email: Property.ShortText({ + displayName: 'Email or ID', + description: "Enter the customer's email or ID", + required: true, + }), + }, + async run(context) { + const emailOrId = context.propsValue.email; + let query = ''; + + if (emailOrId.startsWith('cus_')) { + // Assume it’s an ID if it starts with "cus_" + query = `id:"${emailOrId}"`; + } else { + query = `email:"${emailOrId}"`; + } + + const response = await httpClient.sendRequest({ + method: HttpMethod.GET, + url: 'https://api.stripe.com/v1/customers/search', + headers: { + Authorization: 'Bearer ' + context.auth, + 'Content-Type': 'application/x-www-form-urlencoded', + }, + queryParams: { + query: query, + }, + }); + return response.body; + }, +}); diff --git a/packages/pieces/stripe/src/lib/actions/search-invoice.ts b/packages/pieces/stripe/src/lib/actions/search-invoice.ts new file mode 100644 index 0000000000..96ae09ef22 --- /dev/null +++ b/packages/pieces/stripe/src/lib/actions/search-invoice.ts @@ -0,0 +1,31 @@ +import { createAction, Property } from '@activepieces/pieces-framework'; +import { httpClient, HttpMethod } from '@activepieces/pieces-common'; +import { stripeAuth } from '../..'; + +export const stripeSearchInvoice = createAction({ + name: 'search_invoice', + auth: stripeAuth, + displayName: 'Search Invoice', + description: 'Search for an invoice in stripe by ID', + props: { + invoice_id: Property.ShortText({ + displayName: 'Invoice ID', + description: undefined, + required: true, + }), + }, + async run(context) { + const invoice = { + id: context.propsValue.invoice_id, + }; + const response = await httpClient.sendRequest({ + method: HttpMethod.GET, + url: 'https://api.stripe.com/v1/invoices/' + invoice.id, + headers: { + Authorization: 'Bearer ' + context.auth, + 'Content-Type': 'application/x-www-form-urlencoded', + }, + }); + return response.body; + }, +}); diff --git a/packages/pieces/stripe/src/lib/common/index.ts b/packages/pieces/stripe/src/lib/common/index.ts index 9cccd62edd..66176d8f01 100644 --- a/packages/pieces/stripe/src/lib/common/index.ts +++ b/packages/pieces/stripe/src/lib/common/index.ts @@ -1,42 +1,88 @@ import { HttpRequest, HttpMethod, AuthenticationType, httpClient } from "@activepieces/pieces-common"; +import { samples } from './samples'; +import { Property } from '@activepieces/pieces-framework'; export const stripeCommon = { - baseUrl: "https://api.stripe.com/v1", - subscribeWebhook: async (eventName: string, webhookUrl: string, apiKey: string) => { - const request: HttpRequest = { - method: HttpMethod.POST, - url: `${stripeCommon.baseUrl}/webhook_endpoints`, - headers: { - "Content-Type": "application/x-www-form-urlencoded" - }, - body: { - enabled_events: [ - eventName - ], - url: webhookUrl - }, - authentication: { - type: AuthenticationType.BEARER_TOKEN, - token: apiKey, - }, - queryParams: {}, + samples, + baseUrl: 'https://api.stripe.com/v1', + subscribeWebhook: async ( + eventName: string, + webhookUrl: string, + apiKey: string + ) => { + const request: HttpRequest = { + method: HttpMethod.POST, + url: `${stripeCommon.baseUrl}/webhook_endpoints`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: { + enabled_events: [eventName], + url: webhookUrl, + }, + authentication: { + type: AuthenticationType.BEARER_TOKEN, + token: apiKey, + }, + queryParams: {}, + }; + + const { body: webhook } = await httpClient.sendRequest<{ id: string }>( + request + ); + return webhook; + }, + unsubscribeWebhook: async (webhookId: string, apiKey: string) => { + const request: HttpRequest = { + method: HttpMethod.DELETE, + url: `${stripeCommon.baseUrl}/webhook_endpoints/${webhookId}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + authentication: { + type: AuthenticationType.BEARER_TOKEN, + token: apiKey, + }, + }; + return await httpClient.sendRequest(request); + }, + prices: Property.Dropdown({ + displayName: 'Prices', + description: 'List of Prices', + required: true, + refreshers: [], + options: async ({ auth }) => { + if (!auth) { + return { + disabled: true, + options: [], + placeholder: 'Please connect your account first', }; + } + + const response = await httpClient.sendRequest({ + method: HttpMethod.GET, + url: 'https://api.stripe.com/v1/prices', + headers: { + Authorization: 'Bearer ' + auth, + 'Content-Type': 'application/x-www-form-urlencoded', + }, + }); + + const prices = response.body.data.map((price: StripePrice) => ({ + label: price.nickname, + value: price.id, + })); - const { body: webhook } = await httpClient.sendRequest<{ id: string }>(request); - return webhook; + return { + disabled: false, + options: prices, + }; }, - unsubscribeWebhook: async (webhookId: string, apiKey: string) => { - const request: HttpRequest = { - method: HttpMethod.DELETE, - url: `${stripeCommon.baseUrl}/webhook_endpoints/${webhookId}`, - headers: { - "Content-Type": "application/x-www-form-urlencoded" - }, - authentication: { - type: AuthenticationType.BEARER_TOKEN, - token: apiKey, - }, - }; - return await httpClient.sendRequest(request); - } -} + }), +}; + +type StripePrice = { + id: string; + nickname: string; +}; \ No newline at end of file diff --git a/packages/pieces/stripe/src/lib/common/samples.ts b/packages/pieces/stripe/src/lib/common/samples.ts new file mode 100644 index 0000000000..898936fda3 --- /dev/null +++ b/packages/pieces/stripe/src/lib/common/samples.ts @@ -0,0 +1,493 @@ +export const samples = { + charge: { + id: 'ch_3MWM7aKZ0dZfsfLEK1soCKVrq', + object: 'charge', + amount: 10000, + amount_captured: 10000, + amount_refunded: 0, + application: null, + application_fee: null, + application_fee_amount: null, + balance_transaction: 'txn_3MWM7afqwfZRqLEK1VyE8QH1', + billing_details: { + address: { + city: null, + country: 'DE', + line1: null, + line2: null, + postal_code: null, + state: null, + }, + email: 'test@gmail.com', + name: 'Test user', + phone: null, + }, + calculated_statement_descriptor: 'WWW.ACTIVEPIECES.COM', + captured: true, + created: 1675180355, + currency: 'usd', + customer: 'cus_NGtvUQ18FJXcGI', + description: 'Subscription creation', + destination: null, + dispute: null, + disputed: false, + failure_balance_transaction: null, + failure_code: null, + failure_message: null, + fraud_details: {}, + invoice: 'in_1MWM7ZKZ0dZRqLEKQbrgSBnh', + livemode: false, + metadata: {}, + on_behalf_of: null, + order: null, + outcome: { + network_status: 'approved_by_network', + reason: null, + risk_level: 'normal', + risk_score: 64, + seller_message: 'Payment complete.', + type: 'authorized', + }, + paid: true, + payment_intent: 'pi_3MWM7aKZ0dZRqLEK1BsblcVI', + payment_method: 'pm_1MWM8MKZ0dZRqLEKnIH41f76', + payment_method_details: { + card: { + brand: 'visa', + checks: { + address_line1_check: null, + address_postal_code_check: null, + cvc_check: 'pass', + }, + country: 'US', + exp_month: 12, + exp_year: 2034, + fingerprint: 't8SMsmS4h2vvODpN', + funding: 'credit', + installments: null, + last4: '4242', + mandate: null, + network: 'visa', + three_d_secure: null, + wallet: null, + }, + type: 'card', + }, + receipt_email: null, + receipt_number: null, + receipt_url: + 'https://pay.stripe.com/receipts/invoices/CAcaFwoVYWNjdF8xS214ZEtLWjBkWlJxTEVLKMXy5J4GMgZcuppYWF06LBZEoiAhZ6H7EoJ3bN-BMHCXdaW-_i-ywhSIG9wPGTmtE0CdpD75s1hIyprK?s=ap', + refunded: false, + refunds: { + object: 'list', + data: [], + has_more: false, + total_count: 0, + url: '/v1/charges/ch_3MWM7aKZ0dZRqLEK1soCKVrq/refunds', + }, + review: null, + shipping: null, + source: null, + source_transfer: null, + statement_descriptor: null, + statement_descriptor_suffix: null, + status: 'succeeded', + transfer_data: null, + transfer_group: null, + }, + customer: { + id: 'cus_MsFoYp7ZRonwC0', + object: 'customer', + address: { + city: null, + country: 'US', + line1: null, + line2: null, + postal_code: '98003', + state: null, + }, + balance: 0, + created: 1669495757, + currency: 'usd', + default_source: null, + delinquent: false, + description: null, + discount: null, + email: 'john@example.com', + invoice_prefix: '71EC8566', + invoice_settings: { + custom_fields: null, + default_payment_method: null, + footer: null, + rendering_options: null, + }, + livemode: false, + metadata: {}, + name: 'john smith', + next_invoice_sequence: 1, + phone: null, + preferred_locales: ['en-US'], + shipping: null, + tax_exempt: 'none', + test_clock: null, + }, + event: { + id: 'evt_1O6LszDdpvdpdjBQGH6CVCMm', + object: 'event', + api_version: '2017-04-06', + created: 1698535544, + data: { + object: { + id: 'cs_live_a1Qfuv15qZnhMudJVwMQkwxlYpcttldpe9E56Qbc9D4rNsTfImwz0ctedr', + object: 'checkout.session', + after_expiration: null, + allow_promotion_codes: null, + amount_subtotal: 2900, + amount_total: 1450, + automatic_tax: { + enabled: false, + status: null, + }, + billing_address_collection: null, + cancel_url: 'https://www.example.com/paywall', + client_reference_id: 'checkout_1698535415305', + client_secret: null, + consent: null, + consent_collection: null, + created: 1698535420, + currency: 'usd', + currency_conversion: null, + custom_fields: [], + custom_text: { + shipping_address: null, + submit: null, + terms_of_service_acceptance: null, + }, + customer: 'cus_O9AD3Sc5Bq39Pm', + customer_creation: 'always', + customer_details: { + address: { + city: null, + country: 'US', + line1: null, + line2: null, + postal_code: '30328', + state: null, + }, + email: 'test@example.com', + name: 'John Smith', + phone: '+1234567890', + tax_exempt: 'none', + tax_ids: [], + }, + customer_email: 'John Smith', + expires_at: 1698621820, + invoice: 'in_1O6LsmDdpv0pdjBQ2pENKxfu', + invoice_creation: null, + livemode: true, + locale: null, + metadata: { + quantity: '1', + email: 'test@example.com', + price_id: 'price_1NoHq7Ddpv0fdjBQJPCILkZs', + }, + mode: 'subscription', + payment_intent: null, + payment_link: null, + payment_method_collection: 'always', + payment_method_configuration_details: { + id: 'pmc_1KeuGWDdpkeudjBQxk9I9xgd', + parent: null, + }, + payment_method_options: null, + payment_method_types: ['card'], + payment_status: 'paid', + phone_number_collection: { + enabled: true, + }, + recovered_from: null, + setup_intent: null, + shipping: null, + shipping_address_collection: null, + shipping_options: [], + shipping_rate: null, + status: 'complete', + submit_type: null, + subscription: 'sub_1O6Lsmfdpv0pdjBQOYlUdVgC', + success_url: 'https://example.com', + total_details: { + amount_discount: 50, + amount_shipping: 0, + amount_tax: 0, + }, + ui_mode: 'hosted', + url: null, + }, + }, + livemode: true, + pending_webhooks: 0, + request: null, + type: 'checkout.session.completed', + }, + invoice: { + id: 'in_1O6hPoDdpv0pdjBQqPuCEZo8', + object: 'invoice', + account_country: 'US', + account_name: 'Example, Inc', + account_tax_ids: null, + amount_due: 99700, + amount_paid: 0, + amount_remaining: 99700, + amount_shipping: 0, + application: null, + application_fee_amount: null, + attempt_count: 0, + attempted: false, + auto_advance: false, + automatic_tax: { + enabled: false, + status: null, + }, + billing_reason: 'manual', + charge: null, + collection_method: 'charge_automatically', + created: 1698618304, + currency: 'usd', + custom_fields: null, + customer: 'cus_MsFoYp7ZRonwC0', + customer_address: { + city: null, + country: 'US', + line1: null, + line2: null, + postal_code: '98003', + state: null, + }, + customer_email: 'john@example.com', + customer_name: 'john smith', + customer_phone: null, + customer_shipping: null, + customer_tax_exempt: 'none', + customer_tax_ids: [], + default_payment_method: null, + default_source: null, + default_tax_rates: [], + description: null, + discount: null, + discounts: [], + due_date: null, + effective_at: null, + ending_balance: null, + footer: null, + from_invoice: null, + hosted_invoice_url: null, + invoice_pdf: null, + last_finalization_error: null, + latest_revision: null, + lines: { + object: 'list', + data: [ + { + id: 'il_1O6hPoDdpv0pdjBQlyXUUMEJ', + object: 'line_item', + amount: 99700, + amount_excluding_tax: 99700, + currency: 'usd', + description: 'My First Invoice Item (created for API docs)', + discount_amounts: [], + discountable: true, + discounts: [], + invoice_item: 'ii_1O6hPoDdpv0pdjBQVpJr9tLY', + livemode: false, + metadata: {}, + period: { + end: 1698618304, + start: 1698618304, + }, + price: { + id: 'price_1NHZqYDdpv0pdjBQ4Uoy9QjK', + object: 'price', + active: true, + billing_scheme: 'per_unit', + created: 1686434482, + currency: 'usd', + custom_unit_amount: null, + livemode: false, + lookup_key: null, + metadata: {}, + nickname: null, + product: 'prod_O3hFuqVcnH50y3', + recurring: null, + tax_behavior: 'unspecified', + tiers_mode: null, + transform_quantity: null, + type: 'one_time', + unit_amount: 99700, + unit_amount_decimal: '99700', + }, + proration: false, + proration_details: { + credited_items: null, + }, + quantity: 1, + subscription: null, + tax_amounts: [], + tax_rates: [], + type: 'invoiceitem', + unit_amount_excluding_tax: '99700', + }, + ], + has_more: false, + url: '/v1/invoices/in_1O6hPoDdpv0pdjBQqPuCEZo8/lines', + }, + livemode: false, + metadata: {}, + next_payment_attempt: null, + number: '71EC8566-DRAFT', + on_behalf_of: null, + paid: false, + paid_out_of_band: false, + payment_intent: null, + payment_settings: { + default_mandate: null, + payment_method_options: null, + payment_method_types: null, + }, + period_end: 1698618304, + period_start: 1698618304, + post_payment_credit_notes_amount: 0, + pre_payment_credit_notes_amount: 0, + quote: null, + receipt_number: null, + rendering: null, + shipping_cost: null, + shipping_details: null, + starting_balance: 0, + statement_descriptor: null, + status: 'draft', + status_transitions: { + finalized_at: null, + marked_uncollectible_at: null, + paid_at: null, + voided_at: null, + }, + subscription: null, + subscription_details: { + metadata: null, + }, + subtotal: 99700, + subtotal_excluding_tax: 99700, + tax: null, + test_clock: null, + total: 99700, + total_discount_amounts: [], + total_excluding_tax: 99700, + total_tax_amounts: [], + transfer_data: null, + webhooks_delivered_at: null, + }, + subscription: { + id: 'sub_1O6hZeDdpv0pdjBQnbL6OqZR', + object: 'subscription', + application: null, + application_fee_percent: null, + automatic_tax: { + enabled: false, + }, + billing_cycle_anchor: 1698618914, + billing_thresholds: null, + cancel_at: null, + cancel_at_period_end: false, + canceled_at: null, + cancellation_details: { + comment: null, + feedback: null, + reason: null, + }, + collection_method: 'charge_automatically', + created: 1698618914, + currency: 'usd', + current_period_end: 1701297314, + current_period_start: 1698618914, + customer: 'cus_MsFoYp7ZRonwC0', + days_until_due: null, + default_payment_method: null, + default_source: null, + default_tax_rates: [], + description: null, + discount: null, + ended_at: null, + items: { + object: 'list', + data: [ + { + id: 'si_OuWcdWKpdakza4', + object: 'subscription_item', + billing_thresholds: null, + created: 1698618915, + metadata: {}, + price: { + id: 'price_1MARreDdpv0pdjBQ6RTfEitN', + object: 'price', + active: true, + billing_scheme: 'per_unit', + created: 1669959166, + currency: 'usd', + custom_unit_amount: null, + livemode: false, + lookup_key: null, + metadata: {}, + nickname: null, + product: 'prod_MuGO2A9gFuDEJ2', + recurring: { + aggregate_usage: null, + interval: 'month', + interval_count: 1, + usage_type: 'licensed', + }, + tax_behavior: 'unspecified', + tiers_mode: null, + transform_quantity: { + divide_by: 4, + round: 'up', + }, + type: 'recurring', + unit_amount: 2900, + unit_amount_decimal: '2900', + }, + quantity: 1, + subscription: 'sub_1O6hZeDdpv0pdjBQnbL6OqZR', + tax_rates: [], + }, + ], + has_more: false, + url: '/v1/subscription_items?subscription=sub_1O6hZeDdpv0pdjBQnbL6OqZR', + }, + latest_invoice: null, + livemode: false, + metadata: {}, + next_pending_invoice_item_invoice: null, + on_behalf_of: null, + pause_collection: null, + payment_settings: { + payment_method_options: null, + payment_method_types: null, + save_default_payment_method: null, + }, + pending_invoice_item_interval: null, + pending_setup_intent: null, + pending_update: null, + schedule: null, + start_date: 1698618914, + status: 'active', + test_clock: null, + transfer_data: null, + trial_end: null, + trial_settings: { + end_behavior: { + missing_payment_method: 'create_invoice', + }, + }, + trial_start: null, + }, +}; diff --git a/packages/pieces/stripe/src/lib/trigger/canceled-subscription.ts b/packages/pieces/stripe/src/lib/trigger/canceled-subscription.ts new file mode 100644 index 0000000000..e3eaf53efc --- /dev/null +++ b/packages/pieces/stripe/src/lib/trigger/canceled-subscription.ts @@ -0,0 +1,42 @@ +import { createTrigger } from '@activepieces/pieces-framework'; +import { TriggerStrategy } from '@activepieces/pieces-framework'; +import { stripeCommon } from '../common'; +import { stripeAuth } from '../..'; + +export const stripeCanceledSubscription = createTrigger({ + auth: stripeAuth, + name: 'canceled_subscription', + displayName: 'Canceled Subscription', + description: 'Triggers when a subscription is canceled', + props: {}, + sampleData: stripeCommon.samples.subscription, + type: TriggerStrategy.WEBHOOK, + async onEnable(context) { + const webhook = await stripeCommon.subscribeWebhook( + 'customer.subscription.deleted', + context.webhookUrl, + context.auth + ); + await context.store.put( + '_canceled_subscription_trigger', + { + webhookId: webhook.id, + } + ); + }, + async onDisable(context) { + const response = await context.store?.get( + '_canceled_subscription_trigger' + ); + if (response !== null && response !== undefined) { + await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + } + }, + async run(context) { + return [context.payload.body.data.object]; + }, +}); + +interface WebhookInformation { + webhookId: string; +} diff --git a/packages/pieces/stripe/src/lib/trigger/checkout-session-complete.ts b/packages/pieces/stripe/src/lib/trigger/checkout-session-complete.ts new file mode 100644 index 0000000000..a69e048bcb --- /dev/null +++ b/packages/pieces/stripe/src/lib/trigger/checkout-session-complete.ts @@ -0,0 +1,42 @@ +import { createTrigger } from '@activepieces/pieces-framework'; +import { TriggerStrategy } from '@activepieces/pieces-framework'; +import { stripeCommon } from '../common'; +import { stripeAuth } from '../..'; + +export const stripeCheckoutSessionComplete = createTrigger({ + auth: stripeAuth, + name: 'checkout_session_complete', + displayName: 'Checkout Session Complete', + description: 'Triggers when a checkout session is completed', + props: {}, + sampleData: stripeCommon.samples.event, + type: TriggerStrategy.WEBHOOK, + async onEnable(context) { + const webhook = await stripeCommon.subscribeWebhook( + 'checkout.session.completed', + context.webhookUrl, + context.auth + ); + await context.store.put( + '_checkout_session_complete_trigger', + { + webhookId: webhook.id, + } + ); + }, + async onDisable(context) { + const response = await context.store?.get( + '_checkout_session_complete_trigger' + ); + if (response !== null && response !== undefined) { + await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + } + }, + async run(context) { + return [context.payload.body.data.object]; + }, +}); + +interface WebhookInformation { + webhookId: string; +} diff --git a/packages/pieces/stripe/src/lib/trigger/invoice-payment-failed.ts b/packages/pieces/stripe/src/lib/trigger/invoice-payment-failed.ts new file mode 100644 index 0000000000..fe05ffaefe --- /dev/null +++ b/packages/pieces/stripe/src/lib/trigger/invoice-payment-failed.ts @@ -0,0 +1,42 @@ +import { createTrigger } from '@activepieces/pieces-framework'; +import { TriggerStrategy } from '@activepieces/pieces-framework'; +import { stripeCommon } from '../common'; +import { stripeAuth } from '../..'; + +export const stripeInvoicePaymentFailed = createTrigger({ + auth: stripeAuth, + name: 'invoice_payment_failed', + displayName: 'Invoice Payment Failed', + description: 'Triggers when an invoice payment fails', + props: {}, + sampleData: stripeCommon.samples.event, + type: TriggerStrategy.WEBHOOK, + async onEnable(context) { + const webhook = await stripeCommon.subscribeWebhook( + 'invoice.payment_failed', + context.webhookUrl, + context.auth + ); + await context.store?.put( + '_invoice_payment_failed_trigger', + { + webhookId: webhook.id, + } + ); + }, + async onDisable(context) { + const response = await context.store?.get( + '_invoice_payment_failed_trigger' + ); + if (response !== null && response !== undefined) { + await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + } + }, + async run(context) { + return [context.payload.body.data.object]; + }, +}); + +interface WebhookInformation { + webhookId: string; +} diff --git a/packages/pieces/stripe/src/lib/trigger/new-customer.ts b/packages/pieces/stripe/src/lib/trigger/new-customer.ts index 735b1e735f..24ae9d329a 100644 --- a/packages/pieces/stripe/src/lib/trigger/new-customer.ts +++ b/packages/pieces/stripe/src/lib/trigger/new-customer.ts @@ -8,47 +8,23 @@ export const stripeNewCustomer = createTrigger({ name: 'new_customer', displayName: 'New Customer', description: 'Triggers when a new customer is created', - props: { - }, - sampleData: { - "id": "cus_NGtyEf4hNGTj3p", - "object": "customer", - "address": null, - "balance": 0, - "created": 1675180509, - "currency": null, - "default_currency": null, - "default_source": null, - "delinquent": false, - "description": null, - "discount": null, - "email": "jane@example.com", - "invoice_prefix": "B7162248", - "invoice_settings": { - "custom_fields": null, - "default_payment_method": null, - "footer": null, - "rendering_options": null - }, - "livemode": false, - "metadata": {}, - "name": "John Doe", - "next_invoice_sequence": 1, - "phone": null, - "preferred_locales": [], - "shipping": null, - "tax_exempt": "none", - "test_clock": null - }, + props: {}, + sampleData: stripeCommon.samples.customer, type: TriggerStrategy.WEBHOOK, async onEnable(context) { - const webhook = await stripeCommon.subscribeWebhook('customer.created', context.webhookUrl, context.auth); + const webhook = await stripeCommon.subscribeWebhook( + 'customer.created', + context.webhookUrl, + context.auth + ); await context.store.put('_new_customer_trigger', { - webhookId: webhook.id + webhookId: webhook.id, }); }, async onDisable(context) { - const response = await context.store?.get('_new_customer_trigger'); + const response = await context.store?.get( + '_new_customer_trigger' + ); if (response !== null && response !== undefined) { await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); } diff --git a/packages/pieces/stripe/src/lib/trigger/new-dispute.ts b/packages/pieces/stripe/src/lib/trigger/new-dispute.ts new file mode 100644 index 0000000000..ace5ba1f30 --- /dev/null +++ b/packages/pieces/stripe/src/lib/trigger/new-dispute.ts @@ -0,0 +1,42 @@ +import { createTrigger } from '@activepieces/pieces-framework'; +import { TriggerStrategy } from '@activepieces/pieces-framework'; +import { stripeCommon } from '../common'; +import { stripeAuth } from '../..'; + +export const stripeNewDispute = createTrigger({ + auth: stripeAuth, + name: 'new_dispute', + displayName: 'New Dispute', + description: 'Triggers when a new dispute is created', + props: {}, + type: TriggerStrategy.WEBHOOK, + sampleData: stripeCommon.samples.charge, + async onEnable(context) { + const webhook = await stripeCommon.subscribeWebhook( + 'charge.dispute.created', + context.webhookUrl!, + context.auth + ); + await context.store?.put( + '_charge_dispute_created_trigger', + { + webhookId: webhook.id, + } + ); + }, + async onDisable(context) { + const response = await context.store?.get( + '_charge_dispute_created_trigger' + ); + if (response !== null && response !== undefined) { + await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + } + }, + async run(context) { + return [context.payload.body.data.object]; + }, +}); + +interface WebhookInformation { + webhookId: string; +} diff --git a/packages/pieces/stripe/src/lib/trigger/new-invoice.ts b/packages/pieces/stripe/src/lib/trigger/new-invoice.ts new file mode 100644 index 0000000000..4303fbe8b7 --- /dev/null +++ b/packages/pieces/stripe/src/lib/trigger/new-invoice.ts @@ -0,0 +1,39 @@ +import { createTrigger } from '@activepieces/pieces-framework'; +import { TriggerStrategy } from '@activepieces/pieces-framework'; +import { stripeCommon } from '../common'; +import { stripeAuth } from '../..'; + +export const stripeNewInvoice = createTrigger({ + auth: stripeAuth, + name: 'new_invoice', + displayName: 'New Invoice', + description: 'Triggers when a new invoice is made', + props: {}, + type: TriggerStrategy.WEBHOOK, + sampleData: stripeCommon.samples.invoice, + async onEnable(context) { + const webhook = await stripeCommon.subscribeWebhook( + 'invoice.created', + context.webhookUrl!, + context.auth + ); + await context.store?.put('_new_invoice_trigger', { + webhookId: webhook.id, + }); + }, + async onDisable(context) { + const response = await context.store?.get( + '_new_invoice_trigger' + ); + if (response !== null && response !== undefined) { + await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + } + }, + async run(context) { + return [context.payload.body.data.object]; + }, +}); + +interface WebhookInformation { + webhookId: string; +} diff --git a/packages/pieces/stripe/src/lib/trigger/new-payment.ts b/packages/pieces/stripe/src/lib/trigger/new-payment.ts index 27ecbef2d6..71d33a323d 100644 --- a/packages/pieces/stripe/src/lib/trigger/new-payment.ts +++ b/packages/pieces/stripe/src/lib/trigger/new-payment.ts @@ -8,112 +8,23 @@ export const stripeNewPayment = createTrigger({ name: 'new_payment', displayName: 'New Payment', description: 'Triggers when a new payment is made', - props: { - }, + props: {}, type: TriggerStrategy.WEBHOOK, - sampleData: { - "id": "ch_3MWM7aKZ0dZRqLEK1soCKVrq", - "object": "charge", - "amount": 10000, - "amount_captured": 10000, - "amount_refunded": 0, - "application": null, - "application_fee": null, - "application_fee_amount": null, - "balance_transaction": "txn_3MWM7aKZ0dZRqLEK1VyE8QH1", - "billing_details": { - "address": { - "city": null, - "country": "DE", - "line1": null, - "line2": null, - "postal_code": null, - "state": null - }, - "email": "test@gmail.com", - "name": "Test user", - "phone": null - }, - "calculated_statement_descriptor": "WWW.ACTIVEPIECES.COM", - "captured": true, - "created": 1675180355, - "currency": "usd", - "customer": "cus_NGtvUQ18FJXcGI", - "description": "Subscription creation", - "destination": null, - "dispute": null, - "disputed": false, - "failure_balance_transaction": null, - "failure_code": null, - "failure_message": null, - "fraud_details": {}, - "invoice": "in_1MWM7ZKZ0dZRqLEKQbrgSBnh", - "livemode": false, - "metadata": {}, - "on_behalf_of": null, - "order": null, - "outcome": { - "network_status": "approved_by_network", - "reason": null, - "risk_level": "normal", - "risk_score": 64, - "seller_message": "Payment complete.", - "type": "authorized" - }, - "paid": true, - "payment_intent": "pi_3MWM7aKZ0dZRqLEK1BsblcVI", - "payment_method": "pm_1MWM8MKZ0dZRqLEKnIH41f76", - "payment_method_details": { - "card": { - "brand": "visa", - "checks": { - "address_line1_check": null, - "address_postal_code_check": null, - "cvc_check": "pass" - }, - "country": "US", - "exp_month": 12, - "exp_year": 2034, - "fingerprint": "t8SMsmS4h2vvODpN", - "funding": "credit", - "installments": null, - "last4": "4242", - "mandate": null, - "network": "visa", - "three_d_secure": null, - "wallet": null - }, - "type": "card" - }, - "receipt_email": null, - "receipt_number": null, - "receipt_url": "https://pay.stripe.com/receipts/invoices/CAcaFwoVYWNjdF8xS214ZEtLWjBkWlJxTEVLKMXy5J4GMgZcuppYWF06LBZEoiAhZ6H7EoJ3bN-BMHCXdaW-_i-ywhSIG9wPGTmtE0CdpD75s1hIyprK?s=ap", - "refunded": false, - "refunds": { - "object": "list", - "data": [], - "has_more": false, - "total_count": 0, - "url": "/v1/charges/ch_3MWM7aKZ0dZRqLEK1soCKVrq/refunds" - }, - "review": null, - "shipping": null, - "source": null, - "source_transfer": null, - "statement_descriptor": null, - "statement_descriptor_suffix": null, - "status": "succeeded", - "transfer_data": null, - "transfer_group": null - }, + sampleData: stripeCommon.samples.charge, async onEnable(context) { - const webhook = await stripeCommon.subscribeWebhook('charge.succeeded', context.webhookUrl!, context.auth); + const webhook = await stripeCommon.subscribeWebhook( + 'charge.succeeded', + context.webhookUrl!, + context.auth + ); await context.store?.put('_new_payment_trigger', { - webhookId: webhook.id + webhookId: webhook.id, }); }, async onDisable(context) { - const response = await context.store?.get('_new_payment_trigger'); + const response = await context.store?.get( + '_new_payment_trigger' + ); if (response !== null && response !== undefined) { await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); } diff --git a/packages/pieces/stripe/src/lib/trigger/new-refund.ts b/packages/pieces/stripe/src/lib/trigger/new-refund.ts new file mode 100644 index 0000000000..b777b150dd --- /dev/null +++ b/packages/pieces/stripe/src/lib/trigger/new-refund.ts @@ -0,0 +1,39 @@ +import { createTrigger } from '@activepieces/pieces-framework'; +import { TriggerStrategy } from '@activepieces/pieces-framework'; +import { stripeCommon } from '../common'; +import { stripeAuth } from '../..'; + +export const stripeNewRefund = createTrigger({ + auth: stripeAuth, + name: 'new_refund', + displayName: 'New Refund', + description: 'Triggers when a new refund is created', + props: {}, + type: TriggerStrategy.WEBHOOK, + sampleData: stripeCommon.samples.charge, + async onEnable(context) { + const webhook = await stripeCommon.subscribeWebhook( + 'charge.refunded', + context.webhookUrl!, + context.auth + ); + await context.store?.put('_charge_refunded_trigger', { + webhookId: webhook.id, + }); + }, + async onDisable(context) { + const response = await context.store?.get( + '_charge_refunded_trigger' + ); + if (response !== null && response !== undefined) { + await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + } + }, + async run(context) { + return [context.payload.body.data.object]; + }, +}); + +interface WebhookInformation { + webhookId: string; +} diff --git a/packages/pieces/stripe/src/lib/trigger/new-subscription.ts b/packages/pieces/stripe/src/lib/trigger/new-subscription.ts index f1102ab688..ecdf8f8614 100644 --- a/packages/pieces/stripe/src/lib/trigger/new-subscription.ts +++ b/packages/pieces/stripe/src/lib/trigger/new-subscription.ts @@ -5,163 +5,36 @@ import { stripeAuth } from '../..'; export const stripeNewSubscription = createTrigger({ auth: stripeAuth, - name: 'new_subscription', - displayName: 'New Subscription', - description: 'Triggers when a new subscription is made', - props: { - }, - type: TriggerStrategy.WEBHOOK, - sampleData: { - "id": "sub_1MWMJXKZ0dZRqLEKJX80JXfv", - "object": "subscription", - "application": null, - "application_fee_percent": null, - "automatic_tax": { - "enabled": true - }, - "billing_cycle_anchor": 1675181047, - "billing_thresholds": null, - "cancel_at": null, - "cancel_at_period_end": false, - "canceled_at": null, - "collection_method": "charge_automatically", - "created": 1675181047, - "currency": "usd", - "current_period_end": 1677600247, - "current_period_start": 1675181047, - "customer": "cus_NGtvUQ18FJXcGI", - "days_until_due": null, - "default_payment_method": "pm_1MWM8MKZ0dZRqLEKnIH41f76", - "default_source": null, - "default_tax_rates": [], - "description": null, - "discount": null, - "ended_at": null, - "items": { - "object": "list", - "data": [ - { - "id": "si_NGu7pb7hS3Rps3", - "object": "subscription_item", - "billing_thresholds": null, - "created": 1675181048, - "metadata": {}, - "plan": { - "id": "price_1MWLz3KZ0dZRqLEK06gRMHCF", - "object": "plan", - "active": true, - "aggregate_usage": null, - "amount": 10000, - "amount_decimal": "10000", - "billing_scheme": "per_unit", - "created": 1675179777, - "currency": "usd", - "interval": "month", - "interval_count": 1, - "livemode": false, - "metadata": {}, - "nickname": null, - "product": "prod_NGtm3AlvaGjaLN", - "tiers_mode": null, - "transform_usage": null, - "trial_period_days": null, - "usage_type": "licensed" - }, - "price": { - "id": "price_1MWLz3KZ0dZRqLEK06gRMHCF", - "object": "price", - "active": true, - "billing_scheme": "per_unit", - "created": 1675179777, - "currency": "usd", - "custom_unit_amount": null, - "livemode": false, - "lookup_key": null, - "metadata": {}, - "nickname": null, - "product": "prod_NGtm3AlvaGjaLN", - "recurring": { - "aggregate_usage": null, - "interval": "month", - "interval_count": 1, - "trial_period_days": null, - "usage_type": "licensed" - }, - "tax_behavior": "exclusive", - "tiers_mode": null, - "transform_quantity": null, - "type": "recurring", - "unit_amount": 10000, - "unit_amount_decimal": "10000" - }, - "quantity": 1, - "subscription": "sub_1MWMJXKZ0dZRqLEKJX80JXfv", - "tax_rates": [] - } - ], - "has_more": false, - "total_count": 1, - "url": "/v1/subscription_items?subscription=sub_1MWMJXKZ0dZRqLEKJX80JXfv" - }, - "latest_invoice": "in_1MWMJXKZ0dZRqLEKIu4a51u7", - "livemode": false, - "metadata": {}, - "next_pending_invoice_item_invoice": null, - "on_behalf_of": null, - "pause_collection": null, - "payment_settings": { - "payment_method_options": null, - "payment_method_types": null, - "save_default_payment_method": "off" - }, - "pending_invoice_item_interval": null, - "pending_setup_intent": null, - "pending_update": null, - "plan": { - "id": "price_1MWLz3KZ0dZRqLEK06gRMHCF", - "object": "plan", - "active": true, - "aggregate_usage": null, - "amount": 10000, - "amount_decimal": "10000", - "billing_scheme": "per_unit", - "created": 1675179777, - "currency": "usd", - "interval": "month", - "interval_count": 1, - "livemode": false, - "metadata": {}, - "nickname": null, - "product": "prod_NGtm3AlvaGjaLN", - "tiers_mode": null, - "transform_usage": null, - "trial_period_days": null, - "usage_type": "licensed" - }, - "quantity": 1, - "schedule": null, - "start_date": 1675181047, - "status": "active", - "test_clock": null, - "transfer_data": null, - "trial_end": null, - "trial_start": null - }, - async onEnable(context) { - const webhook = await stripeCommon.subscribeWebhook('customer.subscription.created', context.webhookUrl!, context.auth); - await context.store?.put('_new_customer_subscription_trigger', { - webhookId: webhook.id - }); - }, - async onDisable(context) { - const response = await context.store?.get('_new_customer_subscription_trigger'); - if (response !== null && response !== undefined) { - await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + name: 'new_subscription', + displayName: 'New Subscription', + description: 'Triggers when a new subscription is made', + props: {}, + type: TriggerStrategy.WEBHOOK, + sampleData: stripeCommon.samples.subscription, + async onEnable(context) { + const webhook = await stripeCommon.subscribeWebhook( + 'customer.subscription.created', + context.webhookUrl!, + context.auth + ); + await context.store?.put( + '_new_customer_subscription_trigger', + { + webhookId: webhook.id, } - }, - async run(context) { - return [context.payload.body.data.object]; - }, + ); + }, + async onDisable(context) { + const response = await context.store?.get( + '_new_customer_subscription_trigger' + ); + if (response !== null && response !== undefined) { + await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + } + }, + async run(context) { + return [context.payload.body.data.object]; + }, }); interface WebhookInformation { diff --git a/packages/pieces/stripe/src/lib/trigger/payment-failed.ts b/packages/pieces/stripe/src/lib/trigger/payment-failed.ts index 1cbdbceeb4..2b58e71ae2 100644 --- a/packages/pieces/stripe/src/lib/trigger/payment-failed.ts +++ b/packages/pieces/stripe/src/lib/trigger/payment-failed.ts @@ -5,169 +5,33 @@ import { stripeAuth } from '../..'; export const stripePaymentFailed = createTrigger({ auth: stripeAuth, - name: 'payment_failed', - displayName: 'Payment Failed', - description: 'Triggers when a payment fails', - props: { - }, - sampleData: { - "id": "ch_3MWMPQKZ0dZRqLEK063rxD7q", - "object": "charge", - "amount": 100000, - "amount_captured": 0, - "amount_refunded": 0, - "application": null, - "application_fee": null, - "application_fee_amount": null, - "balance_transaction": null, - "billing_details": { - "address": { - "city": null, - "country": null, - "line1": null, - "line2": null, - "postal_code": "12321", - "state": null - }, - "email": null, - "name": null, - "phone": null - }, - "calculated_statement_descriptor": "WWW.ACTIVEPIECES.COM", - "captured": false, - "created": 1675181413, - "currency": "usd", - "customer": "cus_NGtvUQ18FJXcGI", - "description": "Failed Payment", - "destination": null, - "dispute": null, - "disputed": false, - "failure_balance_transaction": null, - "failure_code": "card_declined", - "failure_message": "Your card was declined.", - "fraud_details": {}, - "invoice": null, - "livemode": false, - "metadata": {}, - "on_behalf_of": null, - "order": null, - "outcome": { - "network_status": "declined_by_network", - "reason": "generic_decline", - "risk_level": "normal", - "risk_score": 60, - "seller_message": "The bank did not return any further details with this decline.", - "type": "issuer_declined" - }, - "paid": false, - "payment_intent": "pi_3MWMPQKZ0dZRqLEK0Nsc6WhL", - "payment_method": "src_1MWMPQKZ0dZRqLEKuQ83wmZI", - "payment_method_details": { - "card": { - "brand": "visa", - "checks": { - "address_line1_check": null, - "address_postal_code_check": "pass", - "cvc_check": "pass" - }, - "country": "US", - "exp_month": 12, - "exp_year": 2031, - "fingerprint": "mtYxM2Q4edpEt8Pw", - "funding": "credit", - "installments": null, - "last4": "0341", - "mandate": null, - "network": "visa", - "three_d_secure": null, - "wallet": null - }, - "type": "card" - }, - "receipt_email": null, - "receipt_number": null, - "receipt_url": null, - "refunded": false, - "refunds": { - "object": "list", - "data": [], - "has_more": false, - "total_count": 0, - "url": "/v1/charges/ch_3MWMPQKZ0dZRqLEK063rxD7q/refunds" - }, - "review": null, - "shipping": null, - "source": { - "id": "src_1MWMPQKZ0dZRqLEKuQ83wmZI", - "object": "source", - "amount": null, - "card": { - "exp_month": 12, - "exp_year": 2031, - "last4": "0341", - "country": "US", - "brand": "Visa", - "address_zip_check": "pass", - "cvc_check": "pass", - "funding": "credit", - "fingerprint": "mtYxM2Q4edpEt8Pw", - "three_d_secure": "optional", - "name": null, - "address_line1_check": null, - "tokenization_method": null, - "dynamic_last4": null - }, - "client_secret": "src_client_secret_TlLkl6IvhCvmbx8Cz12YNDVb", - "created": 1675181413, - "currency": null, - "flow": "none", - "livemode": false, - "metadata": {}, - "owner": { - "address": { - "city": null, - "country": null, - "line1": null, - "line2": null, - "postal_code": "12321", - "state": null - }, - "email": null, - "name": null, - "phone": null, - "verified_address": null, - "verified_email": null, - "verified_name": null, - "verified_phone": null - }, - "statement_descriptor": null, - "status": "chargeable", - "type": "card", - "usage": "reusable" - }, - "source_transfer": null, - "statement_descriptor": "www.activepieces.com", - "statement_descriptor_suffix": null, - "status": "failed", - "transfer_data": null, - "transfer_group": null - }, - type: TriggerStrategy.WEBHOOK, - async onEnable(context) { - const webhook = await stripeCommon.subscribeWebhook('charge.failed', context.webhookUrl, context.auth); - await context.store?.put('_payment_failed_trigger', { - webhookId: webhook.id - }); - }, - async onDisable(context) { - const response = await context.store?.get('_payment_failed_trigger'); - if (response !== null && response !== undefined) { - await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); - } - }, - async run(context) { - return [context.payload.body.data.object]; - }, + name: 'payment_failed', + displayName: 'Payment Failed', + description: 'Triggers when a payment fails', + props: {}, + sampleData: stripeCommon.samples.charge, + type: TriggerStrategy.WEBHOOK, + async onEnable(context) { + const webhook = await stripeCommon.subscribeWebhook( + 'charge.failed', + context.webhookUrl, + context.auth + ); + await context.store?.put('_payment_failed_trigger', { + webhookId: webhook.id, + }); + }, + async onDisable(context) { + const response = await context.store?.get( + '_payment_failed_trigger' + ); + if (response !== null && response !== undefined) { + await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + } + }, + async run(context) { + return [context.payload.body.data.object]; + }, }); interface WebhookInformation { diff --git a/packages/pieces/stripe/src/lib/trigger/updated-subscription.ts b/packages/pieces/stripe/src/lib/trigger/updated-subscription.ts new file mode 100644 index 0000000000..519e6f2260 --- /dev/null +++ b/packages/pieces/stripe/src/lib/trigger/updated-subscription.ts @@ -0,0 +1,42 @@ +import { createTrigger } from '@activepieces/pieces-framework'; +import { TriggerStrategy } from '@activepieces/pieces-framework'; +import { stripeCommon } from '../common'; +import { stripeAuth } from '../..'; + +export const stripeUpdatedSubscription = createTrigger({ + auth: stripeAuth, + name: 'updated_subscription', + displayName: 'Updated Subscription', + description: 'Triggers when a subscription is updated', + props: {}, + sampleData: stripeCommon.samples.subscription, + type: TriggerStrategy.WEBHOOK, + async onEnable(context) { + const webhook = await stripeCommon.subscribeWebhook( + 'customer.subscription.updated', + context.webhookUrl, + context.auth + ); + await context.store.put( + '_updated_subscription_trigger', + { + webhookId: webhook.id, + } + ); + }, + async onDisable(context) { + const response = await context.store?.get( + '_updated_subscription_trigger' + ); + if (response !== null && response !== undefined) { + await stripeCommon.unsubscribeWebhook(response.webhookId, context.auth); + } + }, + async run(context) { + return [context.payload.body.data.object]; + }, +}); + +interface WebhookInformation { + webhookId: string; +} From 0bb16783d1f46fa81bcb1263c1694f34f9194e7f Mon Sep 17 00:00:00 2001 From: kylebuilds Date: Sun, 29 Oct 2023 17:04:42 -0700 Subject: [PATCH 2/3] targets --- packages/pieces/shopify/src/index.ts | 4 +- .../src/lib/actions/create-customer.ts | 149 +++++++ .../shopify/src/lib/actions/create-order.ts | 0 .../shopify/src/lib/actions/create-product.ts | 0 .../src/lib/actions/create-variant-product.ts | 0 .../shopify/src/lib/actions/find-customer.ts | 0 .../src/lib/actions/find-product-by-title.ts | 0 .../actions/find-product-variant-by-title.ts | 0 .../src/lib/actions/update-customer.ts | 0 .../lib/actions/update-inventory-quantity.ts | 0 .../src/lib/actions/update-product-variant.ts | 0 .../shopify/src/lib/actions/update-product.ts | 0 .../shopify/src/lib/triggers/new-dispute.ts | 22 + .../shopify/src/lib/triggers/new-product.ts | 85 ++++ .../src/lib/triggers/updated-customer.ts | 36 ++ .../shopify/src/lib/triggers/updated-order.ts | 401 ++++++++++++++++++ 16 files changed, 695 insertions(+), 2 deletions(-) create mode 100644 packages/pieces/shopify/src/lib/actions/create-customer.ts create mode 100644 packages/pieces/shopify/src/lib/actions/create-order.ts create mode 100644 packages/pieces/shopify/src/lib/actions/create-product.ts create mode 100644 packages/pieces/shopify/src/lib/actions/create-variant-product.ts create mode 100644 packages/pieces/shopify/src/lib/actions/find-customer.ts create mode 100644 packages/pieces/shopify/src/lib/actions/find-product-by-title.ts create mode 100644 packages/pieces/shopify/src/lib/actions/find-product-variant-by-title.ts create mode 100644 packages/pieces/shopify/src/lib/actions/update-customer.ts create mode 100644 packages/pieces/shopify/src/lib/actions/update-inventory-quantity.ts create mode 100644 packages/pieces/shopify/src/lib/actions/update-product-variant.ts create mode 100644 packages/pieces/shopify/src/lib/actions/update-product.ts create mode 100644 packages/pieces/shopify/src/lib/triggers/new-dispute.ts create mode 100644 packages/pieces/shopify/src/lib/triggers/new-product.ts create mode 100644 packages/pieces/shopify/src/lib/triggers/updated-customer.ts create mode 100644 packages/pieces/shopify/src/lib/triggers/updated-order.ts diff --git a/packages/pieces/shopify/src/index.ts b/packages/pieces/shopify/src/index.ts index b22e301d23..9ffcde4c7f 100644 --- a/packages/pieces/shopify/src/index.ts +++ b/packages/pieces/shopify/src/index.ts @@ -14,13 +14,13 @@ To Obtain an Admin Token, follow these steps: 3. Click on Develop apps 4. Create an App 5. Fill the app name -6. Click on Configure Admin API Scopes (Select the following scopes 'read_orders', 'read_customers') +6. Click on Configure Admin API Scopes (Select the following scopes 'read_orders', 'read_customers') Note: Some steps may require more sensitive scopes 7. Click on Install app 8. Copy the Admin Access Token **Shop Name** 1- You can find your shop name in the url For example, if the URL is https://example.myshopify.com/admin, then your shop name is **example**. -` +`; export const shopifyAuth = PieceAuth.CustomAuth({ description: markdown, diff --git a/packages/pieces/shopify/src/lib/actions/create-customer.ts b/packages/pieces/shopify/src/lib/actions/create-customer.ts new file mode 100644 index 0000000000..ec34a2aee5 --- /dev/null +++ b/packages/pieces/shopify/src/lib/actions/create-customer.ts @@ -0,0 +1,149 @@ +import { + createAction, + Property, + Validators, +} from '@activepieces/pieces-framework'; +import { httpClient, HttpMethod } from '@activepieces/pieces-common'; +import { shopifyAuth } from '../..'; + +export const createCustomer = createAction({ + auth: shopifyAuth, + name: 'create_customer', + displayName: 'Create Customer', + description: 'Creates a customer.', + + props: { + email: Property.ShortText({ + displayName: 'Email', + required: true, + }), + firstName: Property.ShortText({ + displayName: 'First Name', + required: true, + }), + lastName: Property.ShortText({ + displayName: 'Last Name', + required: true, + }), + company: Property.ShortText({ + displayName: 'Company', + required: false, + }), + street_address: Property.ShortText({ + displayName: 'Street Address', + required: false, + }), + + street_address_2: Property.ShortText({ + displayName: 'Street Address 2', + required: false, + }), + city: Property.ShortText({ + displayName: 'City', + required: false, + }), + state: Property.ShortText({ + displayName: 'State/Province code', + required: false, + }), + country: Property.ShortText({ + displayName: 'Country code', + required: false, + }), + zipcode: Property.ShortText({ + displayName: 'Zip Code', + required: false, + }), + + mark_email_as_verified: Property.Checkbox({ + displayName: 'Mark Email as Verified', + required: true, + }), + phone: Property.ShortText({ + displayName: 'Phone', + required: false, + }), + tags: Property.ShortText({ + displayName: 'Tags', + required: false, + }), + note: Property.LongText({ + displayName: 'Note', + required: false, + }), + accepts_marketing: Property.Checkbox({ + displayName: 'Accepts Marketing', + required: false, + }), + tax_exempt: Property.Checkbox({ + displayName: 'Tax Exempt', + required: false, + }), + send_email_invite: Property.Checkbox({ + displayName: 'Send Email Invite', + required: false, + }), + }, + + async run(context) { + const { + email, + firstName, + lastName, + company, + street_address, + street_address_2, + city, + state, + country, + zipcode, + phone, + tags, + note, + accepts_marketing = false, + tax_exempt = false, + send_email_invite = false, + } = context.propsValue; + + const shopName = context.auth.shopName; + const adminToken = context.auth.adminToken; + + const response = await httpClient.sendRequest<{ + customer: { + id: string; + }; + }>({ + method: HttpMethod.POST, + url: `https://${shopName}.myshopify.com/admin/api/2023-01/customers.json`, + headers: { + 'X-Shopify-Access-Token': adminToken, + }, + body: { + customer: { + email, + first_name: firstName, + last_name: lastName, + company, + addresses: [ + { + address1: street_address, + address2: street_address_2, + city, + province: state, + country, + zip: zipcode, + }, + ], + send_email_invite, + phone, + tags, + note, + accepts_marketing, + tax_exempt, + }, + }, + }); + + return [response.body.customer]; + }, +}); diff --git a/packages/pieces/shopify/src/lib/actions/create-order.ts b/packages/pieces/shopify/src/lib/actions/create-order.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/actions/create-product.ts b/packages/pieces/shopify/src/lib/actions/create-product.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/actions/create-variant-product.ts b/packages/pieces/shopify/src/lib/actions/create-variant-product.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/actions/find-customer.ts b/packages/pieces/shopify/src/lib/actions/find-customer.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/actions/find-product-by-title.ts b/packages/pieces/shopify/src/lib/actions/find-product-by-title.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/actions/find-product-variant-by-title.ts b/packages/pieces/shopify/src/lib/actions/find-product-variant-by-title.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/actions/update-customer.ts b/packages/pieces/shopify/src/lib/actions/update-customer.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/actions/update-inventory-quantity.ts b/packages/pieces/shopify/src/lib/actions/update-inventory-quantity.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/actions/update-product-variant.ts b/packages/pieces/shopify/src/lib/actions/update-product-variant.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/actions/update-product.ts b/packages/pieces/shopify/src/lib/actions/update-product.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/shopify/src/lib/triggers/new-dispute.ts b/packages/pieces/shopify/src/lib/triggers/new-dispute.ts new file mode 100644 index 0000000000..33da366b8f --- /dev/null +++ b/packages/pieces/shopify/src/lib/triggers/new-dispute.ts @@ -0,0 +1,22 @@ +import { createShopifyWebhookTrigger } from '../common/register-webhook'; + +export const newDispute = createShopifyWebhookTrigger({ + name: 'new_dispute', + description: 'Triggered when a new dispute is created', + topic: 'disputes/create', + displayName: 'New Dispute', + sampleData: { + id: 285332461850802050, + order_id: 820982911946154500, + type: 'chargeback', + amount: '11.50', + currency: 'CAD', + reason: 'fraudulent', + network_reason_code: '4837', + status: 'under_review', + evidence_due_by: '2021-12-30T19:00:00-05:00', + evidence_sent_on: null, + finalized_on: null, + initiated_at: '2021-12-31T19:00:00-05:00', + }, +}); diff --git a/packages/pieces/shopify/src/lib/triggers/new-product.ts b/packages/pieces/shopify/src/lib/triggers/new-product.ts new file mode 100644 index 0000000000..31b991fe55 --- /dev/null +++ b/packages/pieces/shopify/src/lib/triggers/new-product.ts @@ -0,0 +1,85 @@ +import { createShopifyWebhookTrigger } from '../common/register-webhook'; + +export const newProduct = createShopifyWebhookTrigger({ + name: 'new_product', + description: 'Triggered when a new product is created', + topic: 'products/create', + displayName: 'New Product', + sampleData: { + admin_graphql_api_id: 'gid://shopify/Product/788032119674292922', + body_html: 'An example T-Shirt', + created_at: null, + handle: 'example-t-shirt', + id: 788032119674292900, + product_type: 'Shirts', + published_at: '2021-12-31T19:00:00-05:00', + template_suffix: null, + title: 'Example T-Shirt', + updated_at: '2021-12-31T19:00:00-05:00', + vendor: 'Acme', + status: 'active', + published_scope: 'web', + tags: 'example, mens, t-shirt', + variants: [ + { + admin_graphql_api_id: 'gid://shopify/ProductVariant/642667041472713922', + barcode: null, + compare_at_price: '24.99', + created_at: null, + fulfillment_service: 'manual', + id: 642667041472714000, + inventory_management: 'shopify', + inventory_policy: 'deny', + position: 0, + price: '19.99', + product_id: 788032119674292900, + sku: 'example-shirt-s', + taxable: true, + title: '', + updated_at: null, + option1: 'Small', + option2: null, + option3: null, + grams: 200, + image_id: null, + weight: 200, + weight_unit: 'g', + inventory_item_id: null, + inventory_quantity: 75, + old_inventory_quantity: 75, + requires_shipping: true, + }, + { + admin_graphql_api_id: 'gid://shopify/ProductVariant/757650484644203962', + barcode: null, + compare_at_price: '24.99', + created_at: null, + fulfillment_service: 'manual', + id: 757650484644203900, + inventory_management: 'shopify', + inventory_policy: 'deny', + position: 0, + price: '19.99', + product_id: 788032119674292900, + sku: 'example-shirt-m', + taxable: true, + title: '', + updated_at: null, + option1: 'Medium', + option2: null, + option3: null, + grams: 200, + image_id: null, + weight: 200, + weight_unit: 'g', + inventory_item_id: null, + inventory_quantity: 50, + old_inventory_quantity: 50, + requires_shipping: true, + }, + ], + options: [], + images: [], + image: null, + }, +}); diff --git a/packages/pieces/shopify/src/lib/triggers/updated-customer.ts b/packages/pieces/shopify/src/lib/triggers/updated-customer.ts new file mode 100644 index 0000000000..36445e931a --- /dev/null +++ b/packages/pieces/shopify/src/lib/triggers/updated-customer.ts @@ -0,0 +1,36 @@ +import { createShopifyWebhookTrigger } from '../common/register-webhook'; + +export const updatedCustomer = createShopifyWebhookTrigger({ + name: 'updated_customer', + description: 'Triggered when a customer is updated', + topic: 'customers/updated', + displayName: 'Updated Customer', + sampleData: { + id: 706405506930370000, + email: 'bob@biller.com', + accepts_marketing: true, + created_at: '2021-12-31T19:00:00-05:00', + updated_at: '2021-12-31T19:00:00-05:00', + first_name: 'Bob', + last_name: 'Biller', + orders_count: 0, + state: 'disabled', + total_spent: '0.00', + last_order_id: null, + note: 'This customer loves ice cream', + verified_email: true, + multipass_identifier: null, + tax_exempt: false, + tags: '', + last_order_name: null, + currency: 'USD', + phone: null, + addresses: [], + accepts_marketing_updated_at: '2021-12-31T19:00:00-05:00', + marketing_opt_in_level: null, + tax_exemptions: [], + email_marketing_consent: null, + sms_marketing_consent: null, + admin_graphql_api_id: 'gid://shopify/Customer/706405506930370084', + }, +}); diff --git a/packages/pieces/shopify/src/lib/triggers/updated-order.ts b/packages/pieces/shopify/src/lib/triggers/updated-order.ts new file mode 100644 index 0000000000..e73739ced4 --- /dev/null +++ b/packages/pieces/shopify/src/lib/triggers/updated-order.ts @@ -0,0 +1,401 @@ +import { createShopifyWebhookTrigger } from '../common/register-webhook'; + +export const updatedOrder = createShopifyWebhookTrigger({ + name: 'updated_order', + description: 'Triggered when an order is updated', + topic: 'orders/updated', + displayName: 'Updated Order', + sampleData: { + id: 820982911946154500, + admin_graphql_api_id: 'gid://shopify/Order/820982911946154508', + app_id: null, + browser_ip: null, + buyer_accepts_marketing: true, + cancel_reason: 'customer', + cancelled_at: '2021-12-31T19:00:00-05:00', + cart_token: null, + checkout_id: null, + checkout_token: null, + client_details: null, + closed_at: null, + confirmation_number: null, + confirmed: false, + contact_email: 'jon@example.com', + created_at: '2021-12-31T19:00:00-05:00', + currency: 'USD', + current_subtotal_price: '398.00', + current_subtotal_price_set: { + shop_money: { + amount: '398.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '398.00', + currency_code: 'USD', + }, + }, + current_total_additional_fees_set: null, + current_total_discounts: '0.00', + current_total_discounts_set: { + shop_money: { + amount: '0.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '0.00', + currency_code: 'USD', + }, + }, + current_total_duties_set: null, + current_total_price: '398.00', + current_total_price_set: { + shop_money: { + amount: '398.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '398.00', + currency_code: 'USD', + }, + }, + current_total_tax: '0.00', + current_total_tax_set: { + shop_money: { + amount: '0.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '0.00', + currency_code: 'USD', + }, + }, + customer_locale: 'en', + device_id: null, + discount_codes: [], + email: 'jon@example.com', + estimated_taxes: false, + financial_status: 'voided', + fulfillment_status: 'pending', + landing_site: null, + landing_site_ref: null, + location_id: null, + merchant_of_record_app_id: null, + name: '#9999', + note: null, + note_attributes: [], + number: 234, + order_number: 1234, + order_status_url: + 'https://jsmith.myshopify.com/548380009/orders/123456abcd/authenticate?key=abcdefg', + original_total_additional_fees_set: null, + original_total_duties_set: null, + payment_gateway_names: ['visa', 'bogus'], + phone: null, + po_number: null, + presentment_currency: 'USD', + processed_at: null, + reference: null, + referring_site: null, + source_identifier: null, + source_name: 'web', + source_url: null, + subtotal_price: '388.00', + subtotal_price_set: { + shop_money: { + amount: '388.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '388.00', + currency_code: 'USD', + }, + }, + tags: '', + tax_exempt: false, + tax_lines: [], + taxes_included: false, + test: true, + token: '123456abcd', + total_discounts: '20.00', + total_discounts_set: { + shop_money: { + amount: '20.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '20.00', + currency_code: 'USD', + }, + }, + total_line_items_price: '398.00', + total_line_items_price_set: { + shop_money: { + amount: '398.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '398.00', + currency_code: 'USD', + }, + }, + total_outstanding: '398.00', + total_price: '388.00', + total_price_set: { + shop_money: { + amount: '388.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '388.00', + currency_code: 'USD', + }, + }, + total_shipping_price_set: { + shop_money: { + amount: '10.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '10.00', + currency_code: 'USD', + }, + }, + total_tax: '0.00', + total_tax_set: { + shop_money: { + amount: '0.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '0.00', + currency_code: 'USD', + }, + }, + total_tip_received: '0.00', + total_weight: 0, + updated_at: '2021-12-31T19:00:00-05:00', + user_id: null, + billing_address: { + first_name: 'Steve', + address1: '123 Shipping Street', + phone: '555-555-SHIP', + city: 'Shippington', + zip: '40003', + province: 'Kentucky', + country: 'United States', + last_name: 'Shipper', + address2: null, + company: 'Shipping Company', + latitude: null, + longitude: null, + name: 'Steve Shipper', + country_code: 'US', + province_code: 'KY', + }, + customer: { + id: 115310627314723950, + email: 'john@example.com', + accepts_marketing: false, + created_at: null, + updated_at: null, + first_name: 'John', + last_name: 'Smith', + state: 'disabled', + note: null, + verified_email: true, + multipass_identifier: null, + tax_exempt: false, + phone: null, + email_marketing_consent: { + state: 'not_subscribed', + opt_in_level: null, + consent_updated_at: null, + }, + sms_marketing_consent: null, + tags: '', + currency: 'USD', + accepts_marketing_updated_at: null, + marketing_opt_in_level: null, + tax_exemptions: [], + admin_graphql_api_id: 'gid://shopify/Customer/115310627314723954', + default_address: { + id: 715243470612851200, + customer_id: 115310627314723950, + first_name: null, + last_name: null, + company: null, + address1: '123 Elm St.', + address2: null, + city: 'Ottawa', + province: 'Ontario', + country: 'Canada', + zip: 'K2H7A8', + phone: '123-123-1234', + name: '', + province_code: 'ON', + country_code: 'CA', + country_name: 'Canada', + default: true, + }, + }, + discount_applications: [], + fulfillments: [], + line_items: [ + { + id: 866550311766439000, + admin_graphql_api_id: 'gid://shopify/LineItem/866550311766439020', + attributed_staffs: [ + { + id: 'gid://shopify/StaffMember/902541635', + quantity: 1, + }, + ], + fulfillable_quantity: 1, + fulfillment_service: 'manual', + fulfillment_status: null, + gift_card: false, + grams: 567, + name: 'IPod Nano - 8GB', + price: '199.00', + price_set: { + shop_money: { + amount: '199.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '199.00', + currency_code: 'USD', + }, + }, + product_exists: true, + product_id: 632910392, + properties: [], + quantity: 1, + requires_shipping: true, + sku: 'IPOD2008PINK', + taxable: true, + title: 'IPod Nano - 8GB', + total_discount: '0.00', + total_discount_set: { + shop_money: { + amount: '0.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '0.00', + currency_code: 'USD', + }, + }, + variant_id: 808950810, + variant_inventory_management: 'shopify', + variant_title: null, + vendor: null, + tax_lines: [], + duties: [], + discount_allocations: [], + }, + { + id: 141249953214522980, + admin_graphql_api_id: 'gid://shopify/LineItem/141249953214522974', + attributed_staffs: [], + fulfillable_quantity: 1, + fulfillment_service: 'manual', + fulfillment_status: null, + gift_card: false, + grams: 567, + name: 'IPod Nano - 8GB', + price: '199.00', + price_set: { + shop_money: { + amount: '199.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '199.00', + currency_code: 'USD', + }, + }, + product_exists: true, + product_id: 632910392, + properties: [], + quantity: 1, + requires_shipping: true, + sku: 'IPOD2008PINK', + taxable: true, + title: 'IPod Nano - 8GB', + total_discount: '0.00', + total_discount_set: { + shop_money: { + amount: '0.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '0.00', + currency_code: 'USD', + }, + }, + variant_id: 808950810, + variant_inventory_management: 'shopify', + variant_title: null, + vendor: null, + tax_lines: [], + duties: [], + discount_allocations: [], + }, + ], + payment_terms: null, + refunds: [], + shipping_address: { + first_name: 'Steve', + address1: '123 Shipping Street', + phone: '555-555-SHIP', + city: 'Shippington', + zip: '40003', + province: 'Kentucky', + country: 'United States', + last_name: 'Shipper', + address2: null, + company: 'Shipping Company', + latitude: null, + longitude: null, + name: 'Steve Shipper', + country_code: 'US', + province_code: 'KY', + }, + shipping_lines: [ + { + id: 271878346596884000, + carrier_identifier: null, + code: null, + discounted_price: '10.00', + discounted_price_set: { + shop_money: { + amount: '10.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '10.00', + currency_code: 'USD', + }, + }, + phone: null, + price: '10.00', + price_set: { + shop_money: { + amount: '10.00', + currency_code: 'USD', + }, + presentment_money: { + amount: '10.00', + currency_code: 'USD', + }, + }, + requested_fulfillment_service_id: null, + source: 'shopify', + title: 'Generic Shipping', + tax_lines: [], + discount_allocations: [], + }, + ], + }, +}); From c92585ef8e6c0de84acc1ec167bcffc34fb00eee Mon Sep 17 00:00:00 2001 From: kylebuilds Date: Sun, 29 Oct 2023 17:08:13 -0700 Subject: [PATCH 3/3] targets --- packages/pieces/monday/src/lib/actions/archive-board.ts | 0 packages/pieces/monday/src/lib/actions/archive-group.ts | 0 packages/pieces/monday/src/lib/actions/archive-item.ts | 0 packages/pieces/monday/src/lib/actions/create-board.ts | 0 packages/pieces/monday/src/lib/actions/create-column.ts | 0 packages/pieces/monday/src/lib/actions/create-group.ts | 0 packages/pieces/monday/src/lib/actions/create-subitem.ts | 0 packages/pieces/monday/src/lib/actions/create-update.ts | 0 packages/pieces/monday/src/lib/actions/delete-group.ts | 0 packages/pieces/monday/src/lib/actions/delete-item.ts | 0 packages/pieces/monday/src/lib/actions/get-user.ts | 0 11 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 packages/pieces/monday/src/lib/actions/archive-board.ts create mode 100644 packages/pieces/monday/src/lib/actions/archive-group.ts create mode 100644 packages/pieces/monday/src/lib/actions/archive-item.ts create mode 100644 packages/pieces/monday/src/lib/actions/create-board.ts create mode 100644 packages/pieces/monday/src/lib/actions/create-column.ts create mode 100644 packages/pieces/monday/src/lib/actions/create-group.ts create mode 100644 packages/pieces/monday/src/lib/actions/create-subitem.ts create mode 100644 packages/pieces/monday/src/lib/actions/create-update.ts create mode 100644 packages/pieces/monday/src/lib/actions/delete-group.ts create mode 100644 packages/pieces/monday/src/lib/actions/delete-item.ts create mode 100644 packages/pieces/monday/src/lib/actions/get-user.ts diff --git a/packages/pieces/monday/src/lib/actions/archive-board.ts b/packages/pieces/monday/src/lib/actions/archive-board.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/archive-group.ts b/packages/pieces/monday/src/lib/actions/archive-group.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/archive-item.ts b/packages/pieces/monday/src/lib/actions/archive-item.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/create-board.ts b/packages/pieces/monday/src/lib/actions/create-board.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/create-column.ts b/packages/pieces/monday/src/lib/actions/create-column.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/create-group.ts b/packages/pieces/monday/src/lib/actions/create-group.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/create-subitem.ts b/packages/pieces/monday/src/lib/actions/create-subitem.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/create-update.ts b/packages/pieces/monday/src/lib/actions/create-update.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/delete-group.ts b/packages/pieces/monday/src/lib/actions/delete-group.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/delete-item.ts b/packages/pieces/monday/src/lib/actions/delete-item.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/pieces/monday/src/lib/actions/get-user.ts b/packages/pieces/monday/src/lib/actions/get-user.ts new file mode 100644 index 0000000000..e69de29bb2