Skip to content

Commit

Permalink
update payment method when update card
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu committed Jul 27, 2023
1 parent e4e8cc2 commit c35fdae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/models/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ AND effective_end_date IS NULL
AND pending=0`;

const updatePaymentInfoSql = `UPDATE account_subscriptions
SET last4 = ?, exp_month = ?, exp_year = ?, card_type = ?
SET last4 = ?, stripe_payment_method_id=?, exp_month = ?, exp_year = ?, card_type = ?
WHERE account_sid = ?
AND effective_end_date IS NULL`;

Expand Down Expand Up @@ -206,10 +206,10 @@ class Account extends Model {
}

static async updatePaymentInfo(logger, account_sid, pm) {
const {card} = pm;
const {id, card} = pm;
const last4_encrypted = encrypt(card.last4);
await promisePool.execute(updatePaymentInfoSql,
[last4_encrypted, card.exp_month, card.exp_year, card.brand, account_sid]);
[last4_encrypted, id, card.exp_month, card.exp_year, card.brand, account_sid]);
}

static async provisionPendingSubscription(logger, account_sid, products, payment_method, subscription_id) {
Expand Down

0 comments on commit c35fdae

Please sign in to comment.