要在vue.js Messenger中发送付款链接?

时间:2019-06-18 19:16:50

标签: php vue.js

在我们的网络应用程序上,其想法是可以通过使用vue.js制作的Messenger打开交易。该网站是使用Laravel构建的,我正在使用控制器来创建付款消息。但是,我无法使自动发送的付款链接成为单击的实际链接,它仅显示一些文本。我们正在使用条纹付款。

HTML:


<div class="col-md-10 col-sm-10 text-md-left text-center">
                <div class="container padding_bottom" id="messenger">
                    <div class="row justify-content-center">
                        <div class="col-sm-12">
                            <div class="card">
                                <div class="card-header">Messenger</div>

                                <div class="card-body" id="app">
                                    <chat-app :user="{{ auth()->user() }}"></chat-app>             
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

PHP(创建消息的函数):


public function sendPaymentRequest(Request $request)
    {   
        $url;
        if ($_SERVER['REMOTE_ADDR'] == "127.0.0.1") {
            $url = "127.0.0.1:8000/pay?a=" . $request->text . "&b=" . Auth::user()->id;
        } else {
            $url = "https://stowe.space/pay?a=" . $request->text . "&b=" . Auth::user()->id;
        }
        $text = Auth::user()->name . " is requesting a payment of " . $request->text . " pounds. Please click the link to pay: ". $url;

        $message = Message::create([
            'from' => auth()->id(),
            'to' => $request->contact_id,
            'text' => $text
        ]);

        broadcast(new NewMessage($message));

        return response()->json($message);
    }

Vue.js:


<template>
    <div class="composerpay">
        <textarea v-model.number="amount" type="number" @keydown.enter="send" placeholder="To request a payment, just type a number here! (i.e. 40 for £40.)"></textarea>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                amount: ''
            };
        },
        methods: {  
            send(e) {
                e.preventDefault();
                if (this.amount < 0 || isNaN(this.amount)) {
                    return;
                }
                this.$emit('sendPaymentRequest', this.amount);
                this.amount = '';
            }
        }
    }
</script>

买方在chatapp中请求一笔金额,然后该消息被发送给卖方。

我尝试过:

 $text = Auth::user()->name . " is requesting a payment of " . $request->text . " pounds. Please click the link to pay: <a href'".$url."'></a>";

但是,这仅显示信使中的全部内容。有帮助吗?

0 个答案:

没有答案