×ðÁú¿­Ê±¹ÙÍøµÇ¼

laravelÒì²½ÇëÇóʵÏÖ

ÔÚwebÓ¦ÓóÌÐòÖÐ  £¬Òì²½ÇëÇóÊÇÒ»ÖÖÊ®·ÖÓÐÓõÄÊÖÒÕ ¡£Ëüͨ¹ýÔÚºǫִ́ÐÐÇëÇó  £¬×èÖ¹ÁËÇ°¶ËµØÆÚ´ýЧÀÍÆ÷ÏìÓ¦Ëùµ¼ÖµÄʱ¼äÆÌÕÅ  £¬Í¬Ê±Ò²Ìá¸ßÁËÓû§ÌåÑé ¡£ÔÚlaravel¿ò¼ÜÖÐ  £¬ÎÒÃÇ¿ÉÒÔʹÓÃһЩҪÁìÀ´ÊµÏÖÒì²½ÇëÇóµÄ¹¦Ð§ ¡£

Ò»¡¢Ê²Ã´ÊÇÒì²½ÇëÇó

Òì²½ÇëÇóÊÇÔÚ²»Ë¢ÐÂÕû¸öÒ³ÃæµÄÇéÐÎÏÂÏòЧÀÍÆ÷·¢ËÍÇëÇó  £¬²¢ÔÚºǫ́´¦ÀíÇëÇóµÄÒ»ÖÖÊÖÒÕ ¡£ÕâÖÖÊÖÒÕ¿ÉÒÔ±»Ó¦ÓÃÔÚ²î±ðµÄ³¡¾°µ±ÖÐ  £¬ºÃ±È£ºµ±ÎÒÃÇÐèÒªÏÔʾij¸öʹÃüµÄ½ø¶ÈÌõ»òÊÇÐèÒªÖ§¸¶Ò³Ãæ×Ô¶¯Ë¢Ð  £¬ÒÔ±ãÈÿͻ§¸ÐÊܵ½Æ丶¿îµÄÀÖ³É ¡£

¶þ¡¢LaravelÖÐʹÓÃÒì²½ÇëÇóµÄÒªÁì

1.ʹÓÃjQueryÖеÄajaxÒªÁìÀ´ÊµÏÖÒì²½ÇëÇó ¡£

ÔÚLaravelÖпÉÒÔÇáËɵØÓëjQueryÅäºÏʹÓÃÀ´ÊµÏÖÒì²½ÇëÇóµÄ¹¦Ð§ ¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ°취À´Íê³ÉÕâ¸öÀú³Ì£º

Ê×ÏÈ  £¬ÎÒÃÇÐèÒªÒýÈëjQuery¿âÎļþ ¡£¿ÉÒÔÔÚÎÒÃǵÄHTMLÄ£°åÖеÄÍ·²¿»òÊǶ¥²¿À´Íê³ÉÕâ¸ö°ì·¨£º

<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´  £¬ÎÒÃÇÐèÒª±àд·¢ËÍÒì²½ÇëÇóµÄ´úÂë ¡£Õâ¸ö´úÂëƬ¶Ï¿ÉÒÔ±»°üÀ¨ÔÚÈκÎÊÂÎñ´¦Àíº¯ÊýÖÐ  £¬ºÃ±ÈÓû§µã»÷ij¸ö°´Å¥ºó£º

$(document).ready(function(){
    $('#btn-submit').click(function(e){
        e.preventDefault();
        $.ajax({
            type: 'POST',
            url: '/payment',
            data: {
                'amount': $('#amount').val(),
                'payment_method': $('#payment_method').val(),
                '_token': $('input[name="_token"]').val()
            },
            success: function(data){
                console.log('success');
                console.log(data);
                //ÔÚ´Ë´¦½«·µ»ØµÄdataÊý¾ÝչʾÔÚÇ°¶ËÒ³ÃæÉÏ
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                console.log('error');
                console.log(XMLHttpRequest);
                console.log(textStatus);
                console.log(errorThrown);
            }
        });
    });
});

µÇ¼ºó¸´ÖÆ

2.ʹÓÃLaravelµÄÐÐÁй¦Ð§À´ÊµÏÖÒì²½ÇëÇó ¡£

Laravelµ×²ã×Ô´øÁËÒ»¸öÐÐÁÐϵͳÓÃÓÚÔÚºǫִ́ÐÐʹÃü ¡£Í¨¹ýʹÓÃÐÐÁÐϵͳ  £¬ÎÒÃÇ¿ÉÒÔ×èÖ¹¿Í»§¶ËÆÚ´ýЧÀÍÆ÷ÏìӦʱ¼ä½Ï³¤µÄÎÊÌâ  £¬²¢ÇÒ»¹¿ÉÒÔÖÎÀíËùÓкǫ́ʹÃüµÄÖ´ÐÐ  £¬ÒÔ±ã¸üºÃµØ¾ÙÐе÷ÀíºÍÓÅ»¯ ¡£

½ÓÏÂÀ´  £¬ÎÒÃǽ«Ê¹ÓÃLaravelµÄÐÐÁÐϵͳÀ´½ç˵Òì²½ÇëÇóµÄ´¦Àí°ì·¨ ¡£

Ê×ÏÈ  £¬ÎÒÃÇÐèÒª½ç˵һ¸öеÄʹÃüÀà ¡£Õâ¸öÀàÐèÒª¼ÌÐøÔ­ÉúµÄLaravelµÄʹÃüÀà  £¬²¢ÊµÏÖ¸ÃÀàÖеÄhandle()ÒªÁì ¡£»ù±¾Ä£°å¿ÉÒÔÈçÏÂËùʾ£º

namespace AppJobs;
use IlluminateBusQueueable;
use IlluminateContractsQueueShouldQueue;
use IlluminateFoundationBusDispatchable;
use IlluminateQueueInteractsWithQueue;
use IlluminateQueueSerializesModels;

class ProcessPayment implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $amount;
    protected $paymentMethod;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($amount, $paymentMethod)
    {
        $this->amount = $amount;
        $this->paymentMethod = $paymentMethod;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //ÔÚ´Ë´¦Ö´ÐÐÒì²½ÇëÇóËùÐèµÄËùÓÐÊÂÇé£¬ºÃ±ÈHTTPÇëÇó»òµç×ÓÓʼþ·¢ËÍ¡£

        //´¦ÀíÇëÇóÍê±Ïºó½«Ð§¹ûÉúÑÄÔÚÊý¾Ý¿âÖÐ£¬¹©Ç°¶ËÒ³Ãæ¶ÁÈ¡¡£
    }
}

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´  £¬ÎÒÃÇ¿ÉÒÔ½«Òì²½ÇëÇóµÄ´¦ÀíÂß¼­·ÅÔÚhandle()ÒªÁìÖоÙÐÐ ¡£Í¨¹ýÔÚºó¶ËÖ´ÐÐÕâ¸öʹÃü  £¬¿ÉÒÔ×èÖ¹Ò³Ã濨¶Ùµ¼ÖÂÓû§ÌåÑé±ä²îµÄÎÊÌâ  £¬Í¬Ê±Ò²²»»áÕû¸öÇëÇ󱻺ó¶ËµÄÖ´ÐÐʱ¼äËùÍÏÂý ¡£

×îºó  £¬ÎÒÃÇ¿ÉÒÔÔÚij¸ö¿ØÖÆÆ÷ÒªÁìÖд¥·¢Õâ¸öʹÃü  £¬´Ó¶øʵÏÖÒì²½ÇëÇóµÄ´¦Àí ¡£ºÃ±È£º

public function submitPayment(Request $request)
{
    $amount = $request->input('amount');
    $method = $request->input('payment_method');
    ProcessPayment::dispatch($amount, $method); //´¥·¢Òì²½ÇëÇóʹÃü
    return response()->json(['message' => 'success']);
}

µÇ¼ºó¸´ÖÆ

Èý¡¢×ܽá

Òì²½ÇëÇóÔÚWebÓ¦ÓóÌÐòµÄ¿ª·¢ÖÐÊÎÑÝ×ÅÊ®·ÖÖ÷ÒªµÄ½ÇÉ« ¡£Ê¹ÓÃÒì²½ÇëÇóÊÖÒÕ  £¬Äܹ»ÈÃÎÒÃǵÄÓ¦ÓóÌÐòÔËÐеøü¿ì¸üÁ÷ͨ  £¬´Ó¶øÌá¸ßÓû§µÄÌåÑé ¡£ÔÚLaravel¿ò¼ÜÖÐ  £¬ÎÒÃÇ¿ÉÒÔʹÓÃjQueryµÄajaxÒªÁì»òÕßÊÇLaravelµÄÐÐÁÐϵͳÀ´ÊµÏÖÒì²½ÇëÇó¹¦Ð§ ¡£ÎÞÂÛÄãʹÓÃÄÄÖÖÒªÁì  £¬¶¼ÐèÒªÇмÇÔÚÐÄ£ºÒì²½ÇëÇóʹӦÓóÌÐò¸ü¿ì  £¬¸ßЧ  £¬¸ü¾ßÓÐÓû§ÌåÑé ¡£Ï£Íû±¾ÆªÎÄÕÂÄܹ»¶ÔÄãÔÚʵÏÖÒì²½ÇëÇóʱÓÐËù×ÊÖú ¡£

ÒÔÉϾÍÊÇlaravelÒì²½ÇëÇóʵÏÖµÄÏêϸÄÚÈÝ  £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí  £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø  £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È  £¬Çë¶ÁÕß½ö×ö²Î¿¼ ¡£±¾ÎĽӴýתÔØ  £¬×ªÔØÇë˵Ã÷À´ÓÉ ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢  £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢  £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý ¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå  £¬9:30-18:30  £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ