#theonlybigbad_api

1 messages · Page 1 of 1 (latest)

iron bearBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1366833615425765426

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

atomic gulch
#

var sessionOptions = new SessionCreateOptions
{
PaymentMethodTypes = new List<string> { "card" },
Mode = "subscription",
Customer = stripeCustomerId,
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = priceId,
Quantity = 1
}
},
SuccessUrl = successUrl,
CancelUrl = cancelUrl
};

// If we have a free trial period, then add one day to the trial period, so it shows as that many free days, vs the less one day because it's less than a full day now.
if (numTrialDays > 0)
{
var trialEnd = DateTime.UtcNow.AddDays(numTrialDays).AddHours(1);
sessionOptions.SubscriptionData = new SessionSubscriptionDataOptions
{
TrialEnd = trialEnd, // Set custom trial end date
};
}

// Handle referral commissions
if (!string.IsNullOrEmpty(referrerStripeAccountId) && affiliateCommissionRate.HasValue)
{
// Calculate the application fee percentage
decimal applicationFeePercent = Math.Round((1 - (affiliateCommissionRate.Value / 100)) * 100, 2);

sessionOptions.PaymentIntentData = new SessionPaymentIntentDataOptions
{
    TransferData = new SessionPaymentIntentDataTransferDataOptions
    {
        Destination = referrerStripeAccountId
    },
    ApplicationFeeAmount = null, // Not used for percentage-based fees
};

sessionOptions.***ApplicationFeePercent ***= applicationFeePercent;

}

var sessionService = new SessionService();
try
{
var session = await sessionService.CreateAsync(sessionOptions);
return session.Url;
}

#

I just found it in sessionOptions.SubscriptionData.ApplicationFeePercent

trail cosmos
#

👋

atomic gulch
#

FYI, if we could allow an ApplicationFeeAmount for a referral commissions on a recurring basis it would be way better and make the transaction flows and commission payouts way better. That wasn't supported before not sure if or when it would be supported.

trail cosmos
atomic gulch
#

Currently to do the commissions on a $14.99 subscription with $1.00 going to the referree, we have to charge a 93% ApplicationFeePercent and what is left is what the Referree receives each month.

#

Or having the payment_intent_data.transfer_data.amount on a subscription work monthly, would be great. But that's not supported either.

#

We use the payment_intent_data.transfer_data.destination to pay the connect account referree, but have to use an application fee percent to pull most of the money back to the Stripe host.

#

Huh.... The Subscription Data has:
subscription_data.transfer_data
Dictionary
Connect only
If specified, the funds from the subscription’s invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges.

Hide child parameters

subscription_data.transfer_data.destination
string
Required
ID of an existing, connected Stripe account.

subscription_data.transfer_data.amount_percent
float
A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the destination account. By default, the entire amount is transferred to the destination.

Soooo would this work as we hoped? and NOT have to use the SessionPaymentIntent?

trail cosmos
#

So that is to say you want to create a $14.99/month Subscription and each month you want 13.99 of those funds to "remain" in the platform's balance and $1 to go to the connected account?

atomic gulch
#

Yeah, it's still just amount_percent, not a fixed amount as an option.

#

Yes. That's ideally what we want. But we have it working (via Payment Links), which was before I learned that we don't have to use static Payment Links and can build the Session on the fly. E.g. Each referrer may have different commission rates an Trial Days can also be different (which I don't have in my payment links, but we want to add to referral Subscription signups too). So migrating away from Payment Links to all being created on the fly in a checkout Session.

trail cosmos
#

gotcha! Let me look at how you would do this