fixed bkstripe view
This commit is contained in:
parent
4b8e4f839e
commit
080cceba88
|
|
@ -13,6 +13,7 @@ namespace Beike\Shop\Services;
|
|||
|
||||
use Beike\Models\Order;
|
||||
use Beike\Repositories\OrderRepo;
|
||||
use Illuminate\View\View;
|
||||
use Stripe\Customer;
|
||||
use Stripe\Exception\ApiErrorException;
|
||||
use Stripe\Stripe;
|
||||
|
|
@ -37,47 +38,34 @@ class PaymentService
|
|||
if (empty($this->order)) {
|
||||
throw new \Exception("无效订单");
|
||||
}
|
||||
if ($this->order->status != 'unpaid') {
|
||||
throw new \Exception('订单已支付');
|
||||
}
|
||||
$this->orderId = (int)$this->order->id;
|
||||
$this->paymentMethodCode = $this->order->payment_method_code;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
if ($this->paymentMethodCode == 'bk_stripe') {
|
||||
$apiKey = setting('bk_stripe.secret_key');
|
||||
Stripe::setApiKey($apiKey);
|
||||
// Stripe::setApiVersion('2020-08-27');
|
||||
|
||||
/**
|
||||
* $customer = $stripe->customers()->create([
|
||||
* 'email' => $this->order->email,
|
||||
* ]);
|
||||
*
|
||||
* $customers = $stripe->customers()->all();
|
||||
*
|
||||
* $charge = $stripe->charges()->create([
|
||||
* 'customer' => $customer['id'],
|
||||
* 'currency' => 'USD',
|
||||
* 'amount' => 50.49,
|
||||
* ]);
|
||||
**/
|
||||
|
||||
return view("checkout.payment.{$this->paymentMethodCode}", ['order' => $this->order]);
|
||||
// echo $charge['id'];
|
||||
} else {
|
||||
return view('没有支付方式');
|
||||
$orderPaymentCode = $this->paymentMethodCode;
|
||||
$viewPath = "checkout.payment.{$this->paymentMethodCode}";
|
||||
if (!view()->exists($viewPath)) {
|
||||
throw new \Exception("找不到Payment{$orderPaymentCode}view{$viewPath}");
|
||||
}
|
||||
$paymentView = view($viewPath, ['order' => $this->order])->render();
|
||||
return view('checkout.payment', ['order' => $this->order, 'payment' => $paymentView]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws ApiErrorException
|
||||
*/
|
||||
public function capture($creditCardData): bool
|
||||
{
|
||||
if ($this->order->status != 'unpaid') {
|
||||
throw new \Exception('订单已支付');
|
||||
}
|
||||
$apiKey = setting('bk_stripe.secret_key');
|
||||
Stripe::setApiKey($apiKey);
|
||||
$token = Token::create([
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
@extends('layout.master')
|
||||
|
||||
@section('body-class', 'page-bk-stripe')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-md-9">@include('shared.steps', ['steps' => 4])</div>
|
||||
</div>
|
||||
|
||||
{!! $payment !!}
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -1,27 +1,9 @@
|
|||
@extends('layout.master')
|
||||
|
||||
@section('body-class', 'page-bk-stripe')
|
||||
<script src="{{ asset('vendor/vue/2.6.14/vue.js') }}"></script>
|
||||
<script src="{{ asset('vendor/element-ui/2.15.6/js.js') }}"></script>
|
||||
<link rel="stylesheet" href="{{ asset('vendor/element-ui/2.15.6/css.css') }}">
|
||||
|
||||
@push('header')
|
||||
<script src="{{ asset('vendor/vue/2.6.14/vue.js') }}"></script>
|
||||
<script src="{{ asset('vendor/element-ui/2.15.6/js.js') }}"></script>
|
||||
<link rel="stylesheet" href="{{ asset('vendor/element-ui/2.15.6/css.css') }}">
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="container" id="bk-stripe-app" v-cloak>
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">Library</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-md-9">@include('shared.steps', ['steps' => 4])</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-5">
|
||||
<div class="row mt-5" id="bk-stripe-app" v-cloak>
|
||||
<div class="col-12 col-md-8">
|
||||
<div class="checkout-black">
|
||||
<h5 class="checkout-title">卡信息</h5>
|
||||
|
|
@ -84,9 +66,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@push('add-scripts')
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#bk-stripe-app',
|
||||
|
|
@ -133,4 +113,4 @@
|
|||
}
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue