-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] paddle #10926 #18510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[Components] paddle #10926 #18510
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import app from "../../paddle.app.mjs"; | ||
|
||
export default { | ||
key: "paddle-create-customer", | ||
name: "Create Customer", | ||
description: "Create a new customer in Paddle. [See the documentation](https://developer.paddle.com/api-reference/customers/create-customer)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
email: { | ||
propDefinition: [ | ||
app, | ||
"email", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
customData: { | ||
propDefinition: [ | ||
app, | ||
"customData", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.createCustomer({ | ||
$, | ||
data: { | ||
email: this.email, | ||
name: this.name, | ||
custom_data: this.customData, | ||
}, | ||
}); | ||
$.export("$summary", "Successfully created a new customer with the ID: " + response.data.id); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import app from "../../paddle.app.mjs"; | ||
|
||
export default { | ||
key: "paddle-get-customers", | ||
name: "Get Customers", | ||
description: "Get a list of customers registered in Paddle. [See the documentation](https://developer.paddle.com/api-reference/customers/list-customers)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.getCustomers({ | ||
$, | ||
}); | ||
$.export("$summary", "Successfully retrieved " + response.data.length + " customers"); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import app from "../../paddle.app.mjs"; | ||
|
||
export default { | ||
key: "paddle-update-customer", | ||
name: "Update Customer", | ||
description: "Update the customer with the specified ID. [See the documentation](https://developer.paddle.com/api-reference/customers/update-customer)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
customerId: { | ||
propDefinition: [ | ||
app, | ||
"customerId", | ||
], | ||
}, | ||
email: { | ||
propDefinition: [ | ||
app, | ||
"email", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
customData: { | ||
propDefinition: [ | ||
app, | ||
"customData", | ||
], | ||
}, | ||
status: { | ||
propDefinition: [ | ||
app, | ||
"status", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.updateCustomer({ | ||
$, | ||
customerId: this.customerId, | ||
data: { | ||
email: this.email, | ||
name: this.name, | ||
custom_data: this.customData, | ||
status: this.status, | ||
}, | ||
}); | ||
$.export("$summary", "Successfully updated the customer with ID: " + this.customerId); | ||
return response; | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
STATUS_OPTIONS: [ | ||
"active", | ||
"archived", | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,11 +1,92 @@ | ||||||||||||||||||||||||||||||||||||||||||||
import { axios } from "@pipedream/platform"; | ||||||||||||||||||||||||||||||||||||||||||||
import constants from "./common/constants.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
export default { | ||||||||||||||||||||||||||||||||||||||||||||
type: "app", | ||||||||||||||||||||||||||||||||||||||||||||
app: "paddle", | ||||||||||||||||||||||||||||||||||||||||||||
propDefinitions: {}, | ||||||||||||||||||||||||||||||||||||||||||||
propDefinitions: { | ||||||||||||||||||||||||||||||||||||||||||||
email: { | ||||||||||||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||||||||||||
label: "Email", | ||||||||||||||||||||||||||||||||||||||||||||
description: "Customer's email address", | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
name: { | ||||||||||||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||||||||||||
label: "Name", | ||||||||||||||||||||||||||||||||||||||||||||
description: "Customer's full name", | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
customData: { | ||||||||||||||||||||||||||||||||||||||||||||
type: "object", | ||||||||||||||||||||||||||||||||||||||||||||
label: "Custom Data", | ||||||||||||||||||||||||||||||||||||||||||||
description: "Your own structured key-value data", | ||||||||||||||||||||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
status: { | ||||||||||||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||||||||||||
label: "Status", | ||||||||||||||||||||||||||||||||||||||||||||
description: "Customer's status", | ||||||||||||||||||||||||||||||||||||||||||||
options: constants.STATUS_OPTIONS, | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
customerId: { | ||||||||||||||||||||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||||||||||||||||||||
label: "Customer ID", | ||||||||||||||||||||||||||||||||||||||||||||
description: "Unique identifier of the customer", | ||||||||||||||||||||||||||||||||||||||||||||
async options() { | ||||||||||||||||||||||||||||||||||||||||||||
const response = await this.getCustomers(); | ||||||||||||||||||||||||||||||||||||||||||||
const data = response.data; | ||||||||||||||||||||||||||||||||||||||||||||
return data.map(({ | ||||||||||||||||||||||||||||||||||||||||||||
id, name, | ||||||||||||||||||||||||||||||||||||||||||||
}) => ({ | ||||||||||||||||||||||||||||||||||||||||||||
value: id, | ||||||||||||||||||||||||||||||||||||||||||||
label: name, | ||||||||||||||||||||||||||||||||||||||||||||
})); | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
methods: { | ||||||||||||||||||||||||||||||||||||||||||||
// this.$auth contains connected account data | ||||||||||||||||||||||||||||||||||||||||||||
authKeys() { | ||||||||||||||||||||||||||||||||||||||||||||
console.log(Object.keys(this.$auth)); | ||||||||||||||||||||||||||||||||||||||||||||
_baseUrl() { | ||||||||||||||||||||||||||||||||||||||||||||
return "https://sandbox-api.paddle.com"; | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
async _makeRequest(opts = {}) { | ||||||||||||||||||||||||||||||||||||||||||||
const { | ||||||||||||||||||||||||||||||||||||||||||||
$ = this, | ||||||||||||||||||||||||||||||||||||||||||||
path, | ||||||||||||||||||||||||||||||||||||||||||||
headers, | ||||||||||||||||||||||||||||||||||||||||||||
...otherOpts | ||||||||||||||||||||||||||||||||||||||||||||
} = opts; | ||||||||||||||||||||||||||||||||||||||||||||
return axios($, { | ||||||||||||||||||||||||||||||||||||||||||||
...otherOpts, | ||||||||||||||||||||||||||||||||||||||||||||
url: this._baseUrl() + path, | ||||||||||||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||||||||||||
Authorization: `Bearer ${this.$auth.auth_code}`, | ||||||||||||||||||||||||||||||||||||||||||||
...headers, | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
async getCustomers(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||
return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||
path: "/customers", | ||||||||||||||||||||||||||||||||||||||||||||
...args, | ||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+67
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 🧩 Analysis chainAdd pagination and filtering support. The -async getCustomers(args = {}) {
+async getCustomers({
+ params, ...args
+} = {}) {
return this._makeRequest({
path: "/customers",
+ params, // Allow passing query parameters like after, per_page, status, etc.
...args,
});
}, 🌐 Web query:
💡 Result: The /customers list endpoint supports these query parameters:
(See Paddle docs: List customers and Pagination/Filter pages.) [1][2][3] Support pagination and filtering in getCustomers The Paddle API’s async getCustomers({ params, ...args } = {}) {
return this._makeRequest({
path: "/customers",
- // …
+ params, // per_page, after, order_by, id, email, status, search
...args,
});
}
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
async createCustomer(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||
return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||
path: "/customers", | ||||||||||||||||||||||||||||||||||||||||||||
method: "post", | ||||||||||||||||||||||||||||||||||||||||||||
...args, | ||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
async updateCustomer({ | ||||||||||||||||||||||||||||||||||||||||||||
customerId, ...args | ||||||||||||||||||||||||||||||||||||||||||||
}) { | ||||||||||||||||||||||||||||||||||||||||||||
return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||
path: `/customers/${customerId}`, | ||||||||||||||||||||||||||||||||||||||||||||
method: "patch", | ||||||||||||||||||||||||||||||||||||||||||||
...args, | ||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+82
to
90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Add validation for customerId parameter. The async updateCustomer({
customerId, ...args
}) {
+ if (!customerId) {
+ throw new Error("customerId is required");
+ }
return this._makeRequest({
- path: `/customers/${customerId}`,
+ path: `/customers/${encodeURIComponent(customerId)}`,
method: "patch",
...args,
});
}, 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
CRITICAL: Hardcoded sandbox API URL blocks production usage.
The base URL is hardcoded to Paddle's sandbox environment. This makes the integration unusable in production. The URL should be configurable or determined by the authentication configuration.
Apply this diff to make the environment configurable:
Alternatively, if the auth configuration doesn't include an environment field, you may need to add a separate prop or configuration option.
🌐 Web query:
💡 Result:
Production (live) API base URL: https://api.paddle.com. [1]
Sandbox API base URL: https://sandbox-api.paddle.com. [1]
How integrations typically handle sandbox vs production
Sources: Paddle developer docs (sandbox & base URLs, API keys, SDK environment, go‑live checklist). [1][2][3][4]
CRITICAL — hardcoded sandbox API URL; make base URL environment-configurable
File: components/paddle/paddle.app.mjs (lines 47–49) — _baseUrl() currently returns "https://sandbox-api.paddle.com". Production base URL is "https://api.paddle.com" and sandbox/live credentials are not interchangeable (mismatched key+URL returns 403). Replace with environment/config-driven selection (default to production). Example:
Document PADDLE_ENV/PADDLE_BASE_URL and ensure sandbox vs live credentials are switched together.
📝 Committable suggestion
🤖 Prompt for AI Agents