php - Omnipay - Laravel - 完成 Paypal Pyment

标签 php laravel paypal laravel-4 omnipay

我有以下 SuccessPayment 方法:

    public function getSuccessPayment() {
    $gatewayFactory = new \Omnipay\Common\GatewayFactory;
    $gateway = $gatewayFactory->create('PayPal_Express');
    #Test API Sandbox
    $gateway->setUsername('xxxxxxx.de');
    $gateway->setPassword('xxxxxxxxx');
    $gateway->setSignature('xxxxx.xxxxx.xxxxx.xxxxxxx');
    $gateway->setTestMode(true);

    # FINALIZZZE PAYPAL PAYMENT
    $response = $gateway->completePurchase($this->getApiInfos())->send();
    $data = $response->getData();

    # IF SUCCESSFULLLLLLL
    if($data['ACK'] == 'Success'):
        $order = Order::where('paypalToken',$data['TOKEN'])->first();
        # Set Status
        $order->orderSuccess = 4;
        $order->orderPaid = 1;
        # Set PP ID
        $order->paypalTransactionId = $data['PAYMENTINFO_0_TRANSACTIONID'];
        $order->save();

        # Destroy Cart
        Cart::destroy();

        # Send Confirm Mail
        $this->sendConfirmOrderMail($order->id, Auth::user()->id);

        return View::make('pages.checkout.success', compact(['order','data']));
    endif;
}  

$this->getApiInfos() 有凭据和信息,要传给PP,方法如下:

    public function getApiInfos($order = NULL) {
  return array(
    'amount'=> Cart::total(),
    'cancelUrl' => \URL::route('paypal_cancel_order'),
    'returnUrl' => \URL::route('paypal_return'),
    'description' => 'Your Payment at xxxxxx - Order #',
    'currency' => 'EUR'
  );
}  

看说明。在重定向到 Paypal 之后以及在我被重定向回我的页面之后,如何将 orderID 放入描述中?
我失去了我的 session 和订单(我猜!),那么我该怎么做呢?

此外,您知道我如何通过 Omnipay 将运费、税金和标题图片发送到 PayPal 吗?

最佳答案

要获取您发送到 Paypal 的交易引用,您可以这样做

$response->getTransactionReference();

对于你问题的后半部分:
PayPal Express 网关有以下设置图片的功能:

$gateway->setHeaderImageUrl()
$gateway->setLogoImageUrl()

所有请求都具有以下功能

$request->setTaxAmount()
$request->setShippingAmount()
$request->setHandlingAmount()
$request->setShippingDiscount()
$request->setInsuranceAmount()

关于php - Omnipay - Laravel - 完成 Paypal Pyment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26577385/

相关文章:

php - 如何在 php 日期中使用时区?

php - 使用 Laravel Socialite 获取谷歌刷新 token

用于列出用户总帖子的 PHP 脚本

laravel - 如何使Laravel迁移器与命名空间迁移一起使用?

php - 支付成功,有效期、卡验证码、姓名、地址错误

javascript - MySQL 错误号 1064

php - Laravel,无法复制目录或移动目录

php - 如何从 localhost(laravel、nodejs)调用 localhost?

python - 我们可以用纯Python urllib登录一个网站,修改一些表单值,然后提交吗? (没有 Selenium 浏览器自动化)

android - 从 JSON 响应中提取 PayPal 销售 ID