Skip to content

Commit b659e0d

Browse files
committed
chore: updated payload to include BillingCycle
1 parent 5476206 commit b659e0d

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

Common/Messages/BackupMessage.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public class BackupMessage
66

77
public string SaleType { get; set; }
88

9+
public string BillingCycle { get; set; }
10+
911
public int Price { get; set; }
1012
}
1113
}

WebHook/Model/Hook.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,15 @@ public class MarketplacePurchase
336336
public Account account { get; set; }
337337

338338
public Plan plan { get; set; }
339+
public string billing_cycle { get; set; }
339340
public bool? on_free_trial { get; set; }
340341
}
341342

342343
public class Plan
343344
{
344345
public int id { get; set; }
345346
public int monthly_price_in_cents { get; set; }
347+
public int yearly_price_in_cents { get; set; }
346348
}
347349
}
348350
}

WebHook/WebHookFunction.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,20 @@ private static async Task<string> ProcessMarketplacePurchaseAsync(Hook hook, Clo
360360
}
361361
}
362362

363+
var price = hook.marketplace_purchase.plan.monthly_price_in_cents / 100;
364+
365+
if (hook.marketplace_purchase.billing_cycle == "yearly")
366+
{
367+
price = hook.marketplace_purchase.plan.yearly_price_in_cents / 100;
368+
}
369+
363370
await backupMessages.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(
364371
new BackupMessage
365372
{
366373
PlanId = hook.marketplace_purchase.plan.id,
367-
Price = hook.marketplace_purchase.plan.monthly_price_in_cents / 100,
368-
SaleType = recurrentSale
374+
Price = price,
375+
SaleType = recurrentSale,
376+
BillingCycle = hook.marketplace_purchase.billing_cycle
369377
})));
370378
}
371379

@@ -390,12 +398,20 @@ await marketplaceTable.ExecuteAsync(TableOperation.InsertOrMerge(new Marketplace
390398
if (KnownGitHubs.Plans.ContainsKey(hook.marketplace_purchase.plan.id) &&
391399
KnownGitHubs.Plans[hook.marketplace_purchase.plan.id] != 0)
392400
{
401+
var price = hook.marketplace_purchase.plan.monthly_price_in_cents / 100;
402+
403+
if (hook.marketplace_purchase.billing_cycle == "yearly")
404+
{
405+
price = hook.marketplace_purchase.plan.yearly_price_in_cents / 100;
406+
}
407+
393408
await backupMessages.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(
394409
new BackupMessage
395410
{
396411
PlanId = hook.marketplace_purchase.plan.id,
397-
Price = hook.marketplace_purchase.plan.monthly_price_in_cents / 100,
398-
SaleType = "cancelled"
412+
Price = price,
413+
SaleType = "cancelled",
414+
BillingCycle = hook.marketplace_purchase.billing_cycle
399415
})));
400416
}
401417

0 commit comments

Comments
 (0)