-
Notifications
You must be signed in to change notification settings - Fork 907
StripePaymentProcessor — Secure Backend Integration for Stripe Payments and Subscriptions in ServiceNow #2377
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
Server-Side Components/Script Includes/Stripe Payment/Readme.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # ⚙️ StripePaymentProcessor Script Include | ||
|
|
||
| ### Overview | ||
|
|
||
| The **StripePaymentProcessor** Script Include provides a complete backend integration between **ServiceNow** and **Stripe**, supporting both **one-time payments** and **subscriptions**. | ||
|
|
||
| It’s designed to work seamlessly with the **Stripe Payment Widget** — together forming a full ServiceNow–Stripe payment ecosystem. | ||
|
|
||
| --- | ||
|
|
||
| ### 🧩 Features | ||
|
|
||
| - 💳 Create and confirm **Stripe PaymentIntents** | ||
| - 🔁 Create and manage **Stripe Subscriptions** | ||
| - 🧠 Auto-link **PaymentMethods** with customers | ||
| - 💬 Update `u_transaction_history` and webhook logs automatically | ||
| - 🔒 Securely interacts with the Stripe API via REST | ||
| - 🌐 Fully dynamic REST message creation — no need for integrations in UI | ||
|
|
||
| --- | ||
|
|
||
| ### 📁 Folder Structure | ||
|
|
||
| | File | Purpose | | ||
| | ---------------------------------- | ------------------------------------------------------- | | ||
| | `Script.js` | Full Script Include XML definition | | ||
| | (Optional) `Stripe_Payment_Widget` | UI widget that calls this backend for creating payments | | ||
|
|
||
| --- | ||
|
|
||
| ### ⚙️ Installation Steps | ||
|
|
||
| 1. Import the Script Include XML: | ||
| Navigate to **System Update Sets → Retrieved Update Sets → Import** | ||
| and upload `sys_script_include_0a4e750983796e10cf0977447daad3a1.xml`. | ||
|
|
||
| 2. Create or update a **System Property**: | ||
|
|
||
| - Name: `stripe_payment_key` | ||
| - Value: your Stripe **secret key** (`sk_live_...` or `sk_test_...`) | ||
|
|
||
| 3. (Optional) Install the **Stripe Payment Widget** from your companion repo or PR. | ||
|
|
||
| 4. Link the widget to this processor by calling: | ||
| ```js | ||
| var processor = new global.StripePaymentProcessor(); | ||
| var result = processor.createPaymentIntent({ | ||
| payment_method_id: "pm_123", | ||
| amount: 2500, | ||
| currency: "usd", | ||
| metadata: { description: "Test Payment" }, | ||
| }); | ||
| ``` | ||
|
|
||
| ### 🔗 Integration Path | ||
|
|
||
| For a working demo, navigate to: | ||
| Service Portal Page: /sp?id=stripe_payment_checkout | ||
| → This page contains the Stripe Payment Widget | ||
| → On submit, it triggers the StripePaymentProcessor backend call. | ||
|
|
||
| 🧠 Example Usage (Client → Server) | ||
|
|
||
| In your widget’s Server Script: | ||
|
|
||
| ``` | ||
| (function() { | ||
| var processor = new global.StripePaymentProcessor(); | ||
| data.result = processor.createPaymentIntent(input); | ||
| })(); | ||
|
|
||
| ``` | ||
|
|
||
| In Client Script (Angular Controller): | ||
|
|
||
| ``` | ||
| c.server.get({ payment_method_id: pm.id, amount: 1999 }) | ||
| .then(function(response) { | ||
| console.log('Payment Intent:', response.data.result); | ||
| }); | ||
|
|
||
| ``` | ||
|
|
||
| ### 🧰 Technical Details | ||
|
|
||
| Script Type: Script Include | ||
|
|
||
| API: global.StripePaymentProcessor | ||
|
|
||
| Scope: Global | ||
|
|
||
| Callable from: Server-side only (not client callable) | ||
|
|
||
| Dependencies: sn_ws.RESTMessageV2, u_transaction_history, Stripe Secret Key | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There's a significant amount of AI used here. How much original work is in this script?