/**
  * Create recurring payment profiles for any recurring invoices in the purchase
  * @param  SI_Invoice $invoice
  * @param  SI_Payment $payment
  * @return void
  */
 private function maybe_create_recurring_payment_profiles(SI_Invoice $invoice, SI_Payment $payment)
 {
     if ($payment->get_payment_method() != $this->get_payment_method()) {
         return false;
     }
     $data = $payment->get_data();
     if (!isset($data['payment_token'])) {
         // a payment token is needed
         return false;
     }
     if (si_is_invoice_recurring($invoice)) {
         $this->create_recurring_payment_profile($invoice, $payment);
     }
 }
 /**
  * Create recurring payment profiles for any recurring invoices in the purchase
  * @param  SI_Invoice $invoice
  * @param  SI_Payment $payment
  * @return void
  */
 private function maybe_create_recurring_payment_profiles(SI_Checkouts $checkout, SI_Invoice $invoice, SI_Payment $payment)
 {
     if ($payment->get_payment_method() != $this->get_payment_method()) {
         return false;
     }
     if (si_is_invoice_recurring($invoice)) {
         $this->create_recurring_payment_profile($checkout, $invoice, $payment);
     }
 }
 /**
  * Process a payment
  *
  * @param SI_Checkouts $checkout
  * @param SI_Invoice $invoice
  * @return SI_Payment|bool FALSE if the payment failed, otherwise a Payment object
  */
 public function process_payment(SI_Checkouts $checkout, SI_Invoice $invoice)
 {
     // Recurring
     if (si_is_invoice_recurring($invoice)) {
         $this->create_recurring_payment_plan($checkout, $invoice);
         $charge_reciept = $this->add_customer_to_plan($checkout, $invoice);
     } else {
         // default
         $charge_reciept = $this->charge_stripe($checkout, $invoice);
     }
     do_action('si_log', __CLASS__ . '::' . __FUNCTION__ . ' - Stripe Response', $charge_reciept);
     if (!$charge_reciept) {
         return false;
     }
     $payment_id = SI_Payment::new_payment(array('payment_method' => self::PAYMENT_METHOD, 'invoice' => $invoice->get_id(), 'amount' => self::convert_cents_to_money($charge_reciept['amount']), 'data' => array('live' => self::$api_mode == self::MODE_LIVE, 'api_response' => $charge_reciept)), SI_Payment::STATUS_AUTHORIZED);
     if (!$payment_id) {
         return false;
     }
     // Go through the routine and do the authorized actions and then complete.
     $payment = SI_Payment::get_instance($payment_id);
     do_action('payment_authorized', $payment);
     $payment->set_status(SI_Payment::STATUS_COMPLETE);
     do_action('payment_complete', $payment);
     // Return the payment
     return $payment;
 }