node-behind-api-client 2.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +20 -0
- package/README.md +65 -0
- package/docs/behind-api-client/easyjob/JobDescriptions/README.md +654 -0
- package/docs/behind-api-client/easyjob/README.md +647 -0
- package/docs/behind-api-client/easyjob/applicants/README.md +494 -0
- package/docs/behind-api-client/easyjob/applications/README.md +754 -0
- package/docs/behind-api-client/easyjob/candidateProfiles/README.md +940 -0
- package/docs/behind-api-client/easyjob/jd-candidate-questions/README.md +372 -0
- package/docs/behind-api-client/payments/payture/README.21.md +901 -0
- package/docs/behind-api-client/payments/payture/README.cards.md +1497 -0
- package/docs/behind-api-client/payments/payture/README.md +1497 -0
- package/docs/behind-api-client/payments/payture/README.rukitchen.md +396 -0
- package/docs/behind-api-client/payments/payture/README.subscriptions.md +1266 -0
- package/docs/behind-api-client/payments/stripe/README.flow.md +254 -0
- package/docs/behind-api-client/rag/storage/README.md +519 -0
- package/example.js +35 -0
- package/index.cjs +14 -0
- package/index.js +15 -0
- package/lib/behind-api-auth-client/BehindApiAuthClient.js +91 -0
- package/lib/behind-api-auth-client/authorisation/AuthorisationApp.js +9 -0
- package/lib/behind-api-auth-client/authorisation/AuthorisationV10.js +9 -0
- package/lib/behind-api-auth-client/authorisation/AuthorisationV10Code.js +30 -0
- package/lib/behind-api-auth-client/example.js +47 -0
- package/lib/behind-api-auth-client/package.json +9 -0
- package/lib/behind-api-client/BehindApiClient.js +137 -0
- package/lib/behind-api-client/chat/ChatApp.js +11 -0
- package/lib/behind-api-client/chat/ChatV10.js +13 -0
- package/lib/behind-api-client/chat/ChatV10Chat.js +87 -0
- package/lib/behind-api-client/chat/ChatV10Chats.js +14 -0
- package/lib/behind-api-client/chat/ChatV10Message.js +57 -0
- package/lib/behind-api-client/chat/ChatV20.js +11 -0
- package/lib/behind-api-client/chat/ChatV20Chat.js +14 -0
- package/lib/behind-api-client/chat/ChatV20Message.js +27 -0
- package/lib/behind-api-client/easyjob/EasyjobApp.js +9 -0
- package/lib/behind-api-client/easyjob/EasyjobV10.js +31 -0
- package/lib/behind-api-client/easyjob/EasyjobV10Answers.js +16 -0
- package/lib/behind-api-client/easyjob/EasyjobV10Applicants.js +29 -0
- package/lib/behind-api-client/easyjob/EasyjobV10Applications.js +39 -0
- package/lib/behind-api-client/easyjob/EasyjobV10CandidateProfileArtifacts.js +31 -0
- package/lib/behind-api-client/easyjob/EasyjobV10CandidateProfiles.js +99 -0
- package/lib/behind-api-client/easyjob/EasyjobV10Companies.js +36 -0
- package/lib/behind-api-client/easyjob/EasyjobV10Cv.js +15 -0
- package/lib/behind-api-client/easyjob/EasyjobV10Departments.js +37 -0
- package/lib/behind-api-client/easyjob/EasyjobV10JobDescriptionArtifacts.js +29 -0
- package/lib/behind-api-client/easyjob/EasyjobV10JobDescriptionCandidateQuestions.js +63 -0
- package/lib/behind-api-client/easyjob/EasyjobV10JobDescriptions.js +93 -0
- package/lib/behind-api-client/easyjob/EasyjobV10Reports.js +35 -0
- package/lib/behind-api-client/example.js +47 -0
- package/lib/behind-api-client/global/GlobalApp.js +9 -0
- package/lib/behind-api-client/global/GlobalV10.js +11 -0
- package/lib/behind-api-client/global/GlobalV10Sockets.js +16 -0
- package/lib/behind-api-client/global/GlobalV10Storage.js +29 -0
- package/lib/behind-api-client/gpt/GptApp.js +15 -0
- package/lib/behind-api-client/gpt/GptV10.js +15 -0
- package/lib/behind-api-client/gpt/GptV10Prompt.js +17 -0
- package/lib/behind-api-client/gpt/GptV10Request.js +16 -0
- package/lib/behind-api-client/gpt/GptV10Storedprompts.js +14 -0
- package/lib/behind-api-client/gpt/GptV10Whisper.js +23 -0
- package/lib/behind-api-client/gpt/GptV20.js +9 -0
- package/lib/behind-api-client/gpt/GptV20Prompt.js +15 -0
- package/lib/behind-api-client/gpt/GptV30.js +13 -0
- package/lib/behind-api-client/gpt/GptV30Chat.js +19 -0
- package/lib/behind-api-client/gpt/GptV30Prompt.js +41 -0
- package/lib/behind-api-client/gpt/GptV30Prompts.js +32 -0
- package/lib/behind-api-client/gpt/GptV40.js +11 -0
- package/lib/behind-api-client/gpt/GptV40Prompt.js +24 -0
- package/lib/behind-api-client/gpt/GptV40Prompts.js +30 -0
- package/lib/behind-api-client/mailer/MailerApp.js +11 -0
- package/lib/behind-api-client/mailer/MailerV10.js +15 -0
- package/lib/behind-api-client/mailer/MailerV10Bulk.js +21 -0
- package/lib/behind-api-client/mailer/MailerV10Message.js +83 -0
- package/lib/behind-api-client/mailer/MailerV10Settings.js +44 -0
- package/lib/behind-api-client/mailer/MailerV10Template.js +23 -0
- package/lib/behind-api-client/mailer/MailerV20.js +9 -0
- package/lib/behind-api-client/mailer/MailerV20Message.js +21 -0
- package/lib/behind-api-client/mastogram/MastogramApp.js +9 -0
- package/lib/behind-api-client/mastogram/MastogramV10.js +13 -0
- package/lib/behind-api-client/mastogram/MastogramV10Bluesky.js +42 -0
- package/lib/behind-api-client/mastogram/MastogramV10Mastodon.js +45 -0
- package/lib/behind-api-client/mastogram/MastogramV10Telegram.js +39 -0
- package/lib/behind-api-client/monitor/MonitorApp.js +9 -0
- package/lib/behind-api-client/monitor/MonitorV10.js +13 -0
- package/lib/behind-api-client/monitor/MonitorV10Finances.js +39 -0
- package/lib/behind-api-client/monitor/MonitorV10Record.js +15 -0
- package/lib/behind-api-client/monitor/MonitorV10Records.js +22 -0
- package/lib/behind-api-client/oauth/OauthApp.js +9 -0
- package/lib/behind-api-client/oauth/OauthV10.js +9 -0
- package/lib/behind-api-client/oauth/OauthV10Authorisation.js +15 -0
- package/lib/behind-api-client/package.json +9 -0
- package/lib/behind-api-client/payments/PaymentsApp.js +13 -0
- package/lib/behind-api-client/payments/PaymentsV10.js +15 -0
- package/lib/behind-api-client/payments/PaymentsV10Gift.js +32 -0
- package/lib/behind-api-client/payments/PaymentsV10Payture.js +30 -0
- package/lib/behind-api-client/payments/PaymentsV10Product.js +15 -0
- package/lib/behind-api-client/payments/PaymentsV10Telegram.js +44 -0
- package/lib/behind-api-client/payments/PaymentsV20.js +9 -0
- package/lib/behind-api-client/payments/PaymentsV20Payture.js +32 -0
- package/lib/behind-api-client/payments/PaymentsV21.js +15 -0
- package/lib/behind-api-client/payments/PaymentsV21Cards.js +14 -0
- package/lib/behind-api-client/payments/PaymentsV21Payture.js +29 -0
- package/lib/behind-api-client/payments/PaymentsV21Stripe.js +28 -0
- package/lib/behind-api-client/payments/PaymentsV21Subscriptions.js +21 -0
- package/lib/behind-api-client/questionnaire/QuestionnaireApp.js +9 -0
- package/lib/behind-api-client/questionnaire/QuestionnaireV10.js +9 -0
- package/lib/behind-api-client/questionnaire/QuestionnaireV10Form.js +22 -0
- package/lib/behind-api-client/raet/RaetApp.js +11 -0
- package/lib/behind-api-client/raet/RaetV10.js +21 -0
- package/lib/behind-api-client/raet/RaetV10Cv.js +87 -0
- package/lib/behind-api-client/raet/RaetV10Individual.js +43 -0
- package/lib/behind-api-client/raet/RaetV10Individuals.js +38 -0
- package/lib/behind-api-client/raet/RaetV10Jd.js +47 -0
- package/lib/behind-api-client/raet/RaetV10Project.js +61 -0
- package/lib/behind-api-client/raet/RaetV10Projects.js +14 -0
- package/lib/behind-api-client/raet/RaetV10Report.js +39 -0
- package/lib/behind-api-client/raet/RaetV20.js +11 -0
- package/lib/behind-api-client/raet/RaetV20Cv.js +31 -0
- package/lib/behind-api-client/raet/RaetV20Individuals.js +25 -0
- package/lib/behind-api-client/rag/RagApp.js +9 -0
- package/lib/behind-api-client/rag/RagV10.js +9 -0
- package/lib/behind-api-client/rag/RagV10Storage.js +27 -0
- package/lib/behind-api-client/ruKitchen/RuKitchenApp.js +9 -0
- package/lib/behind-api-client/ruKitchen/RuKitchenV10.js +11 -0
- package/lib/behind-api-client/ruKitchen/RuKitchenV10Importer.js +29 -0
- package/lib/behind-api-client/ruKitchen/RuKitchenV10SeoArticle.js +14 -0
- package/lib/behind-api-client/sales/SalesApp.js +11 -0
- package/lib/behind-api-client/sales/SalesV10.js +23 -0
- package/lib/behind-api-client/sales/SalesV10Catalogue.js +58 -0
- package/lib/behind-api-client/sales/SalesV10Categories.js +15 -0
- package/lib/behind-api-client/sales/SalesV10Companies.js +55 -0
- package/lib/behind-api-client/sales/SalesV10Company.js +120 -0
- package/lib/behind-api-client/sales/SalesV10Group.js +70 -0
- package/lib/behind-api-client/sales/SalesV10Groups.js +21 -0
- package/lib/behind-api-client/sales/SalesV10Logs.js +14 -0
- package/lib/behind-api-client/sales/SalesV10Notes.js +38 -0
- package/lib/behind-api-client/sales/SalesV20.js +11 -0
- package/lib/behind-api-client/sales/SalesV20Companies.js +26 -0
- package/lib/behind-api-client/sales/SalesV20Notes.js +17 -0
- package/lib/behind-api-client/sip/SipApp.js +9 -0
- package/lib/behind-api-client/sip/SipV10.js +15 -0
- package/lib/behind-api-client/sip/SipV10Call.js +83 -0
- package/lib/behind-api-client/sip/SipV10Phone.js +44 -0
- package/lib/behind-api-client/sip/SipV10Transcript.js +21 -0
- package/lib/behind-api-client/sip/SipV10Transcripts.js +21 -0
- package/lib/behind-api-client/storage/StorageApp.js +9 -0
- package/lib/behind-api-client/storage/StorageV10.js +11 -0
- package/lib/behind-api-client/storage/StorageV10File.js +35 -0
- package/lib/behind-api-client/storage/StorageV10Upload.js +21 -0
- package/lib/behind-api-client/tests/TestsApp.js +9 -0
- package/lib/behind-api-client/tests/TestsV10.js +15 -0
- package/lib/behind-api-client/tests/TestsV10Cases.js +29 -0
- package/lib/behind-api-client/tests/TestsV10CasesExtended.js +14 -0
- package/lib/behind-api-client/tests/TestsV10Core.js +14 -0
- package/lib/behind-api-client/tests/TestsV10Mail.js +14 -0
- package/lib/behind-api-client/tools/ToolsApp.js +9 -0
- package/lib/behind-api-client/tools/ToolsV10.js +9 -0
- package/lib/behind-api-client/tools/ToolsV10Pdf.js +30 -0
- package/package.json +25 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# Stripe Subscription Flow
|
|
2
|
+
|
|
3
|
+
## Workflow Overview
|
|
4
|
+
|
|
5
|
+
This document outlines the complete subscription process for integrating Stripe payments with BehindAPI.
|
|
6
|
+
|
|
7
|
+
### Process Steps
|
|
8
|
+
|
|
9
|
+
1. **Extract Subscription ID**
|
|
10
|
+
- Receive `subscription_id` from URL GET parameter
|
|
11
|
+
|
|
12
|
+
2. **Check Existing Payment Methods**
|
|
13
|
+
- Query BehindAPI to check if user has saved Stripe cards
|
|
14
|
+
|
|
15
|
+
3. **Direct Subscription (Existing Card)**
|
|
16
|
+
- If saved card exists, proceed directly to subscription creation using `subscription_id`
|
|
17
|
+
|
|
18
|
+
4. **New Card Authorization Flow**
|
|
19
|
+
- If no saved card exists, initiate card authorization process:
|
|
20
|
+
|
|
21
|
+
4.1 **Initialize Authorization**
|
|
22
|
+
- Call BehindAPI to initialize card authorization
|
|
23
|
+
- Obtain `client_secret` for Stripe integration
|
|
24
|
+
|
|
25
|
+
4.2 **Stripe Card Setup**
|
|
26
|
+
- Use Stripe SDK to authorize card with `client_secret`
|
|
27
|
+
- Receive customer card token from Stripe
|
|
28
|
+
|
|
29
|
+
4.3 **Finalize Authorization**
|
|
30
|
+
- Send customer card token to BehindAPI endpoint
|
|
31
|
+
- Save payment method for future use
|
|
32
|
+
|
|
33
|
+
4.4 **Create Subscription**
|
|
34
|
+
- Subscribe user using `subscription_id`
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
````html
|
|
38
|
+
|
|
39
|
+
<script src="https://js.stripe.com/v3/"></script>
|
|
40
|
+
|
|
41
|
+
<form style="width:100%;display:none" method="post" id="stripe-payment-form">
|
|
42
|
+
<div class="form-row">
|
|
43
|
+
<label for="card-element" style="display:none">
|
|
44
|
+
We accept credit or debit cards. After you fill all necessary fileds,
|
|
45
|
+
<span id="stripe-payment-form-amount"></span> will be debited from your card. The rest of founds
|
|
46
|
+
<span id="stripe-payment-form-amount-rest"></span> will be taken from your Zecamp wallet.
|
|
47
|
+
</label>
|
|
48
|
+
<div id="stripe-payment-form-card-element">
|
|
49
|
+
<!-- A Stripe Element will be inserted here. -->
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div id="payment-method-selection">
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<!-- Used to display form errors. -->
|
|
57
|
+
<div id="card-errors" role="alert"></div>
|
|
58
|
+
</div>
|
|
59
|
+
</form>
|
|
60
|
+
|
|
61
|
+
````
|
|
62
|
+
|
|
63
|
+
````js
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Stripe Payment Integration
|
|
67
|
+
* Handles subscription payments with saved card support
|
|
68
|
+
*/
|
|
69
|
+
$(document).ready(function() {
|
|
70
|
+
(async () => {
|
|
71
|
+
// Initialize API clients
|
|
72
|
+
console.log("Initializing Stripe Payment System...");
|
|
73
|
+
const BehindAPI = new BehindApiClient(
|
|
74
|
+
"https://127.0.0.1:6002",
|
|
75
|
+
"ACCESS_TOKEN HERE"
|
|
76
|
+
);
|
|
77
|
+
const stripe = Stripe("pk_test_OE8u9FAKvK0W8vYr5mMCj92G");
|
|
78
|
+
|
|
79
|
+
// Step 1: Check for existing saved cards
|
|
80
|
+
const savedCards = await BehindAPI.payments.V21.cards.getList();
|
|
81
|
+
const savedStripeCards = savedCards.data.filter(card => card.payment_method === "stripe");
|
|
82
|
+
console.log("Found saved Stripe cards:", savedStripeCards.length);
|
|
83
|
+
|
|
84
|
+
// Step 2: Initialize payment form based on saved cards
|
|
85
|
+
if (savedStripeCards.length === 0) {
|
|
86
|
+
initializeNewCardForm();
|
|
87
|
+
} else {
|
|
88
|
+
displaySavedCardInfo();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Initialize form for new card entry
|
|
93
|
+
*/
|
|
94
|
+
function initializeNewCardForm() {
|
|
95
|
+
console.log("Setting up new card form...");
|
|
96
|
+
|
|
97
|
+
// Create Stripe Elements instance
|
|
98
|
+
const elements = stripe.elements();
|
|
99
|
+
|
|
100
|
+
// Define card input styling
|
|
101
|
+
const cardElementStyle = {
|
|
102
|
+
base: {
|
|
103
|
+
color: '#32325d',
|
|
104
|
+
lineHeight: '18px',
|
|
105
|
+
fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
|
|
106
|
+
fontSmoothing: 'antialiased',
|
|
107
|
+
fontSize: '16px',
|
|
108
|
+
'::placeholder': {
|
|
109
|
+
color: '#aab7c4'
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
invalid: {
|
|
113
|
+
color: '#fa755a',
|
|
114
|
+
iconColor: '#fa755a'
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Create and mount card element
|
|
119
|
+
const card = elements.create('card', { style: cardElementStyle });
|
|
120
|
+
card.mount('#stripe-payment-form-card-element');
|
|
121
|
+
|
|
122
|
+
// Handle real-time validation errors
|
|
123
|
+
card.addEventListener('change', function(event) {
|
|
124
|
+
const displayError = document.getElementById('card-errors');
|
|
125
|
+
displayError.textContent = event.error ? event.error.message : '';
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Store card element for use in payment processing
|
|
129
|
+
window.stripeCardElement = card;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Display saved card information
|
|
134
|
+
*/
|
|
135
|
+
function displaySavedCardInfo() {
|
|
136
|
+
console.log("Displaying saved card info...");
|
|
137
|
+
|
|
138
|
+
const firstCard = savedStripeCards[0];
|
|
139
|
+
const cardElement = document.getElementById('stripe-payment-form-card-element');
|
|
140
|
+
|
|
141
|
+
// Generate card display HTML
|
|
142
|
+
cardElement.innerHTML = `
|
|
143
|
+
<div class="saved-card-info">
|
|
144
|
+
<div class="card-display">
|
|
145
|
+
<div class="card-icon">${getCardIcon(firstCard.binding_type)}</div>
|
|
146
|
+
<div class="card-details">
|
|
147
|
+
|
|
148
|
+
<div class="card-number">•••• •••• •••• ${firstCard.binding_name}</div>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Get appropriate icon for card type
|
|
158
|
+
*/
|
|
159
|
+
function getCardIcon(cardType) {
|
|
160
|
+
const icons = {
|
|
161
|
+
'visa': '💳',
|
|
162
|
+
'mastercard': '💳',
|
|
163
|
+
'amex': '💳',
|
|
164
|
+
'discover': '💳',
|
|
165
|
+
'default': '💳'
|
|
166
|
+
};
|
|
167
|
+
return icons[cardType.toLowerCase()] || icons.default;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Step 3: Handle payment form submission
|
|
171
|
+
$("#stripe-payment-submit").on("click", async function(event) {
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
console.log("Processing payment...");
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
if (savedStripeCards.length === 0) {
|
|
177
|
+
await processNewCardPayment();
|
|
178
|
+
} else {
|
|
179
|
+
await processSubscriptionWithSavedCard();
|
|
180
|
+
}
|
|
181
|
+
} catch (error) {
|
|
182
|
+
console.error("Payment processing error:", error);
|
|
183
|
+
alert("Payment failed. Please try again.");
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Process payment with new card
|
|
189
|
+
*/
|
|
190
|
+
async function processNewCardPayment() {
|
|
191
|
+
console.log("Processing new card payment...");
|
|
192
|
+
|
|
193
|
+
// Step 1: Initialize payment intent on server
|
|
194
|
+
const paymentIntent = await BehindAPI.payments.V21.stripe.init();
|
|
195
|
+
console.log("Payment intent created:", paymentIntent);
|
|
196
|
+
|
|
197
|
+
const clientSecret = paymentIntent.data.client_secret;
|
|
198
|
+
const cardholderName = "CARDHOLDER NAME"; // TODO: Get from form input
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
// Step 2: Set up payment method with Stripe
|
|
202
|
+
const cardToken = await stripe.handleCardSetup(
|
|
203
|
+
clientSecret,
|
|
204
|
+
window.stripeCardElement,
|
|
205
|
+
{
|
|
206
|
+
payment_method_data: {
|
|
207
|
+
billing_details: { name: cardholderName }
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
// Step 3: Finalize card setup on server
|
|
213
|
+
const bindResult = await BehindAPI.payments.V21.stripe.finalise(
|
|
214
|
+
cardToken.setupIntent.payment_method
|
|
215
|
+
);
|
|
216
|
+
console.log("Card setup finalized:", bindResult);
|
|
217
|
+
|
|
218
|
+
// Step 4: Create subscription
|
|
219
|
+
await createSubscription();
|
|
220
|
+
|
|
221
|
+
} catch (cardError) {
|
|
222
|
+
console.error("Card setup error:", cardError);
|
|
223
|
+
throw new Error("Card setup failed");
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Process subscription with existing saved card
|
|
229
|
+
*/
|
|
230
|
+
async function processSubscriptionWithSavedCard() {
|
|
231
|
+
console.log("Using saved card for subscription...");
|
|
232
|
+
await createSubscription();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Create subscription using the configured payment method
|
|
237
|
+
*/
|
|
238
|
+
async function createSubscription() {
|
|
239
|
+
console.log("Creating subscription...");
|
|
240
|
+
|
|
241
|
+
// TODO: Get subscription_id from URL parameter
|
|
242
|
+
const subscriptionId = "subscription_id_here";
|
|
243
|
+
|
|
244
|
+
const subscriptionResult = await BehindAPI.payments.V21.subscriptions.subscribe(subscriptionId);
|
|
245
|
+
console.log("Subscription created successfully:", subscriptionResult);
|
|
246
|
+
|
|
247
|
+
// Show success message to user
|
|
248
|
+
alert("Subscription activated successfully!");
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
})();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
````
|