Create the POST-message according to the API reference. The example code is populated with example data for a test order.

$postData holds the array that you’ll send to Hygglig. In the array you must have the following:

  • Merchant key = Your key
  • Checksum = SHA1(totalamount of cart and secret key)
  • Articles = Your cart items
  • Prices are including VAT multiplied with 100
  • Quantity should be multiplied with 100
  • Total amount is: (Price of items * 100) * (Quantity of items * 100)
// POST-message
$startCheckoutAPIAddress ="";
$totalAmount = 6000000;
$startCheckoutCheckSum = (SHA1($totalAmount . $secret));
$postData = array(
   'MerchantKey' => $key,
   'Checksum' => $startCheckoutCheckSum,
   'SuccessURL' => '',
   'CheckoutURL' => '',
   'OrderReference' => '123456',
   'TermsURL' => '',
   'Email' => '',
   'Postcode' => '10000',
   'PushNotificationURL' => '',
   'Currency' => 'SEK',
   'Articles' => array(
         'ArticleName' => 'Hygglig Artikel',
         'Description'=>'En fantastisk artikel från Hygglig',
         'ArticleName' => 'Frakt',
         'Description'=>'Fraktsätt: Hyggligt',

Optimize the checkout for returning customers

When you render the checkout iframe you may add data about the consumer;
Email and Postcode.

We at Hygglig recommend using this feature for consumers who log into an account on your page where you already have stored data about the consumer. If you choose to add consumer data, the consumer will not need to re-enter the data into the checkout, and your conversion will increase.

If optional data is sent, the consumer will reach the checkout in the last state, presented with a “one click purchase” possibility.

Receive the answer from Hygglig

Receive and validate the response from Hygglig:

  • A successfull request for iFrame will grant you a Token value.
  • Any unsuccessfull atempts will give you an error code and error description in return.

Note: If a checkout session already exists, you should use the already configured order in that session instead of creating a new checkout session. This will provide a better user experience.

if(responseValidation($response) === FALSE){
//Print response code
echo "Error type: " . $response['Error']['Description'];
echo "Error number: " . $response['Error']['Code']; }
//Continue to req of iframe }

Get the Checkout iFrame

Now get the iFrame.

$getiframeCheckSum = SHA1(strtoupper($token.$secret));
$getiframeAPIAddress = "";
$postData = array(
'MerchantKey' => $key,
'Checksum' => $getiframeCheckSum,
'Token' => $token, );

Render the checkout

Echo out the HtmlText to display the Hygglig Checkout.

//Validate response and then display HTML
$text = $response["HtmlText"];
echo $text;

Use our demo shop to get an idea of how it can look

Go ahead – add a product and go to checkout