Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
🐛 Credit card fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Jun 25, 2019
1 parent 692a09b commit 3bfbe6d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "staart",
"version": "1.0.42",
"version": "1.0.43",
"main": "index.js",
"repository": "[email protected]:AnandChowdhary/staart.git",
"author": "Anand Chowdhary <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export class OrganizationController {
joiValidate(
{
organizationId: Joi.number().required(),
sourceId: Joi.number().required()
sourceId: Joi.string().required()
},
{ organizationId, sourceId }
);
Expand All @@ -408,7 +408,7 @@ export class OrganizationController {
joiValidate(
{
organizationId: Joi.number().required(),
sourceId: Joi.number().required()
sourceId: Joi.string().required()
},
{ organizationId, sourceId }
);
Expand Down
8 changes: 4 additions & 4 deletions src/crud/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const getStripeSources = async (
) => {
return cleanStripeResponse(
await stripe.customers.listSources(id, {
object: "source",
object: "card",
starting_after: start !== "0" ? start : undefined,
limit: itemsPerPage
})
Expand Down Expand Up @@ -269,8 +269,8 @@ export const deleteStripeSource = async (id: string, sourceId: string) => {
* Get the details of a customer
* @param id - Stripe customer ID
*/
export const createStripeSource = async (id: string, card: any) => {
await stripe.customers.createCard(id, { card });
export const createStripeSource = async (id: string, source: any) => {
await stripe.customers.createSource(id, { source });
return { success: true, message: "billing-source-created" };
};

Expand All @@ -283,6 +283,6 @@ export const updateStripeSource = async (
cardId: string,
data: any
) => {
await stripe.customers.updateCard(id, cardId, data);
await stripe.customers.updateSource(id, cardId, data);
return { success: true, message: "billing-source-updated" };
};
5 changes: 3 additions & 2 deletions src/rest/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import {
getStripeSubscription,
updateStripeSubscription,
getStripeInvoice,
createStripeSubscriptionSession
createStripeSubscriptionSession,
createStripeSubscription
} from "../crud/billing";
import { getUser } from "../crud/user";
import { ApiKey } from "../interfaces/tables/user";
Expand Down Expand Up @@ -276,7 +277,7 @@ export const createOrganizationSubscriptionForUser = async (
if (await can(userId, Authorizations.READ, "organization", organizationId)) {
const organization = await getOrganization(organizationId);
if (organization.stripeCustomerId)
return await createStripeSubscriptionSession(
return await createStripeSubscription(
organization.stripeCustomerId,
params
);
Expand Down

0 comments on commit 3bfbe6d

Please sign in to comment.