mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
Ensured upgraded groups are charge correctly (#8567)
* Ensured upgraded groups are charge correctly * Added names to magic numbers * Limited group fields query
This commit is contained in:
committed by
Sabe Jones
parent
cfa433aa75
commit
3dc20a9832
@@ -252,6 +252,17 @@ api.subscribe = async function subscribe (options) {
|
||||
if (!result) throw new NotAuthorized(i18n.t('invalidCoupon'));
|
||||
}
|
||||
|
||||
let amount = sub.price;
|
||||
let leaderCount = 1;
|
||||
let priceOfSingleMember = 3;
|
||||
|
||||
if (groupId) {
|
||||
let groupFields = basicGroupFields.concat(' purchased');
|
||||
let group = await Group.getGroup({user, groupId, populateLeader: false, groupFields});
|
||||
|
||||
amount = sub.price + (group.memberCount - leaderCount) * priceOfSingleMember;
|
||||
}
|
||||
|
||||
await this.setBillingAgreementDetails({
|
||||
AmazonBillingAgreementId: billingAgreementId,
|
||||
BillingAgreementAttributes: {
|
||||
@@ -273,7 +284,7 @@ api.subscribe = async function subscribe (options) {
|
||||
AuthorizationReferenceId: common.uuid().substring(0, 32),
|
||||
AuthorizationAmount: {
|
||||
CurrencyCode: this.constants.CURRENCY_CODE,
|
||||
Amount: sub.price,
|
||||
Amount: amount,
|
||||
},
|
||||
SellerAuthorizationNote: this.constants.SELLER_NOTE_ATHORIZATION_SUBSCRIPTION,
|
||||
TransactionTimeout: 0,
|
||||
|
||||
Reference in New Issue
Block a user