Skip to content

Commit e30efab

Browse files
committed
Script
1 parent f670d24 commit e30efab

File tree

2 files changed

+1239
-0
lines changed

2 files changed

+1239
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# ⚙️ StripePaymentProcessor Script Include
2+
3+
### Overview
4+
5+
The **StripePaymentProcessor** Script Include provides a complete backend integration between **ServiceNow** and **Stripe**, supporting both **one-time payments** and **subscriptions**.
6+
7+
It’s designed to work seamlessly with the **Stripe Payment Widget** — together forming a full ServiceNow–Stripe payment ecosystem.
8+
9+
---
10+
11+
### 🧩 Features
12+
13+
- 💳 Create and confirm **Stripe PaymentIntents**
14+
- 🔁 Create and manage **Stripe Subscriptions**
15+
- 🧠 Auto-link **PaymentMethods** with customers
16+
- 💬 Update `u_transaction_history` and webhook logs automatically
17+
- 🔒 Securely interacts with the Stripe API via REST
18+
- 🌐 Fully dynamic REST message creation — no need for integrations in UI
19+
20+
---
21+
22+
### 📁 Folder Structure
23+
24+
| File | Purpose |
25+
| ---------------------------------- | ------------------------------------------------------- |
26+
| `Script.js` | Full Script Include XML definition |
27+
| (Optional) `Stripe_Payment_Widget` | UI widget that calls this backend for creating payments |
28+
29+
---
30+
31+
### ⚙️ Installation Steps
32+
33+
1. Import the Script Include XML:
34+
Navigate to **System Update Sets → Retrieved Update Sets → Import**
35+
and upload `sys_script_include_0a4e750983796e10cf0977447daad3a1.xml`.
36+
37+
2. Create or update a **System Property**:
38+
39+
- Name: `stripe_payment_key`
40+
- Value: your Stripe **secret key** (`sk_live_...` or `sk_test_...`)
41+
42+
3. (Optional) Install the **Stripe Payment Widget** from your companion repo or PR.
43+
44+
4. Link the widget to this processor by calling:
45+
```js
46+
var processor = new global.StripePaymentProcessor();
47+
var result = processor.createPaymentIntent({
48+
payment_method_id: "pm_123",
49+
amount: 2500,
50+
currency: "usd",
51+
metadata: { description: "Test Payment" },
52+
});
53+
```
54+
55+
### 🔗 Integration Path
56+
57+
For a working demo, navigate to:
58+
Service Portal Page: /sp?id=stripe_payment_checkout
59+
→ This page contains the Stripe Payment Widget
60+
→ On submit, it triggers the StripePaymentProcessor backend call.
61+
62+
🧠 Example Usage (Client → Server)
63+
64+
In your widget’s Server Script:
65+
66+
```
67+
(function() {
68+
var processor = new global.StripePaymentProcessor();
69+
data.result = processor.createPaymentIntent(input);
70+
})();
71+
72+
```
73+
74+
In Client Script (Angular Controller):
75+
76+
```
77+
c.server.get({ payment_method_id: pm.id, amount: 1999 })
78+
.then(function(response) {
79+
console.log('Payment Intent:', response.data.result);
80+
});
81+
82+
```
83+
84+
### 🧰 Technical Details
85+
86+
Script Type: Script Include
87+
88+
API: global.StripePaymentProcessor
89+
90+
Scope: Global
91+
92+
Callable from: Server-side only (not client callable)
93+
94+
Dependencies: sn_ws.RESTMessageV2, u_transaction_history, Stripe Secret Key

0 commit comments

Comments
 (0)