예제 #1
0
 public function export_donors_csv()
 {
     // CSV download headers
     $start_time = !empty($_REQUEST['start']) ? $_REQUEST['start'] : time() - 60 * 60 * 24 * 30;
     $end_time = !empty($_REQUEST['end']) ? $_REQUEST['end'] : strtotime('today');
     $params = array('start' => $start_time, 'end' => $end_time + 60 * 60 * 24);
     $start = date('Y-m-d', $start_time);
     $end = date('Y-m-d', $end_time);
     header('Content-Type: text/csv; charset=UTF-8');
     header('Content-Disposition: attachment; filename="StripeDonations-' . $start . '--' . $end . '.csv"');
     $items = \adz_stripe_donations\CustomSave::get_result_set($params, false);
     // error_log(var_export($items,1));
     include_once realpath(dirname(__FILE__) . '/../views/admin_export_donors_csv.php');
     // die();
 }
function adz_stripe_donations_activate()
{
    \adz_stripe_donations\CustomSave::activate();
}
예제 #3
0
 public function save_stripe_charge($stripe)
 {
     \Stripe\Stripe::setApiKey($this->stripe_private_key);
     // $stripe = $stripe_response->jsonSerialize();
     $charge_obj = $stripe['data']['object'];
     $charge_data = array();
     $charge_data['stripe_id'] = $charge_obj['id'];
     $charge_data['currency'] = $charge_obj['currency'];
     $charge_data['amount'] = $charge_obj['amount'];
     $charge_data['created'] = $charge_obj['created'];
     $bt = \Stripe\BalanceTransaction::retrieve($charge_obj['balance_transaction']);
     $charge_data['amount_converted'] = $bt->amount;
     if ($charge_obj['source']['customer']) {
         $stripe_id = $charge_obj['source']['customer'];
     } else {
         $stripe_id = $charge_obj['id'];
     }
     \adz_stripe_donations\CustomSave::save_stripe_charge_detail($charge_data, $stripe_id);
 }