How to handle a discount with Corrily's create subscription/charge endpoints - corrily

Our website is manually notifying Corrily of subscription and charge events. How should we handle discounts?
Send the price that the user paid when calling create subscription and create charge
Send the full price and then somehow indicate the discount in a subsequent call(s) to Corrily's API.

When calling create charge/subscription you should pass the price that the user paid. So #1 is the correct approach.
Source: I am currently helping the Corrily team with their documentation. This answer is what the Corrily engineering team told a customer to do.

Related

How to know that trial is available in iOS app

We have "try for free" button in our app. I'd like to figure out how to know that trial is available.
I'm a little bit doubt about following text from documentation:
New and resubscribing customers are eligible to pay one discounted price or free trial per subscription group.
What is "resubscribing"? Can customers who has subscription in the past have trial again?
Is it possible to use StoreKit to figure out that trial is available now?
Is it correct to check introductoryPrice property of the SKProduct: https://developer.apple.com/documentation/storekit/skproduct/2936878-introductoryprice?
I also had an idea to ask backend for all the subscription history for current user and show "try for free" if user didn't have trial yet. But as I said I'm not sure about that "resubscribing".
The correct way to check for trial eligibility is to validate the receipt file as outlined by Apple below. Since most would consider this a non-critical validation, there isn't much harm in doing it client-side instead of off a server to save a network call. The worst harm a fake receipt could do is change the text of your button.
Determine Eligibility
To determine if a user is eligible for an introductory price, check
their receipt: Validate the receipt as described in Validating
Receipts With the App Store. In the receipt, check the values of the
Subscription Trial Period and the Subscription Introductory Price
Period for all in-app purchase transactions. If either of these fields
are true for a given subscription, the user is not eligible for an
introductory price on that subscription product or any other products
within the same subscription group. You typically check the user's
eligibility from your server. It's best to determine eligibility
early—for example, on the first launch of the app, if possible.
Based on the receipt, you will find that new and returning customers
are eligible for introductory price or free trial discounts as
follows: New subscribers are always eligible. Lapsed subscribers who
renew are eligible if they haven't previously received an introductory
price for the given product (or any product within the same
subscription group).
To answer your specific questions:
Can customers who has subscription in the past have trial again?
No. This is enforced by Apple for any products in the same subscription group. For example if user starts a trial for "Monthly Product", cancels, then later buys "Yearly Product" they won't be eligible for a free trial.
Is it possible to use StoreKit to figure out that trial is available
now? Is it correct to check introductoryPrice property of the
SKProduct?
No. The SKProduct will always show the same introductory price.

Creating receipts with Stripe Orders

I've looked at the Stripe docs and found receipts that can be attached to Charges by simply passing in receipt_email. However, I have Products and SKUs that I need to attach Orders to. Simply creating a Charge doesn't suffice. What am I missing? This seems like a super basic use case. How does one go about selling a product on Stripe and sending a receipt?
Make sure your account is set up to do it automatically. Then, get the Charge ID from the Order and use it to update the Charge with a receipt_email.
Note that Orders API is deprecated.

Ruby on rails. Monthly subscription best practices

Hello I have a monthly subscription on my app using Braintree which is working ok. I would like some advice on best practices for the event where payments aren't made on time for whatever reason.
I currently have a User model with subscribed:boolean subscribeddate:date and subscribedend:date.
When a user completes payment through braintree, the attributes get updated to subscribed:true subscribeddate:Date.today and subscribedend:Sometime_way_in_the_future .
When a user cancels a subscription, the attributes get updated too, subscribed:false and subscribedend:(a braintree attribute, billing_due_date)
This way I can filter things in my app according to dates and subscription status. The only problem I can see with this is if Braintree tries to charge an account one month but fails. Braintree has an attribute for this (.days_past_due), but my app has no way of knowing whether this has occurred or not.
What are the best practices for this? Should I do a scheduled task each day to check if every single user has a value for the .days_past_due attribute on the Braintree server? Would this not be incredibly slow if I have a lot of users?
I may be going about this all wrong and I'd just like a bit of advice on the matter,
Thanks.
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support#braintreepayments.com.
Your best bet is going to be to implement Braintree's recurring billing webhooks. Webhooks send you a notification via HTTP POST whenever an event occurs that may not have been directly triggered by an API call—such as a customer getting charged via their subscription, a subscription getting canceled, or a subscription going past due. This will allow you to directly respond to subscription events, without having to perform daily checks to see if any changes have occurred.
To use webhooks, you need to choose which events you want to receive webhooks for, designate an endpoint on your server where we'll send the notifications, and set up that endpoint with code to parse the webhook notification into a useable form. For details, see this guide with instructions.

Split/Deferred payments through apple pay

On the getting started page for Apple Pay, it says that Apple Pay supports "partial shipments." How is this implemented in practice? I know how to get a token from a successful PKPayment. Once I get that token, how do I use it to implement multiple sub-order payments through my payment gateway?
For example, say the user validates a total $100 purchase through Apple Pay of two separate suborder shipments ($40 and $60 each) and I now have an associated token for the $100 order. Because of restrictions on some networks, we can't capture each payment until the associated item has been shipped, and they ship at different times.
Do I have the ability to authorize and capture payments of any amounts using that token?
What is the best approach to authorizing and capturing those sub orders?
Do I auth for the total ($100) and then auth for each sub total ($40, $60) at shipment and then capture for each sub total? If so, then I will be potentially authorizing more than the necessary total ($200), and that doesn't seem right. Is it valid to just skip auth for the total, auth for each sub total, and then capture the sub totals as they ship?
You can't capture an authorization more than once. For stripe you would need to save the token to a customer, and charge the customer for each shipment separately. This isn't only the best way it is the only way to do it.
Once you have a token and attach it to the customer object in stripe, you have the ability to charge it at any time & any amount up until the expiration date or if they remove the card from their apple pay account, like you would any other card regardless of the initial authorization.
The rest of your questions will vary by opinion as there are different ways of doing it, but here is how I would charge this type of order. I think this method benefits both the business and the customer, in addition to keeping stripe/apple happy. This isn't apple pay specific, I would treat most orders with these requirements the same. Also keep in mind apple pay supports it, but it is not required. You can collect all up front regardless of shipment dates.
Generate token from PKPayment for $100
Create customer(if needed) & add token to customer
Create charge against customer using that card for $100 without
capture
Within 7 days assess expected shipping dates.
Once assessment is complete immediately capture only the amount
expected to ship within a week on the initial charge. In your
example this is where I would capture $40 for the first charge. If
nothing is expected to be captured issue a complete refund.
Any shipments beyond the 7 days, create individual charges for the
shipments using the customer object, not the token. Again in your example this is when the $60 shipment goes
out charge that here.
As long as the second shipment charge doesn't happen to go out earlier than the 7 days this would prevent any authorizations overlapping resulting in holds of more than the initial amount at any given moment. I would treat almost any transaction like this apple pay or not.

Rails & Stripe: Is it possible to let user pay an amount monthly until they completed the amount?

For example the user needs to pay $2000,
and I want to let them pay the $2000 in 5 months, and then complete the payment not charge them anymore.
This is the closes I have came close to, please let me know if this is wrong:
1- Create Subscription plans for the amounts of payment.
2- Creating a delayed job to cancel the subscription after the 5 month.
Will this be risky to do so ?
Thanks,
Yes, that's exactly how you'd want to handle it. To be more detailed...
First, you'll need to have a web hooks endpoint:
https://stripe.com/docs/webhooks
Next, you'll want to subscribe the customer to a plan like normal. We'll notify your site, via the web hooks, of when payments are made on a recurring subscription. Specifically, you'll want to watch for invoice.payment_succeeded events:
https://stripe.com/docs/api#event_types
Once a specific customer has hit the right number of payments (which you'll track on your end), you'd then issue a cancel subscription request:
https://stripe.com/docs/api#cancel_subscription
Hope that helps!
Larry
PS I work on Support at Stripe.

Resources