Laravel条纹和收银员没有这种付款方式

时间:2020-08-03 07:05:32

标签: javascript jquery laravel stripe-payments laravel-cashier

我正在使用Laravel 7,并且将条纹与收银员集成在一起,因此我面临问题

No such PaymentMethod: 'tok_1HBxFdEft5GkDC4v7ZnPgW5Y'

我正在使用自定义结帐表单html代码是

<form class="rt-formtheme rt-paymentmethodform" method="POST" action="{{route('subscripe.process')}}" id="subscribe-form">
                    @csrf
                    <div class="div-stripe-errors col-12" style="margin-top: 30px;"></div>
                    <fieldset>
                        <legend>Choose your card</legend>
                        <!-- <div class="form-group">
                            <button type="submit" class="rt-btn rt-savebtn">Save</button>
                        </div> -->
                        <div class="form-group">
                            <span class="rt-radio">
                                <input type="radio" name="radiobutton" id="visa">
                                <label for="visa"><img src="{{asset('images/visa.png')}}"  alt=""></label>
                            </span>
                        </div>
                        <div class="form-group">
                            <span class="rt-radio">
                                <input type="radio" name="radiobutton" id="american-express">
                                <label for="american-express"><img src="{{asset('images/american-express.png')}}"  alt=""></label>
                            </span>
                        </div>
                        <div class="form-group">
                            <label>Card Number</label>
                            <input type="text" name="cardnumber" class="form-control" placeholder="1234 5678 9012 3456" data-stripe="number">
                        </div>
                        <div class="rt-twocols">
                            <div class="form-group">
                                <div class="rt-twoinputfieldholder">
                                    <div class="rt-twoinputfieldbox">
                                        <label>Expiry Month</label>
                                        <input type="text" name="expirymonth" class="form-control" placeholder="MM" data-stripe="exp-month">
                                    </div>
                                    <div class="rt-twoinputfieldbox">
                                        <label>Expiry Year</label>
                                        <input type="text" name="expiryyear" class="form-control" placeholder="YY" data-stripe="exp-year">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label>CVC</label>
                                <input type="text" name="cvv" class="form-control" placeholder="123" data-stripe="cvc">
                            </div>
                        </div>
                        <div class="form-group margin-zero rt-savecarddetailbox">
                            <span class="rt-checkbox">
                                <input type="checkbox" name="savecarddetail" id="savecarddetail">
                                <label for="savecarddetail">Save Card Details</label>
                            </span>
                            <button type="submit" class="rt-btn float-right">Checkout</button>
                        </div>
                    </fieldset>
                </form>

而js代码是

<script src="https://js.stripe.com/v2/"></script>
<script>
Stripe.setPublishableKey('{{ env("STRIPE_KEY") }}');
$(document).ready(function(){
    $('#subscribe-form').submit(function(e){
        
        var form = $(this);
        
        form.find('button').prop('disabled', true);

        Stripe.card.createToken(form, function(status, response) {
            if (response.error) {
                form.find('.div-stripe-errors').text(response.error.message).addClass('alert alert-danger');
                form.find('button').prop('disabled', false);
            } else {
                // append the token to the form
                form.append($('<input type="hidden" name="cc_token">').val(response.id));
                // debugger
                // submit the form
                form.get(0).submit();
            }
        });

        e.preventDefault();
    });
});

路线是

    Route::post('/subscribe_process', 'Dashboard\CheckoutController@subscribeProcess')->name('subscripe.process');

和控制器方法是

public function subscribeProcess(Request $request)
{
    try{
        $cc_token = $request->cc_token;
        $user = Auth::user();
        $user->newSubscription('Main','Monthly')->create($cc_token);
        alert()->success('User Updated Successfully', 'Success');
        return \redirect()->back();
    }catch(\Exception $ex){
        return $ex->getMessage();
    }
}

,我也在条纹仪表板上创建计划 enter image description here

创建订阅时显示错误没有这样的付款方式,我是条纹新手,请帮忙

1 个答案:

答案 0 :(得分:0)

“无此类...”错误通常是由于API密钥不匹配(例如,使用测试键和实时密钥的组合)或尝试访问存在于不同帐户中的对象(例如,尝试执行平台帐户对在关联帐户上创建的对象的操作)。