title: How to individually insert the products of the shopping cart after correctly making the payment?
body: <p>Using the <strong>PayPal</strong> payment gateway where all the products added to the shopping cart are issued by means of its form and the generation thereof with <strong>PHP</strong></p>
  
  <pre><code>&lt;?php
      while ($stmt-&gt;fetch()) {
          $key = array_search($id_product, $items);
          $total = $total + $price * $qty[$key];
  ?&gt;
  &lt;input name="item_number_&lt;?php echo $num;?&gt;" type="hidden" value="&lt;?php echo $id_product; ?&gt;"&gt;
  &lt;input name="item_name_&lt;?php echo $num;?&gt;" type="hidden" value="&lt;?php echo $product; ?&gt;"&gt;
  &lt;input name="amount_&lt;?php echo $num;?&gt;" type="hidden" value="&lt;?php echo number_format($price,2);?&gt;"&gt;
  &lt;input name="quantity_&lt;?php echo $num;?&gt;" type="hidden" value="&lt;?php echo $qty[$key];?&gt;"&gt;
  &lt;?php
      $num++;
      }
  ?&gt;
  </code></pre>
  
  <p>And its return of values:</p>
  
  <pre><code>Array
  (
      [payer_email] =&gt; testing-instructor@site.com
      [payer_id] =&gt; J95XSJRX4WXVS
      [payer_status] =&gt; VERIFIED
      [first_name] =&gt; Milck
      [last_name] =&gt; Jmkc
      [address_name] =&gt; Milck Jmkc
      [address_street] =&gt; calle Vilamarï¿½ 76993- 17469
      [address_city] =&gt; Albacete
      [address_state] =&gt; Albacete
      [address_country_code] =&gt; ES
      [address_zip] =&gt; 02001
      [residence_country] =&gt; ES
      [txn_id] =&gt; 71U73747YB4505702
      [mc_currency] =&gt; EUR
      [mc_gross] =&gt; 524.00
      [protection_eligibility] =&gt; INELIGIBLE
      [payment_gross] =&gt; 524.00
      [payment_status] =&gt; Pending
      [pending_reason] =&gt; unilateral
      [payment_type] =&gt; instant
      [item_name1] =&gt; iPhone X
      [item_number1] =&gt; 1
      [quantity1] =&gt; 1
      [mc_gross_1] =&gt; 100.00
      [item_name2] =&gt; HP Notebook
      [item_number2] =&gt; 2
      [quantity2] =&gt; 1
      [mc_gross_2] =&gt; 299.00
      [item_name3] =&gt; Laptop Bag
      [item_number3] =&gt; 3
      [quantity3] =&gt; 1
      [mc_gross_3] =&gt; 125.00
      [num_cart_items] =&gt; 3
      [txn_type] =&gt; cart
      [payment_date] =&gt; 2019-06-20T12:39:01Z
      [business] =&gt; nuestrocorreo@gmail.com
      [notify_version] =&gt; UNVERSIONED
      [verify_sign] =&gt; AafExQbaKRVsBflEXz3fG2x2IuLiAsrid.bh8IJziQRbs.cEOXQNrEFI
  )
  </code></pre>
  
  <p>And then inserting the products individually with your payment status either completed or pending is very easy</p>
  
  <pre><code>$stmt = $mysqli-&gt;prepare("INSERT INTO orden (id_user, id_product, product, quantity, price, payment_method) VALUES (?,?,?,?,?,?)");
  
  for($i = 1;$i &lt;= $_POST['num_cart_items']; $i++) {
      $stmt-&gt;bind_param("iisiss",
          $id_users,
          $_POST['item_number' . $i],
          $_POST['item_name' . $i],
          $_POST['quantity' . $i],
          $_POST['mc_gross_' . $i],
          $transaccionPayPal['payment_status']
      );
  
      $stmt-&gt;execute();
  }
  </code></pre>
  
  <p>Obtaining the following registered result:
  <a href="https://i.stack.imgur.com/9X9R3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9X9R3.png" alt="introducir la descripción de la imagen aquí"></a></p>
  
  <p><strong>How can I get these same results using the stripe payment gateway?</strong></p>
  
  <p>I already have the following base:</p>
  
  <pre><code>try {
      $customer = \Stripe\Customer::create(array(
          'email' =&gt; 'customer2@example.com',
          'card'  =&gt; $token
      ));
  
      $charge = \Stripe\Charge::create(array(
          'customer' =&gt; $customer-&gt;id,
          'amount'   =&gt; 500,
          'description' =&gt; 'Event charge',
          'currency' =&gt; 'usd'
      ));
  
      $transactionData = [
          'id' =&gt; $charge-&gt;id,
          'id_customer' =&gt; $charge-&gt;customer,
          'product' =&gt; $charge-&gt;description,
          'amount' =&gt; $charge-&gt;amount,
          'currency' =&gt; $charge-&gt;currency,
          'status' =&gt; $charge-&gt;status
      ];
  
      $stmt = $con-&gt;prepare("INSERT INTO stripe (token_stripe, id_transaction, id_customer, product, currency, amount, status) VALUES (?,?,?,?,?,?,?)");
      $stmt-&gt;bind_param("sssssss", $token,$transactionData['id'],$transactionData['id_customer'],$transactionData['product'],$transactionData['currency'],$transactionData['amount'],$transactionData['status']);
      $stmt-&gt;execute();
  
      echo 'Successful transaction!';
  </code></pre>
  
  <p>Obtaining the following registered result:
  <a href="https://i.stack.imgur.com/S7p4M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S7p4M.png" alt="introducir la descripción de la imagen aquí"></a></p>