Level 1
That was my mistake. I had to check the response as well. I got the transaction id by:
$response['purchase_units'][0]['payments']['captures'][0]['id']
This is the correct id.
I am using srmklive/paypal for paypal payment gateway. Payment is working fine. But I am not getting any transaction id.
public function paymentPaypalSuccess(Request $request, $encrypted_video_id)
{
$video_id = Crypt::decrypt($encrypted_video_id);
$provider = new PayPalClient;
$provider->setApiCredentials(config('paypal'));
$provider->getAccessToken();
$response = $provider->capturePaymentOrder($request['token']);
if (isset($response['status']) && $response['status'] == 'COMPLETED') {
if(isset($video_id) && !empty($video_id))
{
$save_transaction = new Transcation();
$save_transaction->user_id = Auth::user()->id;
$save_transaction->item_type = 'video';
$save_transaction->item_id = $video_id;
$save_transaction->amount = $response['purchase_units'][0]['payments']['captures'][0]['amount']['value'];
$save_transaction->transaction_id = $response['id'];
$save_transaction->transaction_type = 'paypal';
$save_transaction->is_payment_done = 1;
$save_transaction->save();
}
$message = 'Your transaction is completed successfully!';
$transaction_id = $response['id'];
return view('frontend.payment.success_payment',compact('message','transaction_id'));
} else {
return view('frontend.payment.error_payment');
}
}
In above code, the $response['id'] is different from the transaction section in the seller account. I went through with the documentation of the package. But I didn't get any transaction method or something like that.
Please or to participate in this conversation.