Php 在基于Laravel的商店中实现支付关塔维

Php 在基于Laravel的商店中实现支付关塔维,php,laravel-4,payment,Php,Laravel 4,Payment,我需要一点帮助,以实现支付逃逸在拉维商店。 我使用的付款方式是,我不知道如何获取所需信息。因此,我已经设置了文件数据库表、数据库连接和所有。。现在,我正在尝试在提交订单后将用户重定向到payment.php页面。这是我的CartController.phporderSubmit函数 public function orderSubmit() { $cart = Session::get(self::CART_SESSION_KEY, array()); if (count($ca

我需要一点帮助,以实现支付逃逸在拉维商店。 我使用的付款方式是,我不知道如何获取所需信息。因此,我已经设置了文件数据库表、数据库连接和所有。。现在,我正在尝试在提交订单后将用户重定向到
payment.php
页面。这是我的
CartController.php
orderSubmit函数

public function orderSubmit() {
    $cart = Session::get(self::CART_SESSION_KEY, array());
    if (count($cart) < 1) {
        return Redirect::to('/');
    }

    $validatorRules = array(
        'captcha' => 'required|captcha',
        'shipping_address' => 'required|min:10',
        'shipping_method' => 'required|in:' . implode(',', [Settings::SETTINGS_SHIPPING_NORMAL, Settings::SETTINGS_SHIPPING_EXPRESS])
    );

    Input::merge(array_map('trim', Input::all()));
    $validator = Validator::make(Input::all(), $validatorRules);

    if ($validator->fails()) {
        return Redirect::to('/cart/order?_token=' . csrf_token())->withErrors($validator->errors())->withInput(Input::except(['captcha']));
    }

    $shipping = array(
        'quantity' => 1,
        'image' => '/img/noimage.png',
        'description' => '',
        'title' => 'FIX ME', // this should never occur,
        'price' => 100000 // this should never occur
    );
    switch (Input::get('shipping_method')) {
        case Settings::SETTINGS_SHIPPING_NORMAL:
            $shipping['title'] = 'Normal Delivery';
            $shipping['price'] = 0;
            break;

        case Settings::SETTINGS_SHIPPING_EXPRESS:
            $shipping['title'] = sprintf('Express Delivery - $%.2f', Settings::getOption('express_shipping_cost'));
            $shipping['price'] = doubleval(Settings::getOption('express_shipping_cost'));
            break;
    }

    $cart['shipping'] = $shipping;
    $order = new Order();
    $order->user_id = self::$user->user_id;
    $order->data = json_encode($cart);
    $order->address = Input::get('shipping_address');
    $order->pgp_key = Input::get('gpgkey');
    $order->info = Input::get('additional_info');
    $order->save();

    Session::put(self::CART_SESSION_KEY, array());
    return Redirect::to('payment.php')->with('message_success', 'Order created! We will contact you shortly to confirm your order and payment details.');
}

我的问题是如何在payment.php中获取正确的信息?如何获取userID、userFormat、orderID等等?

首先,我建议您使用Laravel作为它的框架。在Laravel中,您定义控制器来处理http请求。制作一个新的PaymentController并将payment.php中的代码放入该控制器。然后路由到该控制器方法

同时将配置设置放在Laravels配置文件夹中

需要_一次(../cryptobox.class.php)可以由控制器构造函数中的依赖项注入替换

现在回到你的问题。

$userID
是您放置已注册Laravel用户ID的位置。(如果您没有任何已注册用户,请将其留空)。为什么要将用户id放入此变量中-它有助于跟踪哪些用户进行了哪些付款。如果要跟踪付款历史记录,可以稍后将此信息保存在数据库中

$orderID
这是您放置内部订单id的地方。为什么要使用内部订单id-同样,它需要跟踪哪些用户购买了哪些产品。您可以将订单id与用户id和产品id一起存储在数据库中,以获取购买历史记录日志


$userFormat
这是您希望存储用户信息、会话、cookie等的方式。因为在执行购买时,支付网关需要一种访问此信息的方式,因此它必须存储在会话或cookie中。

我将使用
$\u会话['$value']
如果您为用户使用会话

好的,我制作了一个新的控制器,下单后我将用户重定向到此页面,但出现错误
MethodNotAllowedHttpException
。。。我想我在controllerMethodNotAllowedHttpException中有错误,当您试图使用错误的http谓词访问该方法时,通常会出现异常。例如,如果您尝试使用http POSTNow调用定义为GET的路由,我会在/var/www/site/vendor/laravel/framework/src/illumb/Routing/RouteCollection.php:148中获得
异常'Symfony\Component\HttpKernel\exception\NotFoundHttpException'。我的路线是
route::post('/cart/payment',['uses'=>'PaymentController@paymentView“,”在“=>”auth | csrf']之前]
并正确重定向到
/cart/payment
,这意味着您正在尝试访问routes.php文件中未指定的URL
    require_once( "../cryptobox.class.php" );

/**** CONFIGURATION VARIABLES ****/ 

$userID         = "";               // place your registered userID or md5(userID) here (user1, user7, uo43DC, etc).
                                    // you don't need to use userID for unregistered website visitors
                                    // if userID is empty, system will autogenerate userID and save in cookies
$userFormat     = "";           // save userID in cookies (or you can use IPADDRESS, SESSION)
$orderID        = "";
$amountUSD      = 20;           
$period         = "NOEXPIRY";       
$def_language   = "en";             
$public_key     = "mypublickey"; 
$private_key    = "myprivatekey";



/** PAYMENT BOX **/
$options = array(
        "public_key"  => $public_key,   // your public key from gourl.io
        "private_key" => $private_key,  // your private key from gourl.io
        "webdev_key"  => "",        // optional, gourl affiliate key
        "orderID"     => $orderID,      // order id or product name
        "userID"      => $userID,       // unique identifier for every user
        "userFormat"  => $userFormat,   // save userID in COOKIE, IPADDRESS or SESSION
        "amount"      => 0,             // product price in coins OR in USD below
        "amountUSD"   => $amountUSD,    // we use product price in USD
        "period"      => $period,       // payment valid period
        "language"    => $def_language  // text on EN - english, FR - french, etc
);

// Initialise Payment Class
$box = new Cryptobox ($options);

// coin name
$coinName = $box->coin_name(); 

// Successful Cryptocoin Payment received
if ($box->is_paid()) 
{
    if (!$box->is_confirmed()) {
        $message =  "Thank you for payment (payment #".$box->payment_id()."). Awaiting transaction/payment confirmation";
    }                                           
    else 
    { // payment confirmed (6+ confirmations)

        // one time action
        if (!$box->is_processed())
        {
            // One time action after payment has been made/confirmed

            $message = "Thank you for order (order #".$orderID.", payment #".$box->payment_id()."). We will send soon";

            // Set Payment Status to Processed
            $box->set_status_processed();  
        }
        else $message = "Thank you. Your order is in process"; // General message
    }
}
else $message = "This invoice has not been paid yet";

$languages_list = display_language_box($def_language);