Skip to content

Commit 0e8df21

Browse files
authored
Merge pull request #67 from teacoder-team/dev
fix: prevent idempotence key reuse error
2 parents 0b8a364 + d688ef3 commit 0e8df21

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

packages/nestjs-yookassa/dist/core/http/yookassa.http-client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ let YookassaHttpClient = class YookassaHttpClient {
3232
password: this.config.apiKey
3333
};
3434
client.defaults.headers.common['Content-Type'] = 'application/json';
35-
client.defaults.headers.common['Idempotence-Key'] = (0, crypto_1.randomUUID)();
3635
}
3736
async request(options) {
3837
var _a, _b, _c, _d, _e;
3938
try {
39+
options.headers = Object.assign(Object.assign({}, options.headers), { 'Idempotence-Key': (0, crypto_1.randomUUID)() });
4040
const $res = this.httpService.request(options);
4141
const res = await (0, rxjs_1.firstValueFrom)($res);
4242
return res.data;

packages/nestjs-yookassa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nestjs-yookassa",
3-
"version": "2.0.3",
3+
"version": "2.0.4",
44
"description": "A NestJS library for integrating with YooKassa API",
55
"keywords": [
66
"nest",

packages/nestjs-yookassa/src/core/http/yookassa.http-client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ export class YookassaHttpClient {
2626
password: this.config.apiKey
2727
}
2828
client.defaults.headers.common['Content-Type'] = 'application/json'
29-
client.defaults.headers.common['Idempotence-Key'] = randomUUID()
3029
}
3130

3231
public async request<T = any>(options: AxiosRequestConfig): Promise<T> {
3332
try {
33+
options.headers = {
34+
...options.headers,
35+
'Idempotence-Key': randomUUID()
36+
}
37+
3438
const $res = this.httpService.request(options)
3539
const res = await firstValueFrom($res)
3640

0 commit comments

Comments
 (0)