【发布时间】:2017-06-07 04:18:21
【问题描述】:
我刚刚从 net-shell (https://github.com/net-shell/laravel-paypal) 为 Laravel 实现了 PayPal API,到目前为止一切正常,但现在我缺少一件事或者我不知道该怎么做:在我的门户中,用户必须使用他们的地址注册。我想要的是这封电子邮件(用于在我的门户网站上注册)用作送货地址,然后在 PayPal 网站上也会显示(因此无论用户为 PayPal 输入的地址是什么)。
有什么办法吗?
我知道似乎有一个 PayPal:ShippingAdress,我可以使用它,但如果这是正确的,那么我该如何将其分配给付款?
编辑:我现在尝试了很多变体,例如 $transaction->setShippingAddress(); 或 $payer->setShippingAddress(); 或 $payment->setShippingAddress(); 但没有任何效果,该方法从未找到。现在在 Paypal/Api/ShippingAddress 我找到了 setDefaultAddress 方法,所以我想创建这样一个对象并像这样使用这个方法:
$shippingAddress = [
"recipient_name" => "John Johnson",
"line1" => "Whatever street 2",
"line2" => "Another street 2",
"city" => "London",
"country_code" => "UK",
"postal_code" => "NR30 1LY",
"state" => "England",
"phone" => "3123123123"
];
$shippingAddr = PayPal::ShippingAddresss();
$shippingAddr->setDefaultAddress($shippingAddress);
使用此代码不会出错,但它也没有设置地址,我现在需要将此创建的 shippingAddress 对象分配给付款或交易,就像我使用详细信息一样,创建详细信息对象,然后使用 @987654327 @,但我没有为 shippingAddress 找到任何东西.....
编辑2: 通过项目列表获得提示,这就是我创建和设置该列表的方式:
$itemList = PayPal::itemList();
foreach ($items as $item)
$product = Product::where('id', '=', $item->product->id)->first();
$itemName = $product->name;
$itemPrice = $product->price;
$itemAmount = $item->amount;
$payPalItem = PayPal::item();
$payPalItem->setName($itemName)
->setDescription($itemName)
->setCurrency('EUR')
->setQuantity($itemAmount)
->setPrice($itemPrice);
$itemList->addItem($payPalItem);
}
然后
$transaction = PayPal::Transaction();
$transaction->setAmount($amount);
$transaction->setItemList($itemList);
【问题讨论】:
-
没人知道吗?
-
只是给您一些快速的信息,当您通过 Paypal 销售商品时,如果您没有将商品运送到他们帐户上的地址,您就没有卖家保护。仅供参考
-
和我一样的问题。我不推荐老兄。我以前用过 5.2。有效。但是,我不能传递地址。我尝试关注 Paypal 文档,但在 paypal 结帐页面中无法预加载任何内容。客户需要再次输入他们的地址详细信息和电话号码作为客人结帐。我还没有测试这个 api github.com/anouarabdsslm/laravel-paypalpayment。但是,它看起来像更多的文档。
-
它工作意味着只是基本的流程工作。你可能会混淆我的评论。
-
@KelvinKyaw 查看接受的答案,我与他进行了长时间的研究,但现在开始工作了!
标签: php laravel paypal paypal-rest-sdk