أقوم بدمج بوابة دفع paypal في طلبي ، قبل أن يغادر المستخدم موقعي لأول مرة من أجل paypal ، قمت بحفظ جميع المعلومات اللازمة ، وقمت بتعيين payment_status
ان نكون 0
، عندما يعود المستخدم ، إذا كان الدفع ناجحًا ، فإنه يعود إلى صفحة جديدة حيث يحصل على paymentId
و payerID
، بالإضافة إلى تعيين paymentstatus
إلى 1
.
الشيء هو أنه إذا قمت بتعيين قيمة قاعدة البيانات ل paymentID
و PaymentId
إلى null
، لا يتم حفظه.
إذا لم أقم بتعيينه على أي شيء ، على سبيل المثال ، اتركه فارغًا ، فسيوفر ، ولكن يعيد الخطأ:
Integrity constraint violation: 1048 Column 'PayerID' cannot be null (SQL: update `paypal_officers` set `paymentId` = , `PayerID` = , `updated_at` = 2018-07-15 07:29:21 where `id` = 1)
لا أستطيع أن أعرف ما هي المشكلة.
هذه هي الطريقة التي تقوم بالتوفير.
public function getPaymentStatus(Input $input)
{
/** Get the payment ID before session clear **/
$payment_id = Session::get('paypal_payment_id');
$insert_the_user_id = PaypalOfficer::findorFail(\session()->get('receivers_main_info_id'));
$insert_the_user_id->update([
'paymentId' => Input::get('paymentId'),
'PayerID' => Input::get('PayerID'),
'payment_status' => 1,
]);
$insert_the_user_id->save();
/** clear the session payment ID **/
Session::forget('paypal_payment_id');
if (empty(Input::get('PayerID')) || empty(Input::get('token'))) {
\Session::put('error', 'Payment failed');
return Redirect::to('account/send-money/paypal/send')->with('payer_id', $payment_id);;
}
$payment = Payment::get($payment_id, $this->_api_context);
$execution = new PaymentExecution();
$execution->setPayerId(Input::get('PayerID'));
/**Execute the payment **/
$result = $payment->execute($execution, $this->_api_context);
if ($result->getState() == 'approved') {
\Session::put('success', 'Payment success');
return Redirect::to('account/send-money/paypal/stagged/paypal')->with('payer_id', $result);
}
\Session::put('error', 'Payment failed');
return Redirect::to('account/send-money/paypal/send');
}
مثالي
namespace App;
use Illuminate\Database\Eloquent\Model;
class PaypalOfficer extends Model
{
protected $fillable = [
'payment_status',
'paymentId',
'PayerID',
'user_id',
'amount',
'destination_account_number',
'destination_account_name',
'destination_bank_name',
'destination_phone_number',
'destination_country',
'destination_state',
'currency_symbol',
'receivers_name',
];
//
public function user(){
return $this->belongsTo(User::class);
}
}
من فضلك ماذا يجب أن يفتقد في التعليمات البرمجية ، أي شخص من فضلك!