Skip to content

Commit 19a2e54

Browse files
author
meow12
committed
feat(payments): create apple subscription
create apple subscription
1 parent b32633b commit 19a2e54

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

src/components/payments.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,34 @@ export async function createSubscription({
413413
return response;
414414
}
415415

416+
export async function createAppStoreSubscription({
417+
secretKey,
418+
customerId,
419+
planId,
420+
receipt,
421+
}) {
422+
const response = await server.loadJson(
423+
`${
424+
Config.apiUrl
425+
}${Endpoints.PROJECT.PAYMENTS.SUBSCRIPTIONS.CREATE_APP_STORE(customerId)}`,
426+
{
427+
method: 'POST',
428+
headers: {
429+
'X-CM-ProjectId': Config.projectId,
430+
Authorization: `Bearer ${secretKey || Config.secretKey}`,
431+
Accept: 'application/json',
432+
'Content-Type': 'application/json',
433+
},
434+
body: JSON.stringify({
435+
planId,
436+
receipt,
437+
}),
438+
}
439+
);
440+
441+
return response;
442+
}
443+
416444
export async function updateSubscription({
417445
secretKey,
418446
id,

src/components/push.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,7 @@ export async function updateDevice({
157157
return response;
158158
}
159159

160-
export async function updateDeviceUser({
161-
secretKey,
162-
idOrKey,
163-
userId,
164-
}) {
160+
export async function updateDeviceUser({secretKey, idOrKey, userId}) {
165161
const response = await server.loadJson(
166162
`${Config.apiUrl}${Endpoints.PROJECT.NOTIFICATIONS.PUSH.UPDATE_DEVICE_USER(
167163
idOrKey
@@ -175,7 +171,7 @@ export async function updateDeviceUser({
175171
'Content-Type': 'application/json',
176172
},
177173
body: JSON.stringify({
178-
userId
174+
userId,
179175
}),
180176
}
181177
);

src/routes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ export const CONFIG = {
148148
SUBSCRIPTIONS: {
149149
CREATE: (customerId) =>
150150
`/v2/payments/customers/${customerId}/subscriptions`,
151+
CREATE_APP_STORE: (customerId) =>
152+
`/v2/payments/customers/${customerId}/subscriptions/apple`,
151153
UPDATE: (customerId, id) =>
152154
`/v2/payments/customers/${customerId}/subscriptions/${id}`,
153155
CHANGE: (customerId, id) =>

0 commit comments

Comments
 (0)