コード例 #1
0
 function save_extra_data($response)
 {
     // \Stripe\Stripe::setApiKey($this->stripe_private_key);
     $stripe = $response['stripe'];
     $customer_data = array();
     $extra_fields = array();
     foreach ($_POST['customer'] as $key => $value) {
         $extra_fields[$key] = htmlspecialchars($value);
     }
     $customer_data['extra_fields'] = json_encode($extra_fields);
     $customer_data['plan'] = htmlspecialchars($_POST['plan']);
     $customer_data['created'] = $response['created'];
     $customer_data['email'] = htmlspecialchars($_POST['email']);
     $customer_data['name'] = htmlspecialchars($_POST['cc-name']);
     if (isset($_POST['giftaid'])) {
         $customer_data['giftaid'] = 1;
     } else {
         $customer_data['giftaid'] = 0;
     }
     // no longer saving the charge in this step  - as it doesn't work for repeated payments - going to rely on Stripe webhooks
     if ($stripe['object'] == 'customer') {
         $customer_data['stripe_type'] = 'customer';
         $customer_data['stripe_id'] = $stripe['id'];
     } else {
         $customer_data['stripe_type'] = 'charge';
         $customer_data['stripe_id'] = $stripe['id'];
     }
     \adz_stripe_donations\CustomSave::save_donor_detail($customer_data);
 }