Laravel / Omnipay paypal,通过自定义运费

时间:2014-11-10 15:14:08

标签: php omnipay paypal

我尝试将自定义运费通过PayPal快速结账。

我使用的是omnipay和laravel 4.

我认为这可以在paypal express docs中引用,但无法与omnipay一起使用我已尝试过以下方法:

/*set api details*/
$request = $gateway->purchase([
    'amount'=> $cart['total'],
    'currency' => 'GBP',
    'XXX' => 100
    'transactionId' => $order->reference,
    'returnUrl' => $returnURL . '/checkout/success',
    'cancelUrl' => $returnURL . '/checkout/cancel'
])->setItems($cart['items'])->send();

/*handleResponse*/

XXX正在发货,shippingAmt,shipping_amount,我已经尝试为购物车中的每件商品添加运费。我已尝试修改abstractrequest.php类以手动添加运费值,如下所示:

protected function getItemData()
    {
        $data = array();
        $items = $this->getItems();
        if ($items) {
            foreach ($items as $n => $item) {
                $data["L_PAYMENTREQUEST_0_NAME$n"] = $item->getName();
                $data["L_PAYMENTREQUEST_0_DESC$n"] = $item->getDescription();
                $data["L_PAYMENTREQUEST_0_QTY$n"] = $item->getQuantity();
                $data["L_PAYMENTREQUEST_0_AMT$n"] = $this->formatCurrency($item->getPrice());
            }
        }
        $data["L_PAYMENTREQUEST_0_SHIPPINGAMT"] = "3.00";
        return $data;
    }

1 个答案:

答案 0 :(得分:0)

我找到了answer here

我使用的是较旧版本的软件包,因此只需运行composer update并可以使用函数setShippingAmount();