Skip to content

Stripe

Stripe is a comprehensive financial infrastructure platform that enables businesses to accept payments, manage revenue operations, and facilitate global commerce through a suite of integrated APIs and services.

By integrating Braze and Stripe, you can:

  • Update user profiles in Braze with real-time payment and billing data from Stripe.
  • Trigger messaging in Braze based on Stripe events such as trial started, subscription activated, subscription cancellation, and more.
  • Personalize Braze messaging based on a user’s payment history or billing status received using Stripe webhooks.

Prerequisites

Integration

Step 1: Set up the Braze Data Transformation to accept Stripe’s webhooks

Braze 대시보드에서 데이터 설정 > 데이터 변환로 이동합니다.

변환 이름을 지정하려면 Create Transformation을 선택한 다음 편집 경험을 선택하세요.

편집 경험을 위해 "템플릿 사용" 또는 "처음부터 시작" 옵션을 선택할 수 있는 변환 세부정보입니다.

템플릿 사용을 선택하여 데이터 변환 사용 사례를 포함한 템플릿 라이브러리를 탐색합니다. 또는 시작하기를 선택하여 기본값 코드 템플릿을 로드합니다.

아무것도 없는 상태에서 시작한다면, 변화를 위한 대상을 선택하세요. 템플릿 라이브러리에서 코드 템플릿을 여전히 삽입할 수 있습니다.

목적지에 대한 더 많은 정보
  • 게시: 사용자 추적: 소스 플랫폼의 웹훅을 고객 프로필 업데이트로 변환합니다. 예를 들어 속성, 이벤트 또는 구매와 같은 것입니다.
  • 넣기: 여러 카탈로그 항목 업데이트: 소스 플랫폼의 웹후크를 카탈로그 항목 업데이트로 변환합니다.
  • 삭제: 여러 카탈로그 항목 삭제: 소스 플랫폼의 웹후크를 카탈로그 항목 삭제로 변환합니다.
  • 패치: 여러 카탈로그 항목 편집: 소스 플랫폼의 웹후크를 카탈로그 항목 편집으로 변환합니다.
  • 게시: API만을 통해 즉시 메시지를 전송하세요. 소스 플랫폼에서 웹후크를 변환하여 지정된 사용자에게 즉시 메시지를 전송합니다.

변환을 생성한 후 변환의 세부 정보를 볼 수 있습니다. 여기에서 웹훅 세부정보 아래에서 이 변환을 위해 수신된 가장 최근의 웹훅을 볼 수 있으며, 변환 코드 아래에 변환 코드를 작성할 수 있는 공간이 있습니다.

다음 단계에서 사용할 웹훅 URL을(를) 캡처하세요.

Step 2: Set up Stripe webhooks

Follow the steps in Stripe’s webhooks documentation to set up a webhook.

Add your Data Transformation webhook URL as the Destination URL and select the event types you’d like to send to Braze. Refer to Stripe’s documentation for a full list of event types.

An example Stripe webhook configuration.

Then, send a test event to your Data Transformation.

Step 3: Write transformation code to accept your chosen Stripe events

Next, you’ll transform the webhook payload that will be sent from Stripe to a JavaScript object return value.

  1. Refresh your Data Transformation and make sure you can see the Stripe test payload in the Webhook details section.
  2. Update your Data Transformation code to support your chosen Stripe events.
  3. Select Validate to return a preview of your code’s output and to check if it’s an acceptable /users/track request.
  4. Save and activate your Data Transformation.

An example of webhook details and transformation code.

Request body format

This return value must adhere to the /users/track endpoint request body format:

  • Transformation code is accepted in the JavaScript programming language. Any standard JavaScript control flow, such as if/else logic, is supported.
  • Transformation code accesses the webhook request body using the payload variable. This variable is an object populated by parsing the request body JSON.
  • Any feature supported in our /users/track endpoint is supported, including:
    • User attribute objects, event objects, and purchase objects
    • Nested attributes and nested custom event properties
    • Subscription group updates
    • Email address as an identifier

Step 4: Publish your Stripe webhook

After writing your Data Transformation, select Validate to make your Data Transformation code is formatted correctly and will work as expected. Then, save and activate your Data Transformation. After activating, custom event data will be logged to a user’s profile when they complete the event.

A Stripe custom event "Charge Succeeded" in a Braze user profile.

Example Stripe webhook payload

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{
 "headers": {
   "Version": "HTTP/1.1",
   "X-Datadog-Trace-Id": "9124157397962821303",
   "X-Datadog-Parent-Id": "9124157397962821303",
   "X-Datadog-Sampling-Priority": "2",
   "Host": "xxx",
   "X-Request-Id": "xxx",
   "X-Real-Ip": "165.159.72.690",
   "X-Forwarded-For": "161.123.56.890",
   "X-Forwarded-Host": "xxx",
   "X-Forwarded-Port": "443",
   "X-Forwarded-Proto": "https",
   "X-Forwarded-Scheme": "https",
   "X-Scheme": "https",
   "X-Original-Forwarded-For": "12.345.678.123",
   "Cf-Ray": "9470a06172f8816e-IAD",
   "Cache-Control": "no-cache",
   "User-Agent": "Stripe/1.0 (+https://stripe.com/docs/webhooks)",
   "Accept-Encoding": "gzip",
   "Cf-Connecting-Ip": "12.123.456.789",
   "Cf-Visitor": "{\"scheme\":\"https\"}",
   "X-Worker-Executions": "1",
   "Cf-Worker": "xxx",
   "X-Fastly-Geoloc-Countrycode": "US",
   "Stripe-Signature": "t=xxx,v1=xxxx,v0=xxxx",
   "Cf-Ew-Via": "15",
   "Cdn-Loop": "cloudflare; loops=1; subreqs=1",
   "Accept": "*/*; q=0.5, application/xml"
 },
 "payload": {
   "id": "evt_3RTqw0RMEOaIvYpU1k2TFajH",
   "object": "event",
   "api_version": "2025-04-30.basil",
   "created": 1748465448,
   "data": {
     "object": {
       "id": "ch_3RTqw0RMEOaIvYpU1M9ZYtjP",
       "object": "charge",
       "amount": 100,
       "amount_captured": 100,
       "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": null,
           "state": null
         },
         "email": null,
         "name": null,
         "phone": null,
         "tax_id": null
       },
       "calculated_statement_descriptor": "Stripe",
       "captured": true,
       "created": 1748465448,
       "currency": "usd",
       "customer": "cus_SOeDf39aosGb97",
       "description": "(created by Stripe CLI)",
       "destination": null,
       "dispute": null,
       "disputed": false,
       "failure_balance_transaction": null,
       "failure_code": null,
       "failure_message": null,
       "fraud_details": {},
       "livemode": false,
       "metadata": {},
       "on_behalf_of": null,
       "order": null,
       "outcome": {
         "advice_code": null,
         "network_advice_code": null,
         "network_decline_code": null,
         "network_status": "approved_by_network",
         "reason": null,
         "risk_level": "normal",
         "risk_score": 9,
         "seller_message": "Payment complete.",
         "type": "authorized"
       },
       "paid": true,
       "payment_intent": "pi_3RTqw0RMEOaIvYpU1pQl3Lmp",
       "payment_method": "pm_1RTqw0RMEOaIvYpU5VE8HFlp",
       "payment_method_details": {
         "card": {
           "amount_authorized": 100,
           "authorization_code": null,
           "brand": "visa",
           "checks": {
             "address_line1_check": null,
             "address_postal_code_check": null,
             "cvc_check": "pass"
           },
           "country": "US",
           "exp_month": 5,
           "exp_year": 2026,
           "extended_authorization": {
             "status": "disabled"
           },
           "fingerprint": "HAKdyqJ9xh2YhbzT",
           "funding": "credit",
           "incremental_authorization": {
             "status": "unavailable"
           },
           "installments": null,
           "last4": "4242",
           "mandate": null,
           "multicapture": {
             "status": "unavailable"
           },
           "network": "visa",
           "network_token": {
             "used": false
           },
           "network_transaction_id": "726575100121113",
           "overcapture": {
             "maximum_amount_capturable": 100,
             "status": "unavailable"
           },
           "regulated_status": "unregulated",
           "three_d_secure": null,
           "wallet": null
         },
         "type": "card"
       },
       "radar_options": {},
       "receipt_email": null,
       "receipt_number": null,
       "receipt_url": "https://pay.stripe.com/receipts/payment/xxx",
       "refunded": false,
       "review": null,
       "shipping": null,
       "source": null,
       "source_transfer": null,
       "statement_descriptor": null,
       "statement_descriptor_suffix": null,
       "status": "succeeded",
       "transfer_data": null,
       "transfer_group": null
     }
   },
   "livemode": false,
   "pending_webhooks": 3,
   "request": {
     "id": "req_jqtL1Q6CPaNx8x",
     "idempotency_key": "f0f9aee4-a889-4fcc-bc2e-fa41fa426f05"
   },
   "type": "charge.succeeded"
 }
}

Data Transformation use cases

The following are example templates built using our example Stripe webhook payload. These templates can be used as a starting point. You can start from scratch or delete specific components as you see fit.

In this example template, we’re logging a custom event to the Braze profile. The event type will be sent as the custom event name, and the data object will be passed as event properties.

Use case: customer as an identifier

In this example template, we are using the customer field as the identifier.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* This template is based on the source platform's documentation here: https://stripe.com/docs/webhooks


/* Braze's /users/track endpoint expects timestamps in an ISO 8601 format. To use the Unix timestamp within Stripe's charge succeeded event payload as the event timestamp in Braze must first be converted to ISO 8601. This can be done with the following code:
let unixTimestamp = payload.data.object.created;
let dateObj = new Date(unixTimestamp * 1000);
let isoString = dateObj.toISOString();


/* defines a variable 'brazecall' that will hold the request payload for the /users/track request
let brazecall;


/* if the type is charge.succeeded and customer field is not null, build the /users/track request to log an event to the user profile
if (payload.type == "charge.succeeded" && payload.data.object.customer) {
 brazecall = {
   "events": [
     {
       "external_id": payload.data.object.customer,
       "name": "Charge Succeeded",
       "time": isoString,
       "properties": {
         "amount": payload.data.object.amount,
         "paid": payload.data.object.paid,
         "status": payload.data.object.status
       }
     }
   ]
 };
}
/* After the /users/track request is assigned to brazecall, you will want to explicitly return brazecall to create an output
return brazecall;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "events": [
    {
      "external_id": "[email protected]",
      "name": "Charge Succeeded",
      "time": "2025-05-28T18:21:39.527Z",
      "properties": {
        "amount": 100,
    "paid":true,
    "Status":"succeeded"
    }
   }
  ]
}

Monitoring and troubleshooting

Refer to Monitoring your transformation for more information on monitoring and troubleshooting your transformation.

이 페이지가 얼마나 도움이 되었나요?
New Stuff!