I am required to get the records of all the customers in a day from Stripe and store the records in the MySQL database table. I am able to fetch the records from Stripe and can store them in the table too. However, I want the task to be automatic and get the task done at a specific time in a day. Any suggestions?
Asked
Active
Viewed 98 times
0
-
1You can use an `Event` - [Event Scheduler](https://dev.mysql.com/doc/refman/5.7/en/event-scheduler.html) and [creating an event](https://dev.mysql.com/doc/refman/8.0/en/create-event.html) – Professor Abronsius Mar 29 '21 at 12:14
-
Is it possible with MySQL event scheduler or will it require other libraries? – Anil Mar 29 '21 at 12:19
-
If you need to fetch the data from an external third party then perhaps you need to use [CRON](https://stackoverflow.com/questions/18737407/how-to-create-cron-job-using-php) – Professor Abronsius Mar 29 '21 at 12:36
-
Actually, I have to fetch data from Stripe API and store the data in a database table – Anil Mar 29 '21 at 12:44
1 Answers
0
Are you open to the idea of implementing a simple application that Stripe can send webhook events to? If so, you can listen to the customer.created
event. This way you can add a new record in your database as soon as a Customer is created.
If not, use the List all Customers
API and supply the created
parameter: https://stripe.com/docs/api/customers/list#list_customers-created but this will be slightly more tedious as you'll need to paginate, since you can only retrieve 100 Customers
per API call. To paginate, supply the starting_after
and ending_before
parameters. You'll also need to configure your cronjob to run at the timing that you desire.

Zhi Kai
- 1,549
- 1
- 13
- 31