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,396 @@
|
|
|
1
|
+
# Recipe Access Purchase - Quick Start Guide
|
|
2
|
+
|
|
3
|
+
## Workflow Overview
|
|
4
|
+
|
|
5
|
+
This guide describes the complete workflow for purchasing access to a recipe page.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Workflow Steps
|
|
10
|
+
|
|
11
|
+
### Step 1: User Clicks "Купить доступ к рецепту"
|
|
12
|
+
|
|
13
|
+
When the user clicks the purchase button, collect the following data:
|
|
14
|
+
|
|
15
|
+
**Required Data:**
|
|
16
|
+
- `user_id` - Current user's UUID
|
|
17
|
+
- `subscription_id` - Fixed value: `"a295e987-28c6-4b79-b1f7-5245d95b91d6"`
|
|
18
|
+
- `pageId` - The recipe page ID (e.g., `"ck4jrtawdA3Ed4"`)
|
|
19
|
+
- `redirect_url` - Where to return after payment: `https://shop.ru-kitchen.ru/bills/{bill_id}`
|
|
20
|
+
|
|
21
|
+
**Example Data:**
|
|
22
|
+
```javascript
|
|
23
|
+
const userId = getCurrentUserId(); // Get from your auth system
|
|
24
|
+
const subscriptionId = "a295e987-28c6-4b79-b1f7-5245d95b91d6";
|
|
25
|
+
const pageId = "ck4jrtawdA3Ed4";
|
|
26
|
+
const originalPageUrl = "https://ru-kitchen.ru/old/baking/ck4jrtawdA3Ed4-fokachcha";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Step 2: Create Payment Bill
|
|
30
|
+
|
|
31
|
+
Call the `billCreateUnauthorised` function with the collected data:
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
async function purchaseRecipeAccess(userId, pageId, originalPageUrl) {
|
|
35
|
+
try {
|
|
36
|
+
const subscriptionId = "a295e987-28c6-4b79-b1f7-5245d95b91d6";
|
|
37
|
+
|
|
38
|
+
const result = await behindAPI.easyjob.V20.payments.payture.billCreateUnauthorised(
|
|
39
|
+
subscriptionId,
|
|
40
|
+
userId,
|
|
41
|
+
`https://shop.ru-kitchen.ru/bills/`, // Will append bill_id automatically
|
|
42
|
+
{
|
|
43
|
+
pageId: pageId,
|
|
44
|
+
redirectUrl: originalPageUrl
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (result.success) {
|
|
49
|
+
const billId = result.data.bill_id;
|
|
50
|
+
const paymentUrl = result.data.bill.payUrl;
|
|
51
|
+
|
|
52
|
+
console.log(`Bill created: ${billId}`);
|
|
53
|
+
console.log(`Redirecting to payment terminal: ${paymentUrl}`);
|
|
54
|
+
|
|
55
|
+
// Redirect user to payment terminal
|
|
56
|
+
window.location.href = paymentUrl;
|
|
57
|
+
|
|
58
|
+
return { success: true, billId, paymentUrl };
|
|
59
|
+
} else {
|
|
60
|
+
console.error("Failed to create bill:", result.message);
|
|
61
|
+
alert("Не удалось создать платеж. Попробуйте снова.");
|
|
62
|
+
return { success: false, error: result.message };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error("Error:", error);
|
|
67
|
+
alert("Произошла ошибка. Попробуйте снова.");
|
|
68
|
+
return { success: false, error: error.message };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Usage
|
|
73
|
+
const userId = "user-uuid-here";
|
|
74
|
+
const pageId = "ck4jrtawdA3Ed4";
|
|
75
|
+
const originalPageUrl = "https://ru-kitchen.ru/old/baking/ck4jrtawdA3Ed4-fokachcha";
|
|
76
|
+
|
|
77
|
+
purchaseRecipeAccess(userId, pageId, originalPageUrl);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Step 3: User Completes Payment
|
|
81
|
+
|
|
82
|
+
The user is redirected to the Payture payment terminal (payUrl) where they complete the payment.
|
|
83
|
+
|
|
84
|
+
### Step 4: Return to Confirmation Page
|
|
85
|
+
|
|
86
|
+
After successful payment, Payture redirects the user to:
|
|
87
|
+
```
|
|
88
|
+
https://shop.ru-kitchen.ru/bills/4c0275df-6c8d-4f1a-b25b-b2db4b831707
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Step 5: Check Payment Status
|
|
92
|
+
|
|
93
|
+
On the confirmation page, check the payment status:
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
async function checkPaymentStatus() {
|
|
97
|
+
try {
|
|
98
|
+
// Extract bill_id from URL
|
|
99
|
+
const urlPath = window.location.pathname;
|
|
100
|
+
const billId = urlPath.split('/bills/')[1];
|
|
101
|
+
|
|
102
|
+
if (!billId) {
|
|
103
|
+
console.error("Bill ID not found in URL");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.log(`Checking status for bill: ${billId}`);
|
|
108
|
+
|
|
109
|
+
// Check payment status
|
|
110
|
+
const statusResult = await behindAPI.easyjob.V20.payments.payture.billStatus(billId);
|
|
111
|
+
|
|
112
|
+
if (!statusResult.success) {
|
|
113
|
+
displayError("Не удалось проверить статус платежа");
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const status = statusResult.data.status;
|
|
118
|
+
console.log(`Payment status: ${status}`);
|
|
119
|
+
|
|
120
|
+
if (status === "PAID" || status === "DONE") {
|
|
121
|
+
// Payment successful
|
|
122
|
+
displaySuccess("Оплата прошла успешно! Доступ к рецепту открыт.");
|
|
123
|
+
|
|
124
|
+
// Redirect back to recipe page after 3 seconds
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
const redirectUrl = getRedirectUrlFromBill();
|
|
127
|
+
if (redirectUrl) {
|
|
128
|
+
window.location.href = redirectUrl;
|
|
129
|
+
}
|
|
130
|
+
}, 3000);
|
|
131
|
+
|
|
132
|
+
} else if (status === "PENDING") {
|
|
133
|
+
// Payment still processing
|
|
134
|
+
displayPending("Платеж обрабатывается. Пожалуйста, подождите...");
|
|
135
|
+
|
|
136
|
+
// Retry after 3 seconds
|
|
137
|
+
setTimeout(checkPaymentStatus, 3000);
|
|
138
|
+
|
|
139
|
+
} else if (status === "AMOUNT_MISMATCH") {
|
|
140
|
+
displayError("Ошибка оплаты. Свяжитесь с поддержкой.");
|
|
141
|
+
} else {
|
|
142
|
+
displayError("Неизвестный статус платежа.");
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error("Error checking payment status:", error);
|
|
147
|
+
displayError("Произошла ошибка при проверке статуса платежа");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Display functions
|
|
152
|
+
function displaySuccess(message) {
|
|
153
|
+
document.getElementById('status-message').textContent = message;
|
|
154
|
+
document.getElementById('status-container').className = 'success';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function displayPending(message) {
|
|
158
|
+
document.getElementById('status-message').textContent = message;
|
|
159
|
+
document.getElementById('status-container').className = 'pending';
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function displayError(message) {
|
|
163
|
+
document.getElementById('status-message').textContent = message;
|
|
164
|
+
document.getElementById('status-container').className = 'error';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function getRedirectUrlFromBill() {
|
|
168
|
+
// Get from extended data or use default
|
|
169
|
+
return "https://ru-kitchen.ru/old/baking/ck4jrtawdA3Ed4-fokachcha";
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Run status check when page loads
|
|
173
|
+
window.addEventListener('load', checkPaymentStatus);
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Complete Implementation Example
|
|
179
|
+
|
|
180
|
+
### Purchase Button Handler
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
// On recipe page: https://ru-kitchen.ru/old/baking/ck4jrtawdA3Ed4-fokachcha
|
|
184
|
+
document.getElementById('buy-access-button').addEventListener('click', async function(e) {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
|
|
187
|
+
// Get current user ID (from your auth system)
|
|
188
|
+
const userId = window.currentUser?.id || getUserIdFromSession();
|
|
189
|
+
|
|
190
|
+
if (!userId) {
|
|
191
|
+
alert("Пожалуйста, войдите в систему");
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Extract page ID from current URL or data attribute
|
|
196
|
+
const pageId = this.dataset.pageId || "ck4jrtawdA3Ed4";
|
|
197
|
+
const currentPageUrl = window.location.href;
|
|
198
|
+
|
|
199
|
+
// Fixed subscription ID for recipe access
|
|
200
|
+
const subscriptionId = "a295e987-28c6-4b79-b1f7-5245d95b91d6";
|
|
201
|
+
|
|
202
|
+
// Show loading state
|
|
203
|
+
this.disabled = true;
|
|
204
|
+
this.textContent = "Создание платежа...";
|
|
205
|
+
|
|
206
|
+
try {
|
|
207
|
+
const result = await behindAPI.easyjob.V20.payments.payture.billCreateUnauthorised(
|
|
208
|
+
subscriptionId,
|
|
209
|
+
userId,
|
|
210
|
+
`https://shop.ru-kitchen.ru/bills/`,
|
|
211
|
+
{
|
|
212
|
+
pageId: pageId,
|
|
213
|
+
redirectUrl: currentPageUrl
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
if (result.success) {
|
|
218
|
+
// Redirect to payment terminal
|
|
219
|
+
window.location.href = result.data.bill.payUrl;
|
|
220
|
+
} else {
|
|
221
|
+
alert("Ошибка создания платежа: " + result.message);
|
|
222
|
+
this.disabled = false;
|
|
223
|
+
this.textContent = "Купить доступ к рецепту";
|
|
224
|
+
}
|
|
225
|
+
} catch (error) {
|
|
226
|
+
console.error("Purchase error:", error);
|
|
227
|
+
alert("Произошла ошибка. Попробуйте снова.");
|
|
228
|
+
this.disabled = false;
|
|
229
|
+
this.textContent = "Купить доступ к рецепту";
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Confirmation Page (https://shop.ru-kitchen.ru/bills/[bill_id])
|
|
235
|
+
|
|
236
|
+
```html
|
|
237
|
+
<!DOCTYPE html>
|
|
238
|
+
<html lang="ru">
|
|
239
|
+
<head>
|
|
240
|
+
<meta charset="UTF-8">
|
|
241
|
+
<title>Подтверждение оплаты</title>
|
|
242
|
+
<style>
|
|
243
|
+
.status-container {
|
|
244
|
+
padding: 20px;
|
|
245
|
+
margin: 20px;
|
|
246
|
+
border-radius: 8px;
|
|
247
|
+
text-align: center;
|
|
248
|
+
}
|
|
249
|
+
.success { background: #d4edda; color: #155724; }
|
|
250
|
+
.pending { background: #fff3cd; color: #856404; }
|
|
251
|
+
.error { background: #f8d7da; color: #721c24; }
|
|
252
|
+
.loader {
|
|
253
|
+
border: 4px solid #f3f3f3;
|
|
254
|
+
border-top: 4px solid #3498db;
|
|
255
|
+
border-radius: 50%;
|
|
256
|
+
width: 40px;
|
|
257
|
+
height: 40px;
|
|
258
|
+
animation: spin 1s linear infinite;
|
|
259
|
+
margin: 20px auto;
|
|
260
|
+
}
|
|
261
|
+
@keyframes spin {
|
|
262
|
+
0% { transform: rotate(0deg); }
|
|
263
|
+
100% { transform: rotate(360deg); }
|
|
264
|
+
}
|
|
265
|
+
</style>
|
|
266
|
+
</head>
|
|
267
|
+
<body>
|
|
268
|
+
<div id="status-container" class="status-container pending">
|
|
269
|
+
<div class="loader"></div>
|
|
270
|
+
<h2>Проверка статуса платежа...</h2>
|
|
271
|
+
<p id="status-message">Пожалуйста, подождите</p>
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
<script>
|
|
275
|
+
async function checkPaymentStatus() {
|
|
276
|
+
try {
|
|
277
|
+
// Get bill_id from URL
|
|
278
|
+
const billId = window.location.pathname.split('/bills/')[1];
|
|
279
|
+
|
|
280
|
+
if (!billId) {
|
|
281
|
+
document.getElementById('status-message').textContent =
|
|
282
|
+
"Ошибка: ID платежа не найден";
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Check status
|
|
287
|
+
const result = await behindAPI.easyjob.V20.payments.payture.billStatus(billId);
|
|
288
|
+
|
|
289
|
+
if (!result.success) {
|
|
290
|
+
throw new Error(result.message);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const status = result.data.status;
|
|
294
|
+
const container = document.getElementById('status-container');
|
|
295
|
+
const message = document.getElementById('status-message');
|
|
296
|
+
|
|
297
|
+
if (status === "PAID" || status === "DONE") {
|
|
298
|
+
container.className = 'status-container success';
|
|
299
|
+
document.querySelector('.loader').style.display = 'none';
|
|
300
|
+
document.querySelector('h2').textContent = 'Оплата успешна!';
|
|
301
|
+
message.textContent = 'Доступ к рецепту открыт. Перенаправление...';
|
|
302
|
+
|
|
303
|
+
// Redirect back to recipe page
|
|
304
|
+
setTimeout(() => {
|
|
305
|
+
// Get redirect URL from extended data or use default
|
|
306
|
+
const redirectUrl = "https://ru-kitchen.ru/old/baking/ck4jrtawdA3Ed4-fokachcha";
|
|
307
|
+
window.location.href = redirectUrl;
|
|
308
|
+
}, 3000);
|
|
309
|
+
|
|
310
|
+
} else if (status === "PENDING") {
|
|
311
|
+
message.textContent = 'Платеж обрабатывается...';
|
|
312
|
+
// Retry after 3 seconds
|
|
313
|
+
setTimeout(checkPaymentStatus, 3000);
|
|
314
|
+
|
|
315
|
+
} else if (status === "AMOUNT_MISMATCH") {
|
|
316
|
+
container.className = 'status-container error';
|
|
317
|
+
document.querySelector('.loader').style.display = 'none';
|
|
318
|
+
document.querySelector('h2').textContent = 'Ошибка оплаты';
|
|
319
|
+
message.textContent = 'Несоответствие суммы. Свяжитесь с поддержкой.';
|
|
320
|
+
|
|
321
|
+
} else {
|
|
322
|
+
container.className = 'status-container error';
|
|
323
|
+
document.querySelector('.loader').style.display = 'none';
|
|
324
|
+
document.querySelector('h2').textContent = 'Ошибка';
|
|
325
|
+
message.textContent = 'Неизвестный статус платежа: ' + status;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
} catch (error) {
|
|
329
|
+
console.error('Error:', error);
|
|
330
|
+
const container = document.getElementById('status-container');
|
|
331
|
+
container.className = 'status-container error';
|
|
332
|
+
document.querySelector('.loader').style.display = 'none';
|
|
333
|
+
document.querySelector('h2').textContent = 'Ошибка';
|
|
334
|
+
document.getElementById('status-message').textContent =
|
|
335
|
+
'Не удалось проверить статус платежа: ' + error.message;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Start checking when page loads
|
|
340
|
+
window.addEventListener('load', checkPaymentStatus);
|
|
341
|
+
</script>
|
|
342
|
+
</body>
|
|
343
|
+
</html>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Data Flow Summary
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
1. User on recipe page: https://ru-kitchen.ru/old/baking/ck4jrtawdA3Ed4-fokachcha
|
|
352
|
+
↓
|
|
353
|
+
2. Clicks "Купить доступ к рецепту"
|
|
354
|
+
↓
|
|
355
|
+
3. Call billCreateUnauthorised with:
|
|
356
|
+
- subscription_id: "a295e987-28c6-4b79-b1f7-5245d95b91d6"
|
|
357
|
+
- user_id: <current user>
|
|
358
|
+
- redirect_url: "https://shop.ru-kitchen.ru/bills/"
|
|
359
|
+
- extended: {
|
|
360
|
+
pageId: "ck4jrtawdA3Ed4",
|
|
361
|
+
redirectUrl: "https://ru-kitchen.ru/old/baking/ck4jrtawdA3Ed4-fokachcha"
|
|
362
|
+
}
|
|
363
|
+
↓
|
|
364
|
+
4. Receive: { bill_id: "4c0275df-6c8d-4f1a-b25b-b2db4b831707", payUrl: "..." }
|
|
365
|
+
↓
|
|
366
|
+
5. Redirect to: payUrl (Payture payment terminal)
|
|
367
|
+
↓
|
|
368
|
+
6. User completes payment
|
|
369
|
+
↓
|
|
370
|
+
7. Payture redirects to: https://shop.ru-kitchen.ru/bills/4c0275df-6c8d-4f1a-b25b-b2db4b831707
|
|
371
|
+
↓
|
|
372
|
+
8. Call billStatus("4c0275df-6c8d-4f1a-b25b-b2db4b831707")
|
|
373
|
+
↓
|
|
374
|
+
9. If status is "PAID" or "DONE":
|
|
375
|
+
- Show success message
|
|
376
|
+
- Redirect back to: https://ru-kitchen.ru/old/baking/ck4jrtawdA3Ed4-fokachcha
|
|
377
|
+
- User now has access to the recipe
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## Important Notes
|
|
383
|
+
|
|
384
|
+
1. **Fixed Subscription ID**: Always use `"a295e987-28c6-4b79-b1f7-5245d95b91d6"` for recipe access purchases
|
|
385
|
+
|
|
386
|
+
2. **Redirect URL Format**: The `redirect_url` parameter should be `https://shop.ru-kitchen.ru/bills/` - the bill_id will be appended automatically
|
|
387
|
+
|
|
388
|
+
3. **Extended Data**: Store both `pageId` and `redirectUrl` in the extended object:
|
|
389
|
+
- `pageId`: Used to grant access to the specific recipe page
|
|
390
|
+
- `redirectUrl`: Used to redirect user back after successful payment
|
|
391
|
+
|
|
392
|
+
4. **Status Polling**: On the confirmation page, poll the status every 3 seconds if it's still PENDING
|
|
393
|
+
|
|
394
|
+
5. **Error Handling**: Always handle errors gracefully and show user-friendly messages in Russian
|
|
395
|
+
|
|
396
|
+
6. **Page Access**: After successful payment, the system automatically grants the user access to the page specified in `extended.pageId`
|