我正在为一个朋友开发一个电子商务网站,并在执行付款之前更新贝宝的发货金额,我得到以下错误。当我调用Patch,PatchRequest,然后尝试执行支付时,会出现此错误。以下是全部代码:
if (Input::get('action', 'get') === "getDetails") { //Check to see if the action parameter is set to getDetails
$payment = \PayPal\Api\Payment::get(Input::get('paymentId', 'get'), $paypalAPI);
$payerInfo = $payment->getPayer()->payer_info;
if (!empty($payment)){
$quantity = 0;
foreach ($payment->transactions[0]->item_list->items as $item) {
$quantity += $item->quantity;
}
if ($quantity <= 20) {
$parcelType = "MediumFlatRateBox";
} else if ($quantity > 20) {
$parcelType = "LargeFlatRateBox";
}
$shipment = \EasyPost\Shipment::create([
'from_address' => \EasyPost\Address::retrieve(Config::get('easypost/addressObjectID')),
'to_address' => [
'name' => $payerInfo->shipping_address->recipient_name,
'street1'=> $payerInfo->shipping_address->line1,
'street2' => (isset($payerInfo->shipping_address->line2)) ? $payerInfo->shipping_address->line2 : null,
'city' =>$payerInfo->shipping_address->city,
'state' => $payerInfo->shipping_address->state,
'country' => $payerInfo->shipping_address->country_code,
'zip' => $payerInfo->shipping_address->postal_code,
'email' => $payerInfo->email
],
'parcel' => [
'predefined_package' => $parcelType,
'weight' => 520
]
]);
//Grab the lowest shipping rate
$shippingRate = $shipment->lowest_rate()->rate;
//Make a call to PayPal updating our transaction with the tax and shipping rate
$amount = $payment->transactions[0]->amount;
$transactionUpdate = new \PayPal\Api\Patch();
$transactionUpdate ->setOp('replace')
->setPath('transactions/0/amount')
->setValue(json_decode('{
"total": "'.$amount->total.'",
"currency":"USD",
"detail": {
"subtotal": "'.$amount->details->subtotal.'",
"shipping":"'.$shippingRate.'"
}
}'));
//Instantiate a new instance of PayPal's Patch Request Class and Update the Transaction with the tax and shipping rate
$updateRequest = new \PayPal\Api\PatchRequest();
$updateRequest->setPatches(
[$transactionUpdate]
);
//Attempt Update
$result = $payment->update($updateRequest, $paypalAPI);
if ($result) {
$transID = generateTransactionID();
$fields = [
'dateCreated' => strtotime($payment->create_time),
'transID' => $transID,
'paymentID' => $payment->id,
'shipmentID' => $shipment->id
];
$db->insert('transactionLog', $fields);
Redirect::to('shoppingCartFinalize.php?transID='.$transID);
exit();
} else {
Alert::set([
'header' => "Uh Oh....Something Went Wrong",
'message' => "Unable to update transaction. Transaction Cancelled. Please try again.",
'type' => 'danger',
'close' => 1
]);
Redirect::to('shoppingCartView.php');
exit();
}
}
以下是我在调用过程中得到的错误:
请参考这个答案我认为你必须尝试-捕获你的代码来确定错误,问候。
我使用jpaRepository删除通知方法。 并且有一个实体文件。 当我尝试在控制器中删除通知时, 我得到一个错误“无法提交JPA事务;嵌套异常为javax . persistence . roll back exception:提交事务时出错。< br >我可以就这个问题得到一些建议吗?
我非常清楚这个问题可以通过禁用安全更新模式来解决(例如,请参见此处:在MySQL工作台中更新期间的MySQL错误代码:1175)。但是,我不希望禁用安全更新模式(有很多很多解决方案提出了这一点)。 类似地,我知道将WHERE子句设置为匹配所有内容的KEY-value应该会起作用。但在mysql-workbench上似乎并不起作用--至少不是我希望的那样(或它在控制台上的工作方式)。 例如,以下操作
当我转换为maven项目时,错误是: 有什么问题吗?
我正在开发一个JavaEEWeb项目。当我尝试添加依赖项时,会出现此错误消息。我使用Eclipse开普勒。 “更新Maven项目”期间发生内部错误。JAVAlang.NullPointerException 你能帮我吗?非常感谢。
更新Maven项目时获取以下内部错误消息(右键单击Project- 错误消息基本上指向eclipse中的IBM插件 请在下面找到日志: 可能是什么问题?
问题内容: 我在Java J2EE Web应用程序中使用Hibernate 3.5.2和Spring Core 3.0.1。当单独的用户同时更新同一记录时,我得到了StaleObjectStateExcpetion。事务由javax.persistence.EntityManager管理。这是我创建问题的步骤。 User1登录到应用程序 User2登录到应用程序 用户1开始编辑记录A 用户2开始编