title: Klarna Checkout KCO validate
body: <p>I a trying to validate that the customer is above 20 thru Klarna Checkout.</p>
  
  <p>They have a built in function for validating, see here <a href="https://developers.klarna.com/en/se/kco-v2/checkout/use-cases#validate-checkout-order" rel="nofollow">https://developers.klarna.com/en/se/kco-v2/checkout/use-cases#validate-checkout-order</a></p>
  
  <p><strong>The checkout.php page looks like this</strong> </p>
  
  <pre><code>Accept: application/vnd.klarna.checkout.aggregated-order-v2+json
  Authorization: Klarna pwhcueUff0MmwLShJiBE9JHA==
  Content-Type: application/vnd.klarna.checkout.aggregated-order-v2+json
  
  {
      "purchase_country": "se",
      "purchase_currency": "sek",
      "locale": "sv-se",
      "cart": {
          "items": [
              {
                  "reference": "123456789",
                  "name": "Klarna t-shirt",
                  "quantity": 2,
                  "unit_price": 12300,
                  "discount": 1000,
                  "tax_rate": 2500
              },
              {
                  "type": "shipping_fee",
                  "reference": "SHIPPING",
                  "name": "Shipping fee",
                  "quantity": 1,
                  "unit_price": 4900,
                  "tax_rate": 2500
              }
          ]
      },
          "merchant": {
          "id": "0",
          "terms_uri": "http://example.com/terms.php",
          "checkout_uri": "https://example.com/checkout.php",
          "confirmation_uri": "https://example.com/thankyou.php?sid=123&amp;klarna_order={checkout.order.uri}",
          "push_uri": "https://example.com/push.php?sid=123&amp;klarna_order={checkout.order.uri}",
          "validation_uri": "https://example.com/klarna_validation.php"
      }
  }
  </code></pre>
  
  <p>When a customer cliks "buy now" the klarna_validation.php script runs, and sends a return to Klarna with a HTTP status 202 OK or 303 SEE OTHER.</p>
  
  <p><strong>Below are my klarna_validation.php</strong></p>
  
  <pre><code>&lt;?php
      $pno = $_POST['customer']['date_of_birth'];
      $birthdate = new DateTime("$pno");
      $today     = new DateTime();
      $interval  = $today-&gt;diff($birthdate);
      $interval2 = $interval-&gt;format('%y');
      if($interval2 &lt;= "20"){
      header("Location: https://example.com/too_young.php?$pno", true, 303);
      exit;
      } else {
      http_response_code(200);
      }
  ?&gt;
  </code></pre>
  
  <p><strong>According to Klarna:</strong> <em>POST request will be sent to the merchant.validation_uri. The body of the request will contain the current order information. The structure of the order information is identical to the result of fetching the order, as you saw in render the checkout.</em></p>
  
  <p>The thing is that i don't get any data with 
  <strong>$_POST['customer']['date_of_birth'];</strong> it's empty.</p>
  
  <p>To validate that this <strong>$_POST['customer']['date_of_birth'];</strong> is empty i have included it in the URL of the too_young.php page, like this (too_young.php?$pno). When landing on too_young.php the $pno is empty! (The urls looks like this too_young.php?)</p>
  
  <p>Does anyone have an idea of what i am doing wrong?</p>