我使用billing_cycle_anchor为第一个订阅月创建按比例收费,以确保在下个月的 1 号收取第一张完整发票。
这部分效果很好,但随后 Stripe 会计算当前发票在(现在)和未来账单日期之间的按比例分配的费率。
在实际向客户的卡扣款之前,如何计算并向客户显示按比例分配的费用?
目前我们使用以下公式来计算当前的按比例分配金额,但并不准确。我们的公式显示3.54 美元,但 Stripe 最终收费3.87 美元
async function getThisMonth(pmtdata) {
let now = Date.now();
var lastday = function(y,m){
return new Date(y, m +1, 0).getDate();
}
let seconds = now / 1000;
let year = new Date().getFullYear();
let month = new Date().getMonth();
if(month <= 10) {
let date = lastday(year,month);
let l1 = 86400 * Number(date);
let l2 = Number(pmtdata.numberPrice) / l1;
let todayD = new Date().getUTCDate();
let l3 = …Run Code Online (Sandbox Code Playgroud)