public function refund()
 {
     $orderId = $this->request->input('orderId', '');
     $order = $this->order->find($orderId);
     $transacrtionId = $order->transaction_id;
     \Stripe\Stripe::setApiKey("sk_test_I561ILtdEXsIVDoAc9169tcC");
     $re = \Stripe\Refund::create(array("charge" => $transacrtionId));
     $order->order_status = "refunded";
     $order->save();
     $this->sendRefundMail($orderId);
 }
Пример #2
0
                $cu = \Stripe\Customer::retrieve($user["stripe_cust_id"]);
                $cu->source = $token;
                $cu->save();
            }
            $_SESSION["new-card"] = true;
        }
        if ($_POST["action"] == "modify") {
            $registrants = $_POST["registrants"];
            $price_in_cents = $unit_price * $registrants * 100;
            $modify = registerUser($event["event_id"], $user["user_id"], $registrants, $stripe_charge_id, true);
            $_SESSION["modified"] = $registrants;
        }
        //
        // if a charge exists refund it
        if ($paid) {
            $refund = \Stripe\Refund::create(array("charge" => $stripe_charge_id));
            $_SESSION["refund"] = $refund["amount"] / 100;
        }
        // if a charge existed before the refund, or if a new card was just accepted, or if an existing card is to be charged, create a new charge
        if ($paid || $_POST["action"] == "new-card" || $_POST["action"] == "cc-on-file") {
            createEventCharge($user, $event, $price_in_cents, $registrants);
            $_SESSION["payment"] = $price_in_cents / 100;
            $_SESSION["registrants"] = $registrants;
        }
    }
    header("Location:/user/events/" . $event["event_id"] . "/");
} else {
    ?>
<html>
<?php 
    include ROOT_PATH . "inc/head.php";
Пример #3
0
 /**
  * Retrieve stripe refund
  *
  * @param string $id
  *
  * @return \Stripe\Refund
  */
 public function retrieve($id)
 {
     return StripeRefundApi::retrieve($id);
 }
Пример #4
0
 /**
  * Refund a customer for a charge.
  *
  * @param $charge
  * @param array $options
  *
  * @return StripeRefund
  */
 public function refund($charge, array $options = [])
 {
     $options['charge'] = $charge;
     return StripeRefund::create($options, ['api_key' => $this->getStripeKey()]);
 }
Пример #5
0
 public function postRefund(Request $request)
 {
     $transaction_id = $request->get('id');
     $error = '';
     $transaction_details = \App\Models\ProjectFund::findOrFail($transaction_id);
     $getProjectReceiverAccount = \App\Models\Project::where('id', $transaction_details->P_ID)->first();
     $getReceiverAccount = $getProjectReceiverAccount->user_id ? \App\Models\ReciverAccount::where('user_id', $getProjectReceiverAccount->user_id)->first() : Null;
     //dd($getReceiverAccount->secret_key);
     if ($getReceiverAccount->secret_key) {
         \Stripe\Stripe::setApiKey($getReceiverAccount->secret_key);
     }
     try {
         $paid_amount = $transaction_details->paid_amount * 100;
         $refund = \Stripe\Refund::create(array('amount' => $paid_amount, 'charge' => $transaction_details->transaction_id));
         //dd($refund->toArray());
         //updatating local table
         $cashWithDrawaldRequest = new \App\Models\CashWithdrawalsRequest();
         $cashWithDrawaldRequest->user_id = $getProjectReceiverAccount->user_id;
         $cashWithDrawaldRequest->status = 'request';
         $cashWithDrawaldRequest->project_fund_id = $transaction_id;
         if ($cashWithDrawaldRequest->save()) {
             $request->session()->flash('alert-success', 'Request for charge refunding is successfully posted . ');
             //return response(['msg' => 'success'   ]);
             return \Redirect::to('home/project-backed')->with('msg', 'success');
         } else {
             $request->session()->flash('alert-success', 'Request for charge refunding is not processed !');
             //return response(['msg' => 'failure'   ]);
             return \Redirect::to('home/project-backed')->with('stripe_errors', $error['message']);
         }
         ///update
     } catch (Exception $e) {
         //  dd("a");
         $e_json = $e->getMessage();
         $error = $e_json['error'];
         return response(['msg' => 'failure']);
         //return \Redirect::to('home/project-backed')->with('stripe_errors',$error['message'])	;
     }
     //dd($refund->_lastResponse);
 }
Пример #6
0
$member_price = $event["member_price"];
$nonmember_price = $event["nonmember_price"];
if ($event["max_attendees"] == 0) {
    $max = "";
} else {
    $max = $event["max_attendees"];
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // process the event change
    if (password_verify($_POST["admin-password"], $admin["password"])) {
        if ($_POST["action"] == "delete") {
            $registrations = deleteEvent($event["event_id"]);
            foreach ($registrations as $registration) {
                // refund the charge
                if (!empty($registration["stripe_charge_id"])) {
                    $refund = \Stripe\Refund::create(array("charge" => $registration["stripe_charge_id"]));
                }
                // unregister the user
                unregisterUser($registration["event_id"], $registration["user_id"]);
            }
            deleteEvent($event["event_id"], true);
            $_SESSION["deleted"] = $event["name"];
            header("Location:/admin/events/");
        } elseif ($_POST["action"] == "edit") {
            $edit = editEvent($event["event_id"], $_POST["name"], str_replace(array("\r\n", "\r", "\n"), "<br>", $_POST["description"]), $_POST["date"], $_POST["start-time"], $_POST["end-time"], $_POST["member-price"], $_POST["nonmember-price"], $_POST["max"]);
            var_dump($edit);
            $_SESSION["event-edited"] = true;
            header("Location:/admin/events/edit/" . $event["event_id"] . "/");
        }
    } else {
        $_SESSION["incorrect-password"] = true;
Пример #7
0
 /**
  *
  * {@inheritDoc}
  *
  * @see \PhalconRest\Libraries\Payments\Processor::chargeCard()
  */
 public function refundCharge($data)
 {
     try {
         $result = \Stripe\Refund::create(array('charge' => $data['charge_id']));
         return $result->id;
     } catch (\Stripe\Error\Base $e) {
         $this->handleStripeError($e);
     }
 }