Last active
August 30, 2016 00:04
-
-
Save flexgrip/0880c5b6c2ebd9a4a8e60d2b325bb95e to your computer and use it in GitHub Desktop.
StripePullByDate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while ($charges['has_more']) { | |
$charges = $stripe->getChargesByDate($start_date, $starting_after); | |
foreach($charges["data"] as $charge) { | |
// DEBUG | |
Log::info($charges['has_more']); | |
// Reset the data for the pager. Have to do this first in case we skip a dirty record. | |
$starting_after = $charge['id']; | |
$crm_id = $charge['customer']; | |
$amount = $charge['amount'] / 100; | |
$created_at = $charge['created']; | |
if(!$charge['customer'] || $charge['status'] == "failed" || $charge['status'] == "pending") { | |
Log::info("Starting after: " . $charge['id']); | |
//Log::info("No customer attached to this stripe charge. Aborting."); | |
//continue; | |
} // If there's no customer bound to the charge, skip it. | |
elseif(!$amount || !$crm_id || !$created_at) { | |
Log::error($this->date->toDateString() . ' could not process order: ' . json_encode($charge)); | |
} else { | |
$payment = new Payment(); | |
$payment->crm_id = $crm_id; | |
$payment->amount = $amount; | |
$payment->created_at = $created_at; | |
$payment->user_id = $this->user->id; | |
$payment->td_db = $this->user->td_db; | |
$payment->save(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment