【发布时间】:2020-07-12 03:41:36
【问题描述】:
当买家付款时,我在 laravel 上出现条纹问题,它在条纹仪表板上显示成功,但我收到此错误是否有任何解决方案 (itError 不能使用 Omnipay\Stripe\Message\Response 类型的对象作为数组)
这是日志
不能使用 Omnipay\Stripe\Message\Response 类型的对象作为数组 {"userId":6,"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): 不能使用Omnipay\Stripe\Message\Response 类型的对象作为数组位于 /home/tameriu/example.com/app/Http/Controllers/OfferController.php:1349)
这是行:1349
$check_payment = Payment::where('transaction_id', $response['transactions']['0']['related_resources']['0']['sale']['id'])->first();
// Check if a payment with this transaction is already in the database
if ($check_payment == null) {
// Create new payment
$payment = new Payment;
// Offer details
$payment->item_id = $offer->id;
$payment->item_type = Offer::class;
// Page User
$payment->user_id = Auth::user()->id;
// Transaction details from gateway
$payment->transaction_id = $data['id'];
$payment->payment_method = 'stripe';
$payment->payer_info = json_encode($data['source']);
// Money
$payment->total = number_format($balance_data['amount']/100, 2);
$payment->transaction_fee = number_format($balance_data['fee']/100, 2);
$payment->currency = strtoupper($balance_data['currency']);
// Save payment
$payment->save();
}
// Send notification to seller
$offer->listing->user->notify(new PaymentNew($offer, $payment));
\Alert::success('<i class="fa fa-check m-r-5"></i> ' . trans('payment.alert.successful'))->flash();
} else {
\Alert::error('<i class="fa fa-times m-r-5"></i> ' . trans('payment.alert.canceled'))->flash();
Session::forget('params');
}
return $this->show($id);
}
【问题讨论】:
-
可以分享一下代码吗?
-
我已经分享了代码
-
你从
var_dump($response);得到什么? -
你能用这个
$check_payment = Payment::where('transaction_id', $response->transactions['0']['related_resources']['0']['sale']['id'])->first();替换这个声明$check_payment = Payment::where('transaction_id', $response['transactions']['0']['related_resources']['0']['sale']['id'])->first();吗?还有var_dump($response);在此声明之前向我们展示response的样子。
标签: php laravel stripe-payments