My application structure is as follows:
orders table
order_id subscription_id
1 sub_AXXXXX
2 sub_BXXXXX
payments table
pid order_id payment_status date charge_id
1 1 complete 1 May 2020 ch_XXXXX
2 1 pending 2 June 2020
3 1 pending 3 July 2019
4 2 complete 1 April 2020 ch_XXXXX
5 2 complete 1 May 2020
6 2 pending 1 June 2020
- I know you create first create stripe customer(you get $customer->id)
- Then create product(you get $product->id)
- Then create plan
$plan = Plan::create(['currency' => 'usd', 'interval' => 'month', 'product' => $product->id,interval_count': 3, 'amount' => 10 ]);
Then I create subscription with
"customer" => $customer->id,'plan' => $plan, 'metadata' => [ 'order_id' => $order_id, ],'prorate' => false
Question 1 How can I check from stripe for the order_id/subscription_id, how many payment charges were made success out of 3 for order_id 1.
Do I need to query all invoices for the subscription to do this. But how can you determine which month payment was made and failed ones other than looping through dates. Does stripe update interval_count for the plan anywhere if the payment is success for each month.
Question 2 How can I check if any payments failed case: If payment failed for pid 2, how can I show this.
I really do not want to use/rely web shook events for various reasons.