Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.84 KB | None | 0 0
  1. <?php
  2.  
  3. /*******************************************************************************
  4.  * Árukereső.hu trusted shop program
  5.  * Example code integration to the webshop
  6.  *
  7.  *
  8.  * Please note, that the example detailed below can not be simply copy-pasted
  9.  * into your webshop’s code, it has to be customized adequately.
  10.  *
  11.  * Setup steps:
  12.  * 1. Copy TrustedShop.php file to a place accessible by the webshop engine.
  13.  * 2. Copy this example code to the page of the webshop where the e-mail address
  14.  *    of the customer and the names of the purchased products are retrievable
  15.  *    from the webshop engine. Generally this is the webshop’s confirmation
  16.  *    page of the purchase.
  17.  * 3. Customize the pasted example code according to the following:
  18.  *    - Modify path of TrustedShop.php in require_once() in such a way that
  19.  *      the webshop engine can use it.
  20.  *    - Check that the proper WebAPI key is set, if not, modify it. You can find
  21.  *      the WebAPI key on the partner portal.
  22.  *    - Set the customer’s e-mail address.
  23.  *    - Add the names of the purchased products.
  24.  *    - Implement an error handling if you want (optional).
  25.  *
  26.  ******************************************************************************/
  27.  
  28. require_once 'TrustedShop.php';
  29.  
  30. try {
  31.  
  32.   // Provide your own WebAPI key.
  33.   // You can find your WebAPI key on your partner portal.
  34.  
  35.   $Client = new TrustedShop('dfa6cf4f397165288a07296f07e386b2');
  36.  
  37.   // Provide the e-mail address of your customer.
  38.   // You can retrieve the e-amil address from the webshop engine.
  39.  
  40.   $Client->SetEmail('somebody@example.com');
  41.  
  42.   // Provide the name of the purchased products.
  43.   // You can get the name of the products from the webshop engine.
  44.   // The AddProduct method must be called for each of the purchased products.
  45.   //
  46.   // It is optional to provide the name of the products, so if this data is not
  47.   // available, you can leave out the AddProduct calls.
  48.  
  49.   $Client->AddProduct('Name of first purchased product');
  50.   $Client->AddProduct('Name of second purchased product');
  51.  
  52.   // This method sends us the e-mail address and the name of the purchased
  53.   // products set above. After the data arrived to us, we store them
  54.   // with the time stamp and the WebAPI key.
  55.   // This lets us know that someone has purchased at your webshop, to whom
  56.   // we later have to send the questionnaire for evaluating your shop.
  57.   // The "Send()" operation doesn't send immediately. It generates a HTML output,
  58.   // puts into source of the page and the customer's browser will send the
  59.   // required informations us.
  60.  
  61.   $Client->Send();
  62.  
  63. } catch (Exception $Ex) {
  64.  
  65.   // Here you can implement error handling. The error message can be obtained
  66.   // in the manner shown below. Implementing error handling is optional.
  67.  
  68.   $ErrorMessage = $Ex->getMessage();
  69. }
  70.  
  71. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement