Skip to content

Commit 4fea35a

Browse files
authored
Merge pull request #36 from codemash-io/version1
feat(payments): create apple subscription
2 parents faafde7 + 19a2e54 commit 4fea35a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
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/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)