You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by gi...@apache.org on 2026/09/01 07:12:35 UTC
(seatunnel) 01/01: [Feature][Connector-V2] Add Stripe PaymentIntents source (#11940)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/dev/pr-11940-5dbfb374f985349aeefde9cf84169aa98b3ac5ca
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
commit 3343731850f90dd101d760543d8352d29bc78cd9
Author: Goutam Adwant <86...@users.noreply.github.com>
AuthorDate: Tue Sep 1 07:12:08 2026 +0000
[Feature][Connector-V2] Add Stripe PaymentIntents source (#11940)
Signed-off-by: goutamadwant <wo...@gmail.com>
Signed-off-by: Goutam Adwant <wo...@gmail.com>
---
config/plugin_config | 1 +
.../connectors/changelog/connector-http-stripe.md | 6 +
docs/en/connectors/source/Stripe.md | 91 ++++++
.../connectors/changelog/connector-http-stripe.md | 6 +
docs/zh/connectors/source/Stripe.md | 91 ++++++
plugin-mapping.properties | 1 +
.../{ => connector-http-stripe}/pom.xml | 32 +-
.../seatunnel/stripe/source/StripeSource.java | 99 ++++++
.../stripe/source/StripeSourceFactory.java | 73 +++++
.../stripe/source/StripeSourceReader.java | 240 +++++++++++++++
.../stripe/source/config/StripeSourceOptions.java | 78 +++++
.../source/config/StripeSourceParameter.java | 148 +++++++++
.../stripe/StripeSourceParameterTest.java | 113 +++++++
.../stripe/source/StripeSourceReaderTest.java | 332 +++++++++++++++++++++
seatunnel-connectors-v2/connector-http/pom.xml | 1 +
seatunnel-dist/pom.xml | 6 +
.../connector-http-e2e/pom.xml | 6 +
.../seatunnel/e2e/connector/http/StripeIT.java | 81 +++++
.../stripe_payment_intents_to_assert.conf | 59 ++++
19 files changed, 1443 insertions(+), 21 deletions(-)
diff --git a/config/plugin_config b/config/plugin_config
index 4e2ab94100..2e85547eda 100644
--- a/config/plugin_config
+++ b/config/plugin_config
@@ -63,6 +63,7 @@ connector-http-gitlab
connector-http-github
connector-http-jira
connector-http-klaviyo
+connector-http-stripe
connector-http-lemlist
connector-http-myhours
connector-http-notion
diff --git a/docs/en/connectors/changelog/connector-http-stripe.md b/docs/en/connectors/changelog/connector-http-stripe.md
new file mode 100644
index 0000000000..1cf41e674b
--- /dev/null
+++ b/docs/en/connectors/changelog/connector-http-stripe.md
@@ -0,0 +1,6 @@
+<details><summary> Change Log </summary>
+
+| Change | Commit | Version |
+| --- | --- | --- |
+
+</details>
diff --git a/docs/en/connectors/source/Stripe.md b/docs/en/connectors/source/Stripe.md
new file mode 100644
index 0000000000..b77b511985
--- /dev/null
+++ b/docs/en/connectors/source/Stripe.md
@@ -0,0 +1,91 @@
+import ChangeLog from '../changelog/connector-http-stripe.md';
+
+# Stripe
+
+> Stripe PaymentIntents source connector
+
+## Description
+
+Reads PaymentIntent objects from Stripe as a bounded batch source. Each output row contains one complete PaymentIntent JSON object in the `content` string column.
+
+The connector follows Stripe's reverse-chronological list order and uses the last object ID from each response as the `starting_after` cursor for the next page.
+
+## Key features
+
+- [x] [batch](../../introduction/concepts/connector-v2-features.md)
+- [ ] [stream](../../introduction/concepts/connector-v2-features.md)
+- [ ] [exactly-once](../../introduction/concepts/connector-v2-features.md)
+- [ ] [column projection](../../introduction/concepts/connector-v2-features.md)
+- [ ] [parallelism](../../introduction/concepts/connector-v2-features.md)
+- [ ] [support user-defined split](../../introduction/concepts/connector-v2-features.md)
+
+## Options
+
+| name | type | required | default value | description |
+|------|------|----------|---------------|-------------|
+| secret_key | String | Yes | - | Stripe secret API key. The connector sends it as a Bearer token and does not include it in connector logs. |
+| api_base_url | String | No | `https://api.stripe.com` | Stripe API base URL. This is primarily useful for local testing through a compatible HTTP endpoint. |
+| api_version | String | No | - | Stripe API version sent in the `Stripe-Version` header. Pin this when a job needs a stable Stripe response contract. |
+| page_size | int | No | 100 | PaymentIntents requested per page. The allowed range is 1 to 100. |
+| created_gte | long | No | - | Inclusive lower `created` boundary in Unix seconds. |
+| created_lt | long | No | - | Exclusive upper `created` boundary in Unix seconds. When both boundaries are set, `created_gte` must be lower than `created_lt`. |
+| rate_limit_max_retries | int | No | 3 | Maximum retries after an HTTP 429 response. |
+| rate_limit_backoff_ms | int | No | 1000 | Initial exponential backoff after an HTTP 429 response. Backoff is capped at 60 seconds. |
+| retry | int | No | - | Maximum retry count for transport-level `IOException` failures. |
+| retry_backoff_multiplier_ms | int | No | 100 | Retry backoff multiplier for transport failures. |
+| retry_backoff_max_ms | int | No | 10000 | Maximum retry backoff for transport failures. |
+| connect_timeout_ms | int | No | 12000 | HTTP connection timeout. |
+| socket_timeout_ms | int | No | 60000 | HTTP socket timeout. |
+| common-options | config | No | - | Source common options. See [Source Common Options](../common-options/source-common-options.md). |
+
+## Output
+
+The source has a stable single-column schema:
+
+| column | type | description |
+|--------|------|-------------|
+| content | string | One complete PaymentIntent object serialized as JSON. |
+
+Returning the complete object avoids treating Stripe's expandable fields and metadata keys as a fixed relational schema. Use a transform after this source when individual fields are needed.
+
+PaymentIntent objects can contain sensitive values such as `client_secret`. Protect the source output and downstream storage accordingly. A custom `api_base_url` also receives the configured API key, so use only a trusted HTTPS endpoint outside local testing.
+
+## Time boundaries and recovery
+
+Stripe returns PaymentIntents in reverse chronological order. The connector uses `starting_after` with the last ID from each page, so every request continues toward older objects within the same list operation.
+
+For repeatable scheduled extracts, use a half-open time range: `created_gte` is inclusive and `created_lt` is exclusive. Adjacent runs can therefore use `[previous_end, current_end)` without overlapping their time boundaries.
+
+This V1 connector uses SeaTunnel's bounded single-split source model. If a task fails before the batch completes, recovery starts the bounded read again from the configured time range. Downstream processing should therefore tolerate replayed rows.
+
+The Stripe list API is not a transactional snapshot. A PaymentIntent can change while a multi-page read is in progress. The time range bounds which objects are selected, but it does not freeze their contents. Set `api_version` when the JSON contract must remain stable across account API-version changes.
+
+## Example
+
+```hocon
+env {
+ parallelism = 1
+ job.mode = "BATCH"
+}
+
+source {
+ Stripe {
+ plugin_output = "stripe_payment_intents"
+ secret_key = "${STRIPE_SECRET_KEY}"
+ api_version = "2026-02-25.clover"
+ page_size = 100
+ created_gte = 1754006400
+ created_lt = 1754092800
+ }
+}
+
+sink {
+ Console {
+ plugin_input = "stripe_payment_intents"
+ }
+}
+```
+
+## Changelog
+
+<ChangeLog />
diff --git a/docs/zh/connectors/changelog/connector-http-stripe.md b/docs/zh/connectors/changelog/connector-http-stripe.md
new file mode 100644
index 0000000000..1cf41e674b
--- /dev/null
+++ b/docs/zh/connectors/changelog/connector-http-stripe.md
@@ -0,0 +1,6 @@
+<details><summary> Change Log </summary>
+
+| Change | Commit | Version |
+| --- | --- | --- |
+
+</details>
diff --git a/docs/zh/connectors/source/Stripe.md b/docs/zh/connectors/source/Stripe.md
new file mode 100644
index 0000000000..d984de4fa7
--- /dev/null
+++ b/docs/zh/connectors/source/Stripe.md
@@ -0,0 +1,91 @@
+import ChangeLog from '../changelog/connector-http-stripe.md';
+
+# Stripe
+
+> Stripe PaymentIntents 源连接器
+
+## 描述
+
+以有界批处理方式读取 Stripe PaymentIntent 对象。每一行输出都在 `content` 字符串列中包含一个完整的 PaymentIntent JSON 对象。
+
+连接器按照 Stripe 的逆时间顺序读取列表,并使用每次响应中最后一个对象的 ID 作为下一页请求的 `starting_after` 游标。
+
+## 关键特性
+
+- [x] [批处理](../../introduction/concepts/connector-v2-features.md)
+- [ ] [流处理](../../introduction/concepts/connector-v2-features.md)
+- [ ] [精确一次](../../introduction/concepts/connector-v2-features.md)
+- [ ] [列投影](../../introduction/concepts/connector-v2-features.md)
+- [ ] [并行度](../../introduction/concepts/connector-v2-features.md)
+- [ ] [支持用户定义分片](../../introduction/concepts/connector-v2-features.md)
+
+## 选项
+
+| 名称 | 类型 | 是否必填 | 默认值 | 说明 |
+|------|------|----------|--------|------|
+| secret_key | String | 是 | - | Stripe 私有 API Key。连接器以 Bearer Token 发送该值,不会把它写入连接器日志。 |
+| api_base_url | String | 否 | `https://api.stripe.com` | Stripe API 基础地址,主要用于通过兼容的 HTTP 地址进行本地测试。 |
+| api_version | String | 否 | - | 通过 `Stripe-Version` 请求头指定 Stripe API 版本。需要稳定响应契约时建议固定该值。 |
+| page_size | int | 否 | 100 | 每页请求的 PaymentIntent 数量,范围为 1 到 100。 |
+| created_gte | long | 否 | - | `created` 时间的包含式下界,使用 Unix 秒。 |
+| created_lt | long | 否 | - | `created` 时间的不包含式上界,使用 Unix 秒。两个边界同时配置时,`created_gte` 必须小于 `created_lt`。 |
+| rate_limit_max_retries | int | 否 | 3 | 收到 HTTP 429 后的最大重试次数。 |
+| rate_limit_backoff_ms | int | 否 | 1000 | 收到 HTTP 429 后的初始指数退避时间,最大为 60 秒。 |
+| retry | int | 否 | - | 传输层发生 `IOException` 时的最大重试次数。 |
+| retry_backoff_multiplier_ms | int | 否 | 100 | 传输失败时的重试退避倍数。 |
+| retry_backoff_max_ms | int | 否 | 10000 | 传输失败时的最大重试退避时间。 |
+| connect_timeout_ms | int | 否 | 12000 | HTTP 连接超时时间。 |
+| socket_timeout_ms | int | 否 | 60000 | HTTP Socket 超时时间。 |
+| common-options | config | 否 | - | Source 通用选项,详见 [Source Common Options](../common-options/source-common-options.md)。 |
+
+## 输出
+
+该 Source 使用固定的单列结构:
+
+| 列名 | 类型 | 说明 |
+|------|------|------|
+| content | string | 序列化为 JSON 的完整 PaymentIntent 对象。 |
+
+完整返回对象可以避免把 Stripe 可展开字段和动态 metadata 键误认为固定的关系型结构。需要单独字段时,可以在 Source 后增加 Transform。
+
+PaymentIntent 对象可能包含 `client_secret` 等敏感值,请保护 Source 输出和下游存储。自定义 `api_base_url` 也会收到配置的 API Key,因此除本地测试外,只应使用可信的 HTTPS 地址。
+
+## 时间边界和恢复
+
+Stripe 按逆时间顺序返回 PaymentIntent。连接器使用每一页最后一个 ID 作为 `starting_after`,使后续请求继续读取更早的对象。
+
+对于可重复执行的定时抽取,建议使用半开时间范围:`created_gte` 包含下界,`created_lt` 不包含上界。相邻任务可以使用 `[previous_end, current_end)`,不会在时间边界上产生重叠。
+
+V1 使用 SeaTunnel 有界单分片 Source 模型。如果任务在批处理完成前失败,恢复时会从配置的时间范围重新开始读取。因此下游处理应能接受重复读取的行。
+
+Stripe 列表 API 不是事务快照。多页读取期间,PaymentIntent 的内容可能发生变化。时间范围只限制被选择的对象,不会冻结对象内容。需要避免账户 API 版本变化影响 JSON 契约时,请配置 `api_version`。
+
+## 示例
+
+```hocon
+env {
+ parallelism = 1
+ job.mode = "BATCH"
+}
+
+source {
+ Stripe {
+ plugin_output = "stripe_payment_intents"
+ secret_key = "${STRIPE_SECRET_KEY}"
+ api_version = "2026-02-25.clover"
+ page_size = 100
+ created_gte = 1754006400
+ created_lt = 1754092800
+ }
+}
+
+sink {
+ Console {
+ plugin_input = "stripe_payment_intents"
+ }
+}
+```
+
+## 变更日志
+
+<ChangeLog />
diff --git a/plugin-mapping.properties b/plugin-mapping.properties
index ea41a4b954..3a0e9b2599 100644
--- a/plugin-mapping.properties
+++ b/plugin-mapping.properties
@@ -103,6 +103,7 @@ seatunnel.source.Tablestore = connector-tablestore
seatunnel.source.Lemlist = connector-http-lemlist
seatunnel.source.Klaviyo = connector-http-klaviyo
seatunnel.source.Zendesk = connector-http-zendesk
+seatunnel.source.Stripe = connector-http-stripe
seatunnel.sink.Slack = connector-slack
seatunnel.source.OneSignal = connector-http-onesignal
seatunnel.source.Jira = connector-http-jira
diff --git a/seatunnel-connectors-v2/connector-http/pom.xml b/seatunnel-connectors-v2/connector-http/connector-http-stripe/pom.xml
similarity index 57%
copy from seatunnel-connectors-v2/connector-http/pom.xml
copy to seatunnel-connectors-v2/connector-http/connector-http-stripe/pom.xml
index 7584cef02b..efcbce5517 100644
--- a/seatunnel-connectors-v2/connector-http/pom.xml
+++ b/seatunnel-connectors-v2/connector-http/connector-http-stripe/pom.xml
@@ -22,29 +22,19 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.seatunnel</groupId>
- <artifactId>seatunnel-connectors-v2</artifactId>
+ <artifactId>connector-http</artifactId>
<version>${revision}</version>
</parent>
- <artifactId>connector-http</artifactId>
- <packaging>pom</packaging>
- <name>SeaTunnel : Connectors V2 : Http :</name>
- <modules>
- <module>connector-http-base</module>
- <module>connector-http-feishu</module>
- <module>connector-http-wechat</module>
- <module>connector-http-myhours</module>
- <module>connector-http-lemlist</module>
- <module>connector-http-klaviyo</module>
- <module>connector-http-onesignal</module>
- <module>connector-http-jira</module>
- <module>connector-http-gitlab</module>
- <module>connector-http-github</module>
- <module>connector-http-notion</module>
- <module>connector-http-persistiq</module>
- <module>connector-http-airtable</module>
- <module>connector-http-posthog</module>
- <module>connector-http-zendesk</module>
- </modules>
+ <artifactId>connector-http-stripe</artifactId>
+ <name>SeaTunnel : Connectors V2 : Http : Stripe</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.seatunnel</groupId>
+ <artifactId>connector-http-base</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSource.java b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSource.java
new file mode 100644
index 0000000000..170abae0f3
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSource.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.stripe.source;
+
+import org.apache.seatunnel.shade.com.google.common.collect.Lists;
+
+import org.apache.seatunnel.api.common.JobContext;
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.PhysicalColumn;
+import org.apache.seatunnel.api.table.catalog.TableIdentifier;
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import org.apache.seatunnel.api.table.catalog.TableSchema;
+import org.apache.seatunnel.api.table.type.BasicType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.common.constants.JobMode;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitSource;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.stripe.source.config.StripeSourceParameter;
+
+import java.util.Collections;
+import java.util.List;
+
+public class StripeSource extends AbstractSingleSplitSource<SeaTunnelRow> {
+
+ public static final String PLUGIN_NAME = "Stripe";
+
+ private final StripeSourceParameter sourceParameter = new StripeSourceParameter();
+ private final CatalogTable catalogTable;
+ private JobContext jobContext;
+
+ public StripeSource(ReadonlyConfig pluginConfig) {
+ sourceParameter.buildWithConfig(pluginConfig);
+ TableSchema tableSchema =
+ TableSchema.builder()
+ .column(
+ PhysicalColumn.of(
+ "content",
+ BasicType.STRING_TYPE,
+ 0,
+ false,
+ null,
+ "PaymentIntent object as JSON"))
+ .build();
+ catalogTable =
+ CatalogTable.of(
+ TableIdentifier.of(PLUGIN_NAME, TablePath.DEFAULT),
+ tableSchema,
+ Collections.emptyMap(),
+ Collections.emptyList(),
+ null);
+ }
+
+ @Override
+ public String getPluginName() {
+ return PLUGIN_NAME;
+ }
+
+ @Override
+ public Boundedness getBoundedness() {
+ if (JobMode.BATCH.equals(jobContext.getJobMode())) {
+ return Boundedness.BOUNDED;
+ }
+ throw new UnsupportedOperationException("Stripe source only supports batch jobs");
+ }
+
+ @Override
+ public List<CatalogTable> getProducedCatalogTables() {
+ return Lists.newArrayList(catalogTable);
+ }
+
+ @Override
+ public AbstractSingleSplitReader<SeaTunnelRow> createReader(
+ SingleSplitReaderContext readerContext) {
+ return new StripeSourceReader(sourceParameter, readerContext);
+ }
+
+ @Override
+ public void setJobContext(JobContext jobContext) {
+ this.jobContext = jobContext;
+ }
+}
diff --git a/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSourceFactory.java b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSourceFactory.java
new file mode 100644
index 0000000000..4af3151493
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSourceFactory.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.stripe.source;
+
+import org.apache.seatunnel.api.configuration.util.OptionRule;
+import org.apache.seatunnel.api.source.SeaTunnelSource;
+import org.apache.seatunnel.api.source.SourceSplit;
+import org.apache.seatunnel.api.table.connector.TableSource;
+import org.apache.seatunnel.api.table.factory.Factory;
+import org.apache.seatunnel.api.table.factory.TableSourceFactory;
+import org.apache.seatunnel.api.table.factory.TableSourceFactoryContext;
+import org.apache.seatunnel.connectors.seatunnel.http.config.HttpCommonOptions;
+import org.apache.seatunnel.connectors.seatunnel.http.config.HttpSourceOptions;
+import org.apache.seatunnel.connectors.seatunnel.stripe.source.config.StripeSourceOptions;
+
+import com.google.auto.service.AutoService;
+
+import java.io.Serializable;
+
+@AutoService(Factory.class)
+public class StripeSourceFactory implements TableSourceFactory {
+
+ @Override
+ public String factoryIdentifier() {
+ return StripeSource.PLUGIN_NAME;
+ }
+
+ @Override
+ public OptionRule optionRule() {
+ return OptionRule.builder()
+ .required(StripeSourceOptions.SECRET_KEY)
+ .optional(
+ StripeSourceOptions.API_BASE_URL,
+ StripeSourceOptions.API_VERSION,
+ StripeSourceOptions.PAGE_SIZE,
+ StripeSourceOptions.CREATED_GTE,
+ StripeSourceOptions.CREATED_LT,
+ StripeSourceOptions.RATE_LIMIT_MAX_RETRIES,
+ StripeSourceOptions.RATE_LIMIT_BACKOFF_MS,
+ HttpCommonOptions.RETRY,
+ HttpCommonOptions.RETRY_BACKOFF_MULTIPLIER_MS,
+ HttpCommonOptions.RETRY_BACKOFF_MAX_MS,
+ HttpSourceOptions.CONNECT_TIMEOUT_MS,
+ HttpSourceOptions.SOCKET_TIMEOUT_MS)
+ .build();
+ }
+
+ @Override
+ public <T, SplitT extends SourceSplit, StateT extends Serializable>
+ TableSource<T, SplitT, StateT> createSource(TableSourceFactoryContext context) {
+ return () -> (SeaTunnelSource<T, SplitT, StateT>) new StripeSource(context.getOptions());
+ }
+
+ @Override
+ public Class<? extends SeaTunnelSource> getSourceClass() {
+ return StripeSource.class;
+ }
+}
diff --git a/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSourceReader.java b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSourceReader.java
new file mode 100644
index 0000000000..b5820bcd91
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSourceReader.java
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.stripe.source;
+
+import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.JsonNode;
+import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.node.ArrayNode;
+import org.apache.seatunnel.shade.com.google.common.annotations.VisibleForTesting;
+
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.common.utils.JsonUtils;
+import org.apache.seatunnel.connectors.seatunnel.common.source.AbstractSingleSplitReader;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.http.client.HttpClientProvider;
+import org.apache.seatunnel.connectors.seatunnel.http.client.HttpResponse;
+import org.apache.seatunnel.connectors.seatunnel.http.exception.HttpConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.http.exception.HttpConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.stripe.source.config.StripeSourceParameter;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+@Slf4j
+public class StripeSourceReader extends AbstractSingleSplitReader<SeaTunnelRow> {
+
+ private static final int HTTP_TOO_MANY_REQUESTS = 429;
+ private static final int MAX_ERROR_BODY_LENGTH = 1024;
+ private static final long MAX_RATE_LIMIT_BACKOFF_MS = 60000L;
+
+ private final StripeSourceParameter sourceParameter;
+ private final SingleSplitReaderContext context;
+ private final Sleeper sleeper;
+ private HttpClientProvider httpClient;
+
+ public StripeSourceReader(
+ StripeSourceParameter sourceParameter, SingleSplitReaderContext context) {
+ this(sourceParameter, context, Thread::sleep);
+ }
+
+ @VisibleForTesting
+ StripeSourceReader(
+ StripeSourceParameter sourceParameter,
+ SingleSplitReaderContext context,
+ Sleeper sleeper) {
+ this.sourceParameter = sourceParameter;
+ this.context = context;
+ this.sleeper = sleeper;
+ }
+
+ @Override
+ public void open() {
+ httpClient = new HttpClientProvider(sourceParameter);
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (httpClient != null) {
+ httpClient.close();
+ }
+ }
+
+ @Override
+ public void internalPollNext(Collector<SeaTunnelRow> output) throws Exception {
+ String cursor = null;
+ Set<String> seenCursors = new HashSet<>();
+ do {
+ sourceParameter.setStartingAfter(cursor);
+ StripePage page = fetchPage(seenCursors);
+ for (String paymentIntent : page.paymentIntents) {
+ output.collect(new SeaTunnelRow(new Object[] {paymentIntent}));
+ }
+ cursor = page.nextCursor;
+ } while (cursor != null);
+ context.signalNoMoreElement();
+ }
+
+ private StripePage fetchPage(Set<String> seenCursors) throws Exception {
+ HttpResponse response = executeWithRateLimitRetry();
+ if (response.getCode() < 200 || response.getCode() > 299) {
+ throw requestFailed(response);
+ }
+
+ JsonNode root;
+ try {
+ root = JsonUtils.stringToJsonNode(response.getContent());
+ } catch (RuntimeException e) {
+ throw new HttpConnectorException(
+ HttpConnectorErrorCode.REQUEST_FAILED,
+ "Stripe PaymentIntents response is not valid JSON",
+ e);
+ }
+ JsonNode dataNode = root.get("data");
+ JsonNode hasMoreNode = root.get("has_more");
+ if (!(dataNode instanceof ArrayNode) || hasMoreNode == null || !hasMoreNode.isBoolean()) {
+ throw new HttpConnectorException(
+ HttpConnectorErrorCode.REQUEST_FAILED,
+ "Stripe PaymentIntents response must contain array 'data' and boolean 'has_more'");
+ }
+
+ ArrayNode data = (ArrayNode) dataNode;
+ List<String> paymentIntents = new ArrayList<>(data.size());
+ String lastId = null;
+ for (JsonNode paymentIntent : data) {
+ JsonNode idNode = paymentIntent.get("id");
+ if (!paymentIntent.isObject()
+ || idNode == null
+ || !idNode.isTextual()
+ || idNode.textValue().isEmpty()) {
+ throw new HttpConnectorException(
+ HttpConnectorErrorCode.REQUEST_FAILED,
+ "Every Stripe PaymentIntent must be an object with a non-empty string 'id'");
+ }
+ lastId = idNode.textValue();
+ paymentIntents.add(paymentIntent.toString());
+ }
+
+ String nextCursor = null;
+ if (hasMoreNode.booleanValue()) {
+ if (lastId == null) {
+ throw new HttpConnectorException(
+ HttpConnectorErrorCode.REQUEST_FAILED,
+ "Stripe returned has_more=true with an empty PaymentIntents page");
+ }
+ if (!seenCursors.add(lastId)) {
+ throw new HttpConnectorException(
+ HttpConnectorErrorCode.REQUEST_FAILED,
+ "Stripe pagination repeated cursor '" + lastId + "'");
+ }
+ nextCursor = lastId;
+ }
+ return new StripePage(paymentIntents, nextCursor);
+ }
+
+ private HttpResponse executeWithRateLimitRetry() throws Exception {
+ int retries = 0;
+ while (true) {
+ HttpResponse response =
+ httpClient.execute(
+ sourceParameter.getUrl(),
+ sourceParameter.getMethod().getMethod(),
+ sourceParameter.getHeaders(),
+ sourceParameter.getParams(),
+ sourceParameter.getBody(),
+ sourceParameter.isKeepParamsAsForm());
+ if (response.getCode() != HTTP_TOO_MANY_REQUESTS
+ || retries >= sourceParameter.getRateLimitMaxRetries()) {
+ return response;
+ }
+ retries++;
+ long backoffMillis = calculateBackoffMillis(retries);
+ log.warn(
+ "Stripe API rate limit reached, retry {}/{} after {} ms",
+ retries,
+ sourceParameter.getRateLimitMaxRetries(),
+ backoffMillis);
+ try {
+ sleeper.sleep(backoffMillis);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new HttpConnectorException(
+ HttpConnectorErrorCode.REQUEST_FAILED,
+ "Interrupted while waiting to retry Stripe request",
+ e);
+ }
+ }
+ }
+
+ @VisibleForTesting
+ long calculateBackoffMillis(int retryNumber) {
+ if (sourceParameter.getRateLimitBackoffMs() == 0) {
+ return 0L;
+ }
+ int exponent = Math.min(20, Math.max(0, retryNumber - 1));
+ long multiplier = 1L << exponent;
+ long base = sourceParameter.getRateLimitBackoffMs();
+ if (base > MAX_RATE_LIMIT_BACKOFF_MS / multiplier) {
+ return MAX_RATE_LIMIT_BACKOFF_MS;
+ }
+ return Math.min(base * multiplier, MAX_RATE_LIMIT_BACKOFF_MS);
+ }
+
+ private HttpConnectorException requestFailed(HttpResponse response) {
+ String responseBody = response.getContent();
+ if (responseBody == null) {
+ responseBody = "";
+ } else {
+ String authorization = sourceParameter.getHeaders().get("Authorization");
+ if (authorization != null && authorization.startsWith("Bearer ")) {
+ String secretKey = authorization.substring("Bearer ".length());
+ if (!secretKey.isEmpty()) {
+ responseBody = responseBody.replace(secretKey, "[REDACTED]");
+ }
+ }
+ }
+ if (responseBody.length() > MAX_ERROR_BODY_LENGTH) {
+ responseBody = responseBody.substring(0, MAX_ERROR_BODY_LENGTH) + "...";
+ }
+ return new HttpConnectorException(
+ HttpConnectorErrorCode.REQUEST_FAILED,
+ "Stripe PaymentIntents request failed with HTTP "
+ + response.getCode()
+ + ": "
+ + responseBody);
+ }
+
+ @FunctionalInterface
+ interface Sleeper {
+ void sleep(long millis) throws InterruptedException;
+ }
+
+ private static final class StripePage {
+ private final List<String> paymentIntents;
+ private final String nextCursor;
+
+ private StripePage(List<String> paymentIntents, String nextCursor) {
+ this.paymentIntents = paymentIntents;
+ this.nextCursor = nextCursor;
+ }
+ }
+}
diff --git a/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/config/StripeSourceOptions.java b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/config/StripeSourceOptions.java
new file mode 100644
index 0000000000..78199333e9
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/config/StripeSourceOptions.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.stripe.source.config;
+
+import org.apache.seatunnel.api.configuration.Option;
+import org.apache.seatunnel.api.configuration.Options;
+
+public final class StripeSourceOptions {
+
+ public static final String DEFAULT_API_BASE_URL = "https://api.stripe.com";
+
+ public static final Option<String> SECRET_KEY =
+ Options.key("secret_key")
+ .stringType()
+ .noDefaultValue()
+ .withDescription("Stripe secret API key used for Bearer authentication");
+
+ public static final Option<String> API_BASE_URL =
+ Options.key("api_base_url")
+ .stringType()
+ .defaultValue(DEFAULT_API_BASE_URL)
+ .withDescription("Stripe API base URL");
+
+ public static final Option<String> API_VERSION =
+ Options.key("api_version")
+ .stringType()
+ .noDefaultValue()
+ .withDescription(
+ "Optional Stripe API version sent in the Stripe-Version header");
+
+ public static final Option<Integer> PAGE_SIZE =
+ Options.key("page_size")
+ .intType()
+ .defaultValue(100)
+ .withDescription("Number of PaymentIntents requested per page, from 1 to 100");
+
+ public static final Option<Long> CREATED_GTE =
+ Options.key("created_gte")
+ .longType()
+ .noDefaultValue()
+ .withDescription("Inclusive lower created-time boundary as Unix seconds");
+
+ public static final Option<Long> CREATED_LT =
+ Options.key("created_lt")
+ .longType()
+ .noDefaultValue()
+ .withDescription("Exclusive upper created-time boundary as Unix seconds");
+
+ public static final Option<Integer> RATE_LIMIT_MAX_RETRIES =
+ Options.key("rate_limit_max_retries")
+ .intType()
+ .defaultValue(3)
+ .withDescription("Maximum retries after a Stripe HTTP 429 response");
+
+ public static final Option<Integer> RATE_LIMIT_BACKOFF_MS =
+ Options.key("rate_limit_backoff_ms")
+ .intType()
+ .defaultValue(1000)
+ .withDescription(
+ "Initial exponential backoff after a Stripe HTTP 429 response");
+
+ private StripeSourceOptions() {}
+}
diff --git a/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/config/StripeSourceParameter.java b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/config/StripeSourceParameter.java
new file mode 100644
index 0000000000..400b89451b
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/main/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/config/StripeSourceParameter.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.stripe.source.config;
+
+import org.apache.seatunnel.shade.com.google.common.base.Strings;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.connectors.seatunnel.http.config.HttpCommonOptions;
+import org.apache.seatunnel.connectors.seatunnel.http.config.HttpParameter;
+import org.apache.seatunnel.connectors.seatunnel.http.config.HttpRequestMethod;
+import org.apache.seatunnel.connectors.seatunnel.http.config.HttpSourceOptions;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class StripeSourceParameter extends HttpParameter {
+
+ private static final String PAYMENT_INTENTS_PATH = "/v1/payment_intents";
+ private static final String AUTHORIZATION = "Authorization";
+ private static final String ACCEPT = "Accept";
+ private static final String STRIPE_VERSION = "Stripe-Version";
+
+ private int rateLimitMaxRetries;
+ private int rateLimitBackoffMs;
+
+ @Override
+ public void buildWithConfig(ReadonlyConfig pluginConfig) {
+ String secretKey = pluginConfig.get(StripeSourceOptions.SECRET_KEY);
+ if (Strings.isNullOrEmpty(secretKey) || secretKey.trim().isEmpty()) {
+ throw new IllegalArgumentException("Stripe option 'secret_key' must not be blank");
+ }
+
+ String apiBaseUrl = pluginConfig.get(StripeSourceOptions.API_BASE_URL);
+ if (Strings.isNullOrEmpty(apiBaseUrl) || apiBaseUrl.trim().isEmpty()) {
+ throw new IllegalArgumentException("Stripe option 'api_base_url' must not be blank");
+ }
+
+ int pageSize = pluginConfig.get(StripeSourceOptions.PAGE_SIZE);
+ if (pageSize < 1 || pageSize > 100) {
+ throw new IllegalArgumentException(
+ "Stripe option 'page_size' must be between 1 and 100");
+ }
+
+ Long createdGte = pluginConfig.getOptional(StripeSourceOptions.CREATED_GTE).orElse(null);
+ Long createdLt = pluginConfig.getOptional(StripeSourceOptions.CREATED_LT).orElse(null);
+ if (createdGte != null && createdGte < 0) {
+ throw new IllegalArgumentException("Stripe option 'created_gte' must not be negative");
+ }
+ if (createdLt != null && createdLt < 0) {
+ throw new IllegalArgumentException("Stripe option 'created_lt' must not be negative");
+ }
+ if (createdGte != null && createdLt != null && createdGte >= createdLt) {
+ throw new IllegalArgumentException(
+ "Stripe option 'created_gte' must be less than 'created_lt'");
+ }
+
+ this.rateLimitMaxRetries = pluginConfig.get(StripeSourceOptions.RATE_LIMIT_MAX_RETRIES);
+ this.rateLimitBackoffMs = pluginConfig.get(StripeSourceOptions.RATE_LIMIT_BACKOFF_MS);
+ if (rateLimitMaxRetries < 0) {
+ throw new IllegalArgumentException(
+ "Stripe option 'rate_limit_max_retries' must not be negative");
+ }
+ if (rateLimitBackoffMs < 0) {
+ throw new IllegalArgumentException(
+ "Stripe option 'rate_limit_backoff_ms' must not be negative");
+ }
+
+ setUrl(trimTrailingSlash(apiBaseUrl.trim()) + PAYMENT_INTENTS_PATH);
+ setMethod(HttpRequestMethod.GET);
+
+ Map<String, String> requestHeaders = new LinkedHashMap<>();
+ requestHeaders.put(AUTHORIZATION, "Bearer " + secretKey);
+ requestHeaders.put(ACCEPT, "application/json");
+ pluginConfig
+ .getOptional(StripeSourceOptions.API_VERSION)
+ .filter(version -> !version.trim().isEmpty())
+ .ifPresent(version -> requestHeaders.put(STRIPE_VERSION, version.trim()));
+ setHeaders(requestHeaders);
+
+ Map<String, String> requestParams = new LinkedHashMap<>();
+ requestParams.put("limit", Integer.toString(pageSize));
+ if (createdGte != null) {
+ requestParams.put("created[gte]", Long.toString(createdGte));
+ }
+ if (createdLt != null) {
+ requestParams.put("created[lt]", Long.toString(createdLt));
+ }
+ setParams(requestParams);
+
+ pluginConfig
+ .getOptional(HttpCommonOptions.RETRY)
+ .ifPresent(
+ retryCount -> {
+ setRetry(retryCount);
+ setRetryBackoffMultiplierMillis(
+ pluginConfig.get(
+ HttpCommonOptions.RETRY_BACKOFF_MULTIPLIER_MS));
+ setRetryBackoffMaxMillis(
+ pluginConfig.get(HttpCommonOptions.RETRY_BACKOFF_MAX_MS));
+ });
+ setConnectTimeoutMs(pluginConfig.get(HttpSourceOptions.CONNECT_TIMEOUT_MS));
+ setSocketTimeoutMs(pluginConfig.get(HttpSourceOptions.SOCKET_TIMEOUT_MS));
+ }
+
+ public int getRateLimitMaxRetries() {
+ return rateLimitMaxRetries;
+ }
+
+ public int getRateLimitBackoffMs() {
+ return rateLimitBackoffMs;
+ }
+
+ public void setStartingAfter(String cursor) {
+ if (cursor == null) {
+ getParams().remove("starting_after");
+ } else {
+ getParams().put("starting_after", cursor);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "StripeSourceParameter{url='" + getUrl() + "', params=" + getParams() + "}";
+ }
+
+ private static String trimTrailingSlash(String value) {
+ int end = value.length();
+ while (end > 0 && value.charAt(end - 1) == '/') {
+ end--;
+ }
+ return value.substring(0, end);
+ }
+}
diff --git a/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/test/java/org/apache/seatunnel/connectors/seatunnel/stripe/StripeSourceParameterTest.java b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/test/java/org/apache/seatunnel/connectors/seatunnel/stripe/StripeSourceParameterTest.java
new file mode 100644
index 0000000000..9c755f2083
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/test/java/org/apache/seatunnel/connectors/seatunnel/stripe/StripeSourceParameterTest.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.stripe;
+
+import org.apache.seatunnel.api.common.JobContext;
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Boundedness;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.type.BasicType;
+import org.apache.seatunnel.common.constants.JobMode;
+import org.apache.seatunnel.connectors.seatunnel.stripe.source.StripeSource;
+import org.apache.seatunnel.connectors.seatunnel.stripe.source.StripeSourceFactory;
+import org.apache.seatunnel.connectors.seatunnel.stripe.source.config.StripeSourceParameter;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+class StripeSourceParameterTest {
+
+ @Test
+ void buildsPaymentIntentsRequestWithoutExposingSecret() {
+ Map<String, Object> options = baseOptions();
+ options.put("api_base_url", "https://stripe.example/");
+ options.put("api_version", "2025-04-30.basil");
+ options.put("page_size", 25);
+ options.put("created_gte", 100L);
+ options.put("created_lt", 200L);
+
+ StripeSourceParameter parameter = new StripeSourceParameter();
+ parameter.buildWithConfig(ReadonlyConfig.fromMap(options));
+
+ Assertions.assertEquals("https://stripe.example/v1/payment_intents", parameter.getUrl());
+ Assertions.assertEquals("get", parameter.getMethod().getMethod());
+ Assertions.assertEquals(
+ "Bearer sk_test_secret", parameter.getHeaders().get("Authorization"));
+ Assertions.assertEquals("2025-04-30.basil", parameter.getHeaders().get("Stripe-Version"));
+ Assertions.assertEquals("25", parameter.getParams().get("limit"));
+ Assertions.assertEquals("100", parameter.getParams().get("created[gte]"));
+ Assertions.assertEquals("200", parameter.getParams().get("created[lt]"));
+ Assertions.assertFalse(parameter.toString().contains("sk_test_secret"));
+ }
+
+ @Test
+ void validatesPageSizeAndTimeRange() {
+ Map<String, Object> invalidPageSizeOptions = baseOptions();
+ invalidPageSizeOptions.put("page_size", 101);
+ IllegalArgumentException pageSizeError =
+ Assertions.assertThrows(
+ IllegalArgumentException.class,
+ () -> buildParameter(invalidPageSizeOptions));
+ Assertions.assertTrue(pageSizeError.getMessage().contains("page_size"));
+
+ Map<String, Object> invalidTimeRangeOptions = baseOptions();
+ invalidTimeRangeOptions.put("created_gte", 200L);
+ invalidTimeRangeOptions.put("created_lt", 200L);
+ IllegalArgumentException rangeError =
+ Assertions.assertThrows(
+ IllegalArgumentException.class,
+ () -> buildParameter(invalidTimeRangeOptions));
+ Assertions.assertTrue(rangeError.getMessage().contains("created_gte"));
+ }
+
+ @Test
+ void factoryDeclaresRequiredSecretKey() {
+ Assertions.assertNotNull(new StripeSourceFactory().optionRule());
+ Assertions.assertEquals("Stripe", new StripeSourceFactory().factoryIdentifier());
+ }
+
+ @Test
+ void exposesBoundedSingleColumnJsonContract() {
+ StripeSource source = new StripeSource(ReadonlyConfig.fromMap(baseOptions()));
+ source.setJobContext(new JobContext().setJobMode(JobMode.BATCH));
+
+ Assertions.assertEquals(Boundedness.BOUNDED, source.getBoundedness());
+ CatalogTable table = source.getProducedCatalogTables().get(0);
+ Assertions.assertArrayEquals(
+ new String[] {"content"}, table.getSeaTunnelRowType().getFieldNames());
+ Assertions.assertEquals(BasicType.STRING_TYPE, table.getSeaTunnelRowType().getFieldType(0));
+
+ source.setJobContext(new JobContext().setJobMode(JobMode.STREAMING));
+ Assertions.assertThrows(UnsupportedOperationException.class, source::getBoundedness);
+ }
+
+ private static StripeSourceParameter buildParameter(Map<String, Object> options) {
+ StripeSourceParameter parameter = new StripeSourceParameter();
+ parameter.buildWithConfig(ReadonlyConfig.fromMap(options));
+ return parameter;
+ }
+
+ private static Map<String, Object> baseOptions() {
+ Map<String, Object> options = new HashMap<>();
+ options.put("secret_key", "sk_test_secret");
+ return options;
+ }
+}
diff --git a/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/test/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSourceReaderTest.java b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/test/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSourceReaderTest.java
new file mode 100644
index 0000000000..1476c8c1d0
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-http/connector-http-stripe/src/test/java/org/apache/seatunnel/connectors/seatunnel/stripe/source/StripeSourceReaderTest.java
@@ -0,0 +1,332 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.stripe.source;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.source.Collector;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.source.SingleSplitReaderContext;
+import org.apache.seatunnel.connectors.seatunnel.http.exception.HttpConnectorException;
+import org.apache.seatunnel.connectors.seatunnel.stripe.source.config.StripeSourceParameter;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpServer;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+class StripeSourceReaderTest {
+
+ private HttpServer server;
+ private String baseUrl;
+
+ @BeforeEach
+ void setUp() throws IOException {
+ server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);
+ server.start();
+ baseUrl = "http://127.0.0.1:" + server.getAddress().getPort();
+ }
+
+ @AfterEach
+ void tearDown() {
+ if (server != null) {
+ server.stop(0);
+ }
+ }
+
+ @Test
+ void readsPaymentIntentsAcrossCursorPagesWithBoundedTimeRange() throws Exception {
+ List<Map<String, String>> requests = Collections.synchronizedList(new ArrayList<>());
+ List<String> authorizationHeaders = Collections.synchronizedList(new ArrayList<>());
+ server.createContext(
+ "/v1/payment_intents",
+ exchange -> {
+ requests.add(parseQuery(exchange.getRequestURI().getRawQuery()));
+ authorizationHeaders.add(
+ exchange.getRequestHeaders().getFirst("Authorization"));
+ String cursor = requests.get(requests.size() - 1).get("starting_after");
+ if (cursor == null) {
+ respondJson(
+ exchange,
+ 200,
+ "{\"data\":[{\"id\":\"pi_3\",\"amount\":300},{\"id\":\"pi_2\",\"amount\":200}],\"has_more\":true}");
+ } else {
+ respondJson(
+ exchange,
+ 200,
+ "{\"data\":[{\"id\":\"pi_1\",\"amount\":100}],\"has_more\":false}");
+ }
+ });
+
+ SingleSplitReaderContext context = mock(SingleSplitReaderContext.class);
+ RecordingCollector collector = new RecordingCollector();
+ try (StripeSourceReader reader = createReader(context, 2, 0)) {
+ reader.open();
+ reader.internalPollNext(collector);
+ }
+
+ Assertions.assertEquals(3, collector.rows.size());
+ Assertions.assertTrue(collector.rows.get(0).getField(0).toString().contains("\"pi_3\""));
+ Assertions.assertTrue(collector.rows.get(1).getField(0).toString().contains("\"pi_2\""));
+ Assertions.assertTrue(collector.rows.get(2).getField(0).toString().contains("\"pi_1\""));
+ Assertions.assertEquals("2", requests.get(0).get("limit"));
+ Assertions.assertEquals("100", requests.get(0).get("created[gte]"));
+ Assertions.assertEquals("200", requests.get(0).get("created[lt]"));
+ Assertions.assertNull(requests.get(0).get("starting_after"));
+ Assertions.assertEquals("pi_2", requests.get(1).get("starting_after"));
+ Assertions.assertEquals(
+ Arrays.asList("Bearer sk_test_secret", "Bearer sk_test_secret"),
+ authorizationHeaders);
+ verify(context, times(1)).signalNoMoreElement();
+ }
+
+ @Test
+ void acceptsEmptyFinalPage() throws Exception {
+ AtomicInteger requests = new AtomicInteger();
+ server.createContext(
+ "/v1/payment_intents",
+ exchange -> {
+ requests.incrementAndGet();
+ respondJson(exchange, 200, "{\"data\":[],\"has_more\":false}");
+ });
+
+ RecordingCollector collector = new RecordingCollector();
+ try (StripeSourceReader reader =
+ createReader(mock(SingleSplitReaderContext.class), 100, 0)) {
+ reader.open();
+ reader.internalPollNext(collector);
+ }
+
+ Assertions.assertTrue(collector.rows.isEmpty());
+ Assertions.assertEquals(1, requests.get());
+ }
+
+ @Test
+ void retriesRateLimitThenContinues() throws Exception {
+ AtomicInteger requests = new AtomicInteger();
+ server.createContext(
+ "/v1/payment_intents",
+ exchange -> {
+ if (requests.incrementAndGet() == 1) {
+ respondJson(exchange, 429, "{\"error\":{\"message\":\"rate limited\"}}");
+ } else {
+ respondJson(
+ exchange, 200, "{\"data\":[{\"id\":\"pi_1\"}],\"has_more\":false}");
+ }
+ });
+
+ RecordingCollector collector = new RecordingCollector();
+ try (StripeSourceReader reader =
+ createReader(mock(SingleSplitReaderContext.class), 100, 1)) {
+ reader.open();
+ reader.internalPollNext(collector);
+ }
+
+ Assertions.assertEquals(2, requests.get());
+ Assertions.assertEquals(1, collector.rows.size());
+ }
+
+ @Test
+ void reportsRateLimitAfterRetryBudgetIsExhausted() throws Exception {
+ AtomicInteger requests = new AtomicInteger();
+ server.createContext(
+ "/v1/payment_intents",
+ exchange -> {
+ requests.incrementAndGet();
+ respondJson(exchange, 429, "{\"error\":{\"message\":\"rate limited\"}}");
+ });
+
+ try (StripeSourceReader reader =
+ createReader(mock(SingleSplitReaderContext.class), 100, 1)) {
+ reader.open();
+ HttpConnectorException error =
+ Assertions.assertThrows(
+ HttpConnectorException.class,
+ () -> reader.internalPollNext(new RecordingCollector()));
+ Assertions.assertTrue(error.getMessage().contains("HTTP 429"));
+ }
+ Assertions.assertEquals(2, requests.get());
+ }
+
+ @Test
+ void reportsApiErrorWithoutLeakingSecret() throws Exception {
+ server.createContext(
+ "/v1/payment_intents",
+ exchange ->
+ respondJson(
+ exchange,
+ 401,
+ "{\"error\":{\"message\":\"invalid api key sk_test_secret\"}}"));
+
+ try (StripeSourceReader reader =
+ createReader(mock(SingleSplitReaderContext.class), 100, 0)) {
+ reader.open();
+ HttpConnectorException error =
+ Assertions.assertThrows(
+ HttpConnectorException.class,
+ () -> reader.internalPollNext(new RecordingCollector()));
+ Assertions.assertTrue(error.getMessage().contains("HTTP 401"));
+ Assertions.assertFalse(error.getMessage().contains("sk_test_secret"));
+ Assertions.assertTrue(error.getMessage().contains("[REDACTED]"));
+ }
+ }
+
+ @Test
+ void rejectsRepeatedCursorBeforeCollectingDuplicatePage() throws Exception {
+ AtomicInteger requests = new AtomicInteger();
+ server.createContext(
+ "/v1/payment_intents",
+ exchange -> {
+ requests.incrementAndGet();
+ respondJson(exchange, 200, "{\"data\":[{\"id\":\"pi_1\"}],\"has_more\":true}");
+ });
+
+ RecordingCollector collector = new RecordingCollector();
+ try (StripeSourceReader reader =
+ createReader(mock(SingleSplitReaderContext.class), 100, 0)) {
+ reader.open();
+ HttpConnectorException error =
+ Assertions.assertThrows(
+ HttpConnectorException.class, () -> reader.internalPollNext(collector));
+ Assertions.assertTrue(error.getMessage().contains("repeated cursor"));
+ }
+ Assertions.assertEquals(2, requests.get());
+ Assertions.assertEquals(1, collector.rows.size());
+ }
+
+ @Test
+ void rejectsCursorCycleBeforeCollectingRepeatedPage() throws Exception {
+ AtomicInteger requests = new AtomicInteger();
+ server.createContext(
+ "/v1/payment_intents",
+ exchange -> {
+ int request = requests.incrementAndGet();
+ String id = request == 2 ? "pi_2" : "pi_1";
+ respondJson(
+ exchange,
+ 200,
+ "{\"data\":[{\"id\":\"" + id + "\"}],\"has_more\":true}");
+ });
+
+ RecordingCollector collector = new RecordingCollector();
+ try (StripeSourceReader reader =
+ createReader(mock(SingleSplitReaderContext.class), 100, 0)) {
+ reader.open();
+ HttpConnectorException error =
+ Assertions.assertThrows(
+ HttpConnectorException.class, () -> reader.internalPollNext(collector));
+ Assertions.assertTrue(error.getMessage().contains("repeated cursor"));
+ }
+ Assertions.assertEquals(3, requests.get());
+ Assertions.assertEquals(2, collector.rows.size());
+ }
+
+ @Test
+ void rejectsHasMoreWithEmptyPage() throws Exception {
+ server.createContext(
+ "/v1/payment_intents",
+ exchange -> respondJson(exchange, 200, "{\"data\":[],\"has_more\":true}"));
+
+ try (StripeSourceReader reader =
+ createReader(mock(SingleSplitReaderContext.class), 100, 0)) {
+ reader.open();
+ HttpConnectorException error =
+ Assertions.assertThrows(
+ HttpConnectorException.class,
+ () -> reader.internalPollNext(new RecordingCollector()));
+ Assertions.assertTrue(error.getMessage().contains("has_more=true"));
+ }
+ }
+
+ private StripeSourceReader createReader(
+ SingleSplitReaderContext context, int pageSize, int maxRateLimitRetries) {
+ Map<String, Object> options = new HashMap<>();
+ options.put("secret_key", "sk_test_secret");
+ options.put("api_base_url", baseUrl);
+ options.put("page_size", pageSize);
+ options.put("created_gte", 100L);
+ options.put("created_lt", 200L);
+ options.put("rate_limit_max_retries", maxRateLimitRetries);
+ options.put("rate_limit_backoff_ms", 0);
+ StripeSourceParameter parameter = new StripeSourceParameter();
+ parameter.buildWithConfig(ReadonlyConfig.fromMap(options));
+ return new StripeSourceReader(parameter, context, millis -> {});
+ }
+
+ private static Map<String, String> parseQuery(String rawQuery) throws IOException {
+ Map<String, String> query = new LinkedHashMap<>();
+ if (rawQuery == null || rawQuery.isEmpty()) {
+ return query;
+ }
+ for (String part : rawQuery.split("&")) {
+ String[] entry = part.split("=", 2);
+ String key = URLDecoder.decode(entry[0], StandardCharsets.UTF_8.name());
+ String value =
+ entry.length == 1
+ ? ""
+ : URLDecoder.decode(entry[1], StandardCharsets.UTF_8.name());
+ query.put(key, value);
+ }
+ return query;
+ }
+
+ private static void respondJson(HttpExchange exchange, int statusCode, String body)
+ throws IOException {
+ byte[] response = body.getBytes(StandardCharsets.UTF_8);
+ exchange.getResponseHeaders().set("Content-Type", "application/json");
+ exchange.sendResponseHeaders(statusCode, response.length);
+ try (OutputStream output = exchange.getResponseBody()) {
+ output.write(response);
+ }
+ }
+
+ private static final class RecordingCollector implements Collector<SeaTunnelRow> {
+ private final List<SeaTunnelRow> rows = new ArrayList<>();
+ private final Object checkpointLock = new Object();
+
+ @Override
+ public void collect(SeaTunnelRow record) {
+ rows.add(record);
+ }
+
+ @Override
+ public Object getCheckpointLock() {
+ return checkpointLock;
+ }
+ }
+}
diff --git a/seatunnel-connectors-v2/connector-http/pom.xml b/seatunnel-connectors-v2/connector-http/pom.xml
index 7584cef02b..7061a5d53b 100644
--- a/seatunnel-connectors-v2/connector-http/pom.xml
+++ b/seatunnel-connectors-v2/connector-http/pom.xml
@@ -45,6 +45,7 @@
<module>connector-http-airtable</module>
<module>connector-http-posthog</module>
<module>connector-http-zendesk</module>
+ <module>connector-http-stripe</module>
</modules>
</project>
diff --git a/seatunnel-dist/pom.xml b/seatunnel-dist/pom.xml
index aad8d7acc3..2f126d25bf 100644
--- a/seatunnel-dist/pom.xml
+++ b/seatunnel-dist/pom.xml
@@ -302,6 +302,12 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.seatunnel</groupId>
+ <artifactId>connector-http-stripe</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.seatunnel</groupId>
<artifactId>connector-http-onesignal</artifactId>
diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/pom.xml b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/pom.xml
index acea0393d3..c68e9a14e4 100644
--- a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/pom.xml
+++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/pom.xml
@@ -129,6 +129,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.seatunnel</groupId>
+ <artifactId>connector-http-stripe</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty-no-dependencies</artifactId>
diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/StripeIT.java b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/StripeIT.java
new file mode 100644
index 0000000000..60a443bb9c
--- /dev/null
+++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/StripeIT.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.http;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.DockerLoggerFactory;
+
+import java.util.stream.Stream;
+
+class StripeIT extends TestSuiteBase implements TestResource {
+
+ private static final String IMAGE = "stripe/stripe-mock:v0.202.0";
+ private static final int HTTP_PORT = 12111;
+
+ private GenericContainer<?> stripeMock;
+
+ @BeforeAll
+ @Override
+ public void startUp() {
+ DockerImageName image = DockerImageName.parse(IMAGE);
+ stripeMock =
+ new GenericContainer<>(image)
+ .withNetwork(NETWORK)
+ .withNetworkAliases("stripe-mock")
+ .withExposedPorts(HTTP_PORT)
+ .withLogConsumer(
+ new Slf4jLogConsumer(
+ DockerLoggerFactory.getLogger(
+ image.asCanonicalNameString())))
+ .waitingFor(
+ Wait.forHttp("/v1/payment_intents")
+ .forPort(HTTP_PORT)
+ .withHeader("Authorization", "Bearer sk_test_123")
+ .forStatusCode(200));
+ Startables.deepStart(Stream.of(stripeMock)).join();
+ }
+
+ @AfterAll
+ @Override
+ public void tearDown() {
+ if (stripeMock != null) {
+ stripeMock.close();
+ }
+ }
+
+ @TestTemplate
+ void testPaymentIntentsSource(TestContainer container) throws Exception {
+ Container.ExecResult result =
+ container.executeJob("/stripe_payment_intents_to_assert.conf");
+
+ Assertions.assertEquals(0, result.getExitCode(), result.getStderr());
+ }
+}
diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/stripe_payment_intents_to_assert.conf b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/stripe_payment_intents_to_assert.conf
new file mode 100644
index 0000000000..1f39cd9518
--- /dev/null
+++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/stripe_payment_intents_to_assert.conf
@@ -0,0 +1,59 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+env {
+ parallelism = 1
+ job.mode = "BATCH"
+}
+
+source {
+ Stripe {
+ plugin_output = "stripe"
+ secret_key = "sk_test_123"
+ api_base_url = "http://stripe-mock:12111"
+ page_size = 10
+ }
+}
+
+sink {
+ Assert {
+ plugin_input = "stripe"
+ rules {
+ row_rules = [
+ {
+ rule_type = MIN_ROW
+ rule_value = 1
+ },
+ {
+ rule_type = MAX_ROW
+ rule_value = 1
+ }
+ ]
+ field_rules = [
+ {
+ field_name = content
+ field_type = string
+ field_value = [
+ {
+ rule_type = NOT_NULL
+ }
+ ]
+ }
+ ]
+ }
+ }
+}