Can I charge a variable amount to Stripe as a subscription? - php

I want to use the Stripe API to bill users every month for an amount they specify. It appears that Stripe does not allow websites to create a subscription without first setting up a plan for it manually, restricting what people can bill themselves for to predesignated amounts.
What is the best way to do this?

You can! Before we talk more about how this works in practice, make sure you understand when an invoice is open for modification.
Subscribing your customer to a new plan, or updating your customer's existing subscription
If you are subscribing your customer to a plan via the API, you won't be able to add any custom fees after the initial invoice is created since it will be immediately closed. This means you'll need to setup any custom amounts before the initial invoice is created. You can do this in one of two ways:
Set the account_balance when creating a customer or updating a customer's subscription.
Create any invoice items before your customer is subscribed to the plan, and then create the subscription via an update customer subscription call.
In either case, we'll pull the account balance or any outstanding invoice items into the initial invoice, so your customer will still be charged for the setup fees. These are essentially one-time charges that you are combining with the subscription's recurring charges. Since these are being added to the invoice total, only a single charge is being created.
Subscription renewals
The account balance and invoice items are simply one-time adjustments to your customer's account, so they won't be automatically applied each month. If your service uses metered billing or needs to add custom amounts for taxes or other dynamic costs, then you will need to create invoice items every month.
To get started, just use webhooks to listen for the invoice.created event. Whenever an invoice is open for modification, your webhook endpoint can create an invoice item that references the existing invoice's ID. We'll automatically pull this amount into the invoice total before charging your customer, approximately an hour after the invoice's creation.
Link:
https://support.stripe.com/questions/metered-subscription-billing

Related

Multiple products in single charge Stripe?

My use case is that I have multiple products some of which are one time payment and others are recurring payment products. I want to charge the user only once so that the user doesn't have to pay for each product separately. According to my study we can create multiple product subscriptions with one charge. https://stripe.com/docs/billing/subscriptions/multiple-products#creating
If I had one-time payment products only, I can only receive one payment of the payment amount for selected products (as sum of prices).
But as I have mentioned I have some products which are recurring payment. So my question is if I add one-time payment products in this subscription request will they be charged again ones the recurring period overs, and if yes how can I Implement the above case in PHP?
Note: I want to implement this in custom form. I don't want to be redirected to stripe page.
You can use Stripe Checkout and combine both one-time and recurring prices3.
You can follow this guide in order to integrate Stripe Checkout with PHP.
Here what it will looks like for combining both prices types, the first charge will be for both pricing, and the second charge will be just for the recurring price(s):

Temporary Stripe subscription price

I've been asked to integrate Stripe API's for a subscription plan.
I've already worked with it, but never with a variable price :
I have to make a subscription with a "trial price" and then, the month after, change the price.
Here, the user wil pay 19 euros the first month, and then 25 euros each month. But, I can't see any options to manage it ?
Do you have a clue ?
Thanks !
Your best approach is to discount their first invoice.
Coupons in Stripe provide discounts on recurring charges. Like subscriptions, coupons allow for great flexibility in how you define and use them. They can:
Apply to every invoice, just one invoice, or for a certain length of time
https://stripe.com/docs/billing/invoices/subscription#first-invoice-extra
Should you need to include a one-time charge or discount to the first subscription invoice, you can do so by adding an invoice item to the customer before creating the subscription. (The above code would work, as it doesn’t specify an invoice.) The resulting invoice item will be attached to the customer and automatically included in the first invoice created.

Store Stripe payment history

I have integrated stripe in to my application.
Now i want to store the payment history in to my database.
Using stripe APIs, i can create new subscription as well as update that subscription.
Now say i have one subscription for one month for $20 and after few days i am updating to sixmonth for $60. So as per stripe logs it will deduct $40 while updating plan.
I want to store all these payment process along with subscription periods in to my database.
How can i do that. Is that any API for it?
You can use webhooks to get notification from Stripe whenever any event happen.
So you need to create a webhook for charge.succeeded. So that you can get notification for all the successful charges happen. You can get amount, customer data inside the event data which you can store to your DB. I assume you are already storing subscription along with customer, so that you can map subscription from customer data from event data.

Proper way to create dynamic automatic billing method with paypal API?

I know this maybe a duplicate but due to the overwhelming amount of paypal APIs I am having a hard time finding a GOOD answer to my question.
I need to create variable monthly billing per user in PHP. The idea is that a user could sell a number of items with a total sum of sales at the end of the month p. So the billing would be something of the extent MY_PERCENTAGE_FEE * p. The user would then be sent an invoice, and a would be automatically billed via paypal for that amount.
Now, it would be SUPER great if this could be done by creating reoccurring billing and updating the amount at the end of the month. Is that possible? If not what would be the next best way to go?
If you're creating recurring profiles with Payments Pro you can adjust those without any limits. Unfortunately, with Express Checkout you're limited to raising the amount by only 20% every 180 days, so that doesn't normally work out very well. You have a few options of how to get around that.
1) Utilize billing agreements with Express Checkout and Reference Transactions. This would allow you to run an authorization (or an original sale of some sort) for a payer and then from that point on you can use that transaction ID from the original transaction along with a new amount in the DoReferenceTransaction API. Reference Transactions area available with Payments Pro by default, but if you want to use them with Express Checkout you'll need to get that specifically enabled on your account.
2) Use the Preapproval API, which is part of the Adaptive Payments platform. This is similar to reference transactions except that you can create preapproved rules by which you can bill your payers at any time without further approval. This would allow you to process payments for them at any time you need to and pull variable amounts accordingly.
3) Use the Pay API, which is also part of Adaptive Payments, with a split payment (parallel or chained) which would allow you to take your cut in real-time without the need to track balances and submit variable recurring payments. Each time one of your customers is paid for their product/service, you would immediately be paid your share.

Using Paypal API's to process conditional rental payments using PHP

I am building an eCommerce site which gives a user the ability to rent
an item for a designated amount of time. If the item is not returned
within that time, the customer is billed automatically for another rent
cycle. If the item is returned the customer will stop getting billed
for additional rent cycles. If the item is bought the customer will be
billed and an additional amount different from the rent price will be
billed to the customer and the customer will no longer be billed for
additional rent. Most of the billing is ongoing and has too many
variables going on to just have a simple subscription payment method.
I think the sequence of transactions can be initiated with a simple PayPal button form which sends information about my IPN script location, Cancel Payment script location and recurring payment script location.
I find that there are some limitations of what PayPal's API's can do. It seems that the recurring payments API is set up for an amount of set payments set over a specified billing period over a set number of times a customer would be billed. I am not 100% sure on this but I think PayPal only accesses the recurring payment API for a customer once for the initial transaction and executes the continuous transactions without checking my websites internal database which might give data to influence parts of the recurring payment script to cancel continuous payments. An example of when this condition should occur is when a customer returns a product or purchases a product which was already being rented out. PayPal has been terrible at getting back to me about technical problems like this. Another problem with PayPal's recurring payments API is a recurring payment subscription cannot be longer than a year so if a customer is renting an item for 2 years then they would only be charged for the first year.
Any advice on how I can implement a payment system like this using PayPal, if it is even possible would be greatly appreciated. I don't want to have make my own payment gateway if PayPal can do this.

Categories