Using the PayPal payment gateway where all the products added to the shopping cart are issued by means of its form and the generation thereof with PHP
<?php
while ($stmt->fetch()) {
$key = array_search($id_product, $items);
$total = $total + $price * $qty[$key];
?>
<input name="item_number_<?php echo $num;?>" type="hidden" value="<?php echo $id_product; ?>">
<input name="item_name_<?php echo $num;?>" type="hidden" value="<?php echo $product; ?>">
<input name="amount_<?php echo $num;?>" type="hidden" value="<?php echo number_format($price,2);?>">
<input name="quantity_<?php echo $num;?>" type="hidden" value="<?php echo $qty[$key];?>">
<?php
$num++;
}
?>
And its return of values:
Array
(
[payer_email] => testing-instructor@site.com
[payer_id] => J95XSJRX4WXVS
[payer_status] => VERIFIED
[first_name] => Milck
[last_name] => Jmkc
[address_name] => Milck Jmkc
[address_street] => calle Vilamar� 76993- 17469
[address_city] => Albacete
[address_state] => Albacete
[address_country_code] => ES
[address_zip] => 02001
[residence_country] => ES
[txn_id] => 71U73747YB4505702
[mc_currency] => EUR
[mc_gross] => 524.00
[protection_eligibility] => INELIGIBLE
[payment_gross] => 524.00
[payment_status] => Pending
[pending_reason] => unilateral
[payment_type] => instant
[item_name1] => iPhone X
[item_number1] => 1
[quantity1] => 1
[mc_gross_1] => 100.00
[item_name2] => HP Notebook
[item_number2] => 2
[quantity2] => 1
[mc_gross_2] => 299.00
[item_name3] => Laptop Bag
[item_number3] => 3
[quantity3] => 1
[mc_gross_3] => 125.00
[num_cart_items] => 3
[txn_type] => cart
[payment_date] => 2019-06-20T12:39:01Z
[business] => nuestrocorreo@gmail.com
[notify_version] => UNVERSIONED
[verify_sign] => AafExQbaKRVsBflEXz3fG2x2IuLiAsrid.bh8IJziQRbs.cEOXQNrEFI
)
And then inserting the products individually with your payment status either completed or pending is very easy
$stmt = $mysqli->prepare("INSERT INTO orden (id_user, id_product, product, quantity, price, payment_method) VALUES (?,?,?,?,?,?)");
for($i = 1;$i <= $_POST['num_cart_items']; $i++) {
$stmt->bind_param("iisiss",
$id_users,
$_POST['item_number' . $i],
$_POST['item_name' . $i],
$_POST['quantity' . $i],
$_POST['mc_gross_' . $i],
$transaccionPayPal['payment_status']
);
$stmt->execute();
}
Obtaining the following registered result:

How can I get these same results using the stripe payment gateway?
I already have the following base:
try {
$customer = \Stripe\Customer::create(array(
'email' => 'customer2@example.com',
'card' => $token
));
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => 500,
'description' => 'Event charge',
'currency' => 'usd'
));
$transactionData = [
'id' => $charge->id,
'id_customer' => $charge->customer,
'product' => $charge->description,
'amount' => $charge->amount,
'currency' => $charge->currency,
'status' => $charge->status
];
$stmt = $con->prepare("INSERT INTO stripe (token_stripe, id_transaction, id_customer, product, currency, amount, status) VALUES (?,?,?,?,?,?,?)");
$stmt->bind_param("sssssss", $token,$transactionData['id'],$transactionData['id_customer'],$transactionData['product'],$transactionData['currency'],$transactionData['amount'],$transactionData['status']);
$stmt->execute();
echo 'Successful transaction!';
