Skip to content

Commit 473595d

Browse files
committed
handle free trial users
1 parent 7e1340c commit 473595d

1 file changed

Lines changed: 10 additions & 24 deletions

File tree

controller/subscription_controller.go

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ const RefreshTransferBalanceDuration = 30 * time.Hour
4444

4545
// const RefreshTransferBalanceTimeout = 24 * time.Hour
4646

47-
const RefreshSupporterTransferBalance = 1000 * model.Gib
48-
const RefreshFreeTransferBalance = 70 * model.Gib
47+
const RefreshSupporterTransferBalance = 600 * model.Gib
48+
const RefreshFreeTransferBalance = 34 * model.Gib // ~ 1 TiB / month
4949

5050
const SubscriptionGracePeriod = 24 * time.Hour
5151

@@ -1863,33 +1863,19 @@ func HandleSubscribedApple(ctx context.Context, notification AppleNotificationDe
18631863

18641864
}
18651865

1866-
// // note - currently if a TestFlight user subscribes,
1867-
// // they won't be marked as pro since their price is 0
1868-
// // in the transaction info
1869-
// // uncommenting this will mark them as pro, but pollutes net_revenue with false data
1870-
// // if uncommenting, wrap in check that price is zero
1871-
1872-
//
1873-
// // todo - deprecate
1874-
// // we should instead mark transfer balance as PRO
1875-
// // in the case of testflight users, we don't want to pollute net_revenue with false data
1876-
// //
1877-
// // fallback if we can't parse price, hardset price
1878-
// glog.Infof("[apple] price not found in transaction info, using hardset values")
1879-
1880-
// now := time.Now()
1881-
// twoMonthsFromNow := now.AddDate(0, 2, 0)
1882-
// if expiresDate.After(twoMonthsFromNow) {
1883-
// priceNanoCents = model.UsdToNanoCents(39.99) // year subscription
1884-
// } else {
1885-
// priceNanoCents = model.UsdToNanoCents(4.99) // monthly subscription
1886-
// }
1887-
18881866
// fixme: hardcoded fee fraction
18891867
feeFraction := 0.2
18901868

18911869
netRevenue := priceNanoCents - int64(float64(priceNanoCents)*feeFraction)
18921870

1871+
if netRevenue == 0 {
1872+
/**
1873+
* For users who subscribe via TestFlight or with FREE_TRIAL, the price will be 0
1874+
* We still want to mark them upgraded in the DB, which means they need some paid transfer_balance
1875+
*/
1876+
netRevenue = model.UsdToNanoCents(0.01)
1877+
}
1878+
18931879
glog.Infof("[apple] Subscription details - App Transaction ID: %s, Network ID: %s, Product ID: %s, Expires: %s, Net Revenue: %d",
18941880
appTransactionId,
18951881
networkId,

0 commit comments

Comments
 (0)