芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/thefirstcookout.com/support/application/libraries/APPStripe.php
hasAdminSettingsAccess()) { AddOnManager::AddFilter("admin-menu-payment-list", [$this, "AdminMenu"]); } AddOnManager::AddFilter("payment-method-icon",function($methods){ $methods['S']=" ap ap-stripe"; return $methods; }); AddOnManager::AddFilter("payment-method-color",function($methods){ $methods['S']=" stripe-color text-bold"; return $methods; }); AddOnManager::AddAction('process-payment-stripe', [$this, "process_payment"], 10, 3); AddOnManager::AddAction('action-stripe-response', [$this, "stripe_response"], 10, 2); \Stripe\Stripe::setApiKey($this->GetSettingsValue("secret")); } /** * @param AppMenu $menuObj */ public function AdminMenu($menuObj){ $menuObj->AddSubMenu("AD", "Stripe Setting", "admin/addons/admin-page/stripe", "ap ap-stripe"); return $menuObj; } public function get_supported_currency() { return ['ARS','AUD','BRL','GBP','CAD','CNY','CZK','DKK','EUR','HKD','HUF','INR','ILS','JPY','MXN','TWD','NZD','NOK','PLN','RUB','SGD','ZAR','KRW','SEK','CHF','THB','TRY','UAH','USD']; } public function is_supported_currency($currency) { return true; } function isActive() { return $this->GetSettingsValue("is_enable","N")=="Y"; } /** * @param String $payment_id * @param Mticket_payment $payment_obj * @param APP_Controller $controller */ public function process_payment($payment_id,$payment_obj,$controller){ $name=""; $email=""; $ticket=Mticket::FindBy("id",$payment_obj->ticket_id); if(!empty($ticket)){ $user=Msite_user::FindBy("id",$ticket->ticket_user); if(!empty($user->user_type =="U")){ $name=$user->first_name.' '.$user->last_name; $email=$user->email; } } ?>
ticket_id}/{$payment_obj->reply_id}/{$payment_obj->id}"),array("class"=>"","id"=>"stripe-payment","method"=>"post"));?>
ticket_id}/{$payment_obj->reply_id}/{$payment_obj->id}"); $cancel_url=site_url("site/action/stripe-response/C/{$payment_obj->ticket_id}/{$payment_obj->reply_id}/{$payment_obj->id}"); $session = \Stripe\Checkout\Session::create([ 'payment_method_types' => ['card'], 'line_items' => [[ 'price_data' => [ 'unit_amount' => (int)($payment_obj->amount*100), 'currency' => $payment_obj->payment_currency, 'product_data' => [ 'name' => "Ticket Payment", 'description' => $payment_obj->payment_des, 'images' => ['https://example.com/t-shirt.png'], ], ], 'quantity' => 1, ]], 'mode' => 'payment', 'success_url' => $success_url, 'cancel_url' => $cancel_url, ]); ?>
DisplayMSGOnly("Invalid request param"); return; } $ticket_id=$params[1]; $reply_id=$params[2]; $payment_id=$params[3]; if(isset($_POST['stripeToken'])){ $payment_obj = Mticket_payment::FindBy("id", $payment_id, ["ticket_id" => $ticket_id, "reply_id" => $reply_id]); if (!$payment_obj) { $controller->DisplayMSGOnly("Process Failed"); return; } try { $charge = \Stripe\Charge::create([ 'description' => $payment_obj->payment_des, 'amount' => (int)($payment_obj->amount * 100), 'currency' => strtolower($payment_obj->payment_currency), 'source' => $_POST['stripeToken'] ]); $customer_name = $charge->source->name; $ticket=Mticket::FindBy("id",$payment_obj->ticket_id); if(!empty($ticket)){ $user=Msite_user::FindBy("id",$ticket->ticket_user); if(!empty($user->user_type =="U")){ $customer_name=$user->first_name.' '.$user->last_name; $email=$user->email; } } $card_or_payment_email = "****-****-****-".$charge->source->last4; $total_amount = sprintf("%.2f",($charge->amount_captured/100)); $transaction_id = $charge->id; $transaction_time = date('Y-m-d H:i:s',$charge->created);; $approval_code =$charge->balance_transaction; $resull_msg = $charge->captured==1?"captured":""; $country = $charge->source->country; if (Mticket_payment::CompletePayment($payment_obj,$customer_name,$card_or_payment_email,$total_amount,$transaction_id, $transaction_time,$approval_code,$resull_msg,$country,"S")) { $controller->DisplayMSGOnly("Payment success", site_url("ticket/details/{$payment_obj->ticket_id}"), 10, true); return; } else { Mdebug_log::AddPaypalLog("Paypal Payment Error for id({$payment_obj->ticket_id}-{$payment_obj->reply_id}-{$payment_obj->id})", Mdebug_log::STATUS_FAILED, Mdebug_log::ENTRY_TYPE_ERROR, current_url()); $controller->DisplayMSGOnly("Payment failed. Please try again later"); return; } }catch (Exception $ex){ $controller->DisplayMSGOnly("Payment failed. Please try again later"); return; } }else{ $controller->DisplayMSGOnly("Invalid request"); return; } } public function getTitle() { return "Stripe"; } public function getButtonImageHTML() { return '
'; } public function AdminSettings($controller,$args){ $controller->SetTitle("Stripe Settings"); ?>
getUpdateUrl(),array("class"=>"form app-ajax-form form-horizontal","id"=>"app_basic_form","method"=>"post", "data-on-complete"=>"ajax_default_complete"));?>
GetPostValue("is_enable","N")=="Y"?' checked="checked"':'';?> value="Y" class="has_depend_fld" id="is_enable" name="is_enable" >
GetPostValue("is_test_mode","N")=="Y"?' checked="checked"':'';?> value="Y" class="has_depend_fld" id="is_test_mode" name="is_test_mode" >
" class="form-control" id="publisher_key" name="publisher_key" placeholder="" data-bv-notempty="true" data-bv-notempty-message="Publishable key ">
Secret
" class="form-control" id="secret" name="secret" placeholder="" data-bv-notempty="true" data-bv-notempty-message="Secret ">
Instruction for Stripe details :
Go to Dashboard
Then go to developers
Then go to API Keys
You will get your information