$items = [
0 => [
'quantity' => 2,
"inventory_id" => 1
]
];
$shippingId = $request->shippingId; //It can be null
$addressId = (int)$request->addressId;
$newOrder = app('orderFunction')->store($shippingId, $addressId, "test from create new order", $items);
//
return $newOrder;
#params :
# shippingId => Type of shipment,
# $addressId => The address ID stored for the user in the address table ,
# $description => create new order by user example .... ,
# $items => Enter the product order number and inventory ID for the corresponding model
public function inventories()
{
return $this->morphMany(app('inventory'), 'adm_inventories');
}
use Advancelearn\ManagePaymentAndOrders\PaymentConfirmationInterface;
class Product extends Model implements PaymentConfirmationInterface
{
//you're methods or logic
//added this method after implemention:
public function paymentConfirmation($user_id, $inventory_id, $quantity)
{
//you're added logic after paymentConfirmation
}
}
use Advancelearn\ManagePaymentAndOrders\Enums\AuditTypes;
$invoice = new Invoice;
$invoice->amount($order->payment_price);
app('payment')::create
([
'order_id' => $order->id,
'driver' => $request->input('driver'),
'transaction_id' => //transactionId from your gateway sent request for pay,
'amount' => $order->payment_price
]);
public function paymentConfirmation(Request $request)
{
$payment = app('payment')::where('transaction_id', $transactionId)->first();
$order = app('order')::find($payment->order_id);
$receipt = //api call gateway for verifyPayment and get response add to this variable
$this->verifyPayAndConfirm($payment, $order, $request);
// return redirect('https://example.com?gatewayOrderID=' .
// $paymentTransaction->OrderId ?? null . '&RRN=' .
// $paymentTransaction->RRN ?? null);
}
use Advancelearn\ManagePaymentAndOrders\Enums\AuditTypes;
private function verifyPayAndConfirm($receipt, $payment, Request $request): void
{
$payment->reference_id = $receipt->getReferenceId();
$payment->transaction = $request->all();
$payment->driver = $receipt->getDriver();
$payment->save();
$order->audits()->attach([AuditTypes::PAID => ['description' => 'Payment was successful']]);
foreach ($order->items as $item) {
//this method called fromAnd finally, this
// method reaches the method that we implemented
// in the corresponding model of the interface
$item->PaymentConfirmation($order->address->user_id);
}
return $receipt;
}
return app('orderFunction')->getOrders(); // get Order List for AdminPanel
return app('orderFunction')->singleOrder(5); // get singleOrder for AdminPanel
return app('orderFunction')->ordersOfTheLoggedInUser(); // get user Authenticated Order list
return app('orderFunction')->SingleOrderOfTheLoggedInUser(5); //get user Authenticated singleOrder
return app('paymentFunction')->getPayments(); // get PaymentList for AdminPanel
return app('paymentFunction')->singlePayment(1); //get singlePayment for AdminPanel
return app('paymentFunction')->paymentsOfTheLoggedInUser(); //get user Authenticated payment list
return app('paymentFunction')->SinglePaymentsOfTheLoggedInUser(1); //send $paymentId
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.