使用Laravel的PayPal API

时间:2015-08-11 14:34:39

标签: php api laravel plugins paypal

我正在使用paypal插件,并且出于某种原因,付款完成后,我无法通过PayPal转到我的回拨网址。我之前使用了相同的插件,所以它一定是我正在做的蠢事。

这是我传递给插件的数据的示例数组

阵列

(
    [sandboxMode] => 1
    [successUrl] => http://x.x.x.x/safespacesforkids/rebuild/public/payment/success
    [cancelUrl] => http://x.x.x.x/safespacesforkids/rebuild/public/assessment/checkout
    [backendUrl] => http://x.x.x.x/safespacesforkids/rebuild/public/payment/pp/316e7c50a117c91b392a013a6e1a22e9a4f97b1e
    [merchantAccount] => myemail@domain.com
    [language] => EN
    [currency] => AUD
    [invoice] => 55ca0738e638d
    [purpose] => Company Name
    [amount] => 180.68
    [remark] => 
)

当我将backendUrl复制到我的浏览器并自己去那里时,处理订单就好了。但paypal不会

我的代码

public function redirect()
{
    //My Basket - Info
    $basket = Cart::getBasket();

    //Make payment hash
    $user = User::find(Auth::id());
    $user->hash = sha1(rand().time());
    $user->save();

    $paypalInfo = array(
        'sandboxMode'     => true,
        'successUrl'      => URL::route('payment.success'),
        'cancelUrl'       => URL::route('assessment.checkout'),
        'backendUrl'      => URL::route('payment.paypal', $user->hash),
        'merchantAccount' => System::first()->paypal_email,
        'language'        => 'EN',
        'currency'        => 'AUD',
        'invoice'         => uniqid(),
        'purpose'         => 'Safe Spaces for Kids',
        'amount'          => Helper::price($basket['total']),
        'remark'          => ''
    );

    Helper::pr($paypalInfo,1);

    $adapter = Gateway::driver('Paypal')->initialize($paypalInfo);
    $generated = $adapter->render();

    return View::make('payment/redirect', ['form' => $generated]);
}

0 个答案:

没有答案