-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from grongor/version-2
Introduce new API version.
- Loading branch information
Showing
24 changed files
with
844 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/vendor/ | ||
/composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
.PHONY: build clean test | ||
.PHONY: build build-dev clean test | ||
|
||
build: | ||
composer install --no-dev | ||
|
||
build-dev: | ||
composer install --dev | ||
|
||
clean: | ||
rm -rf $(CURDIR)/vendor | ||
rm -f $(CURDIR)/composer.lock | ||
|
||
test: build | ||
test: build-dev | ||
$(CURDIR)/vendor/bin/phpunit tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,57 @@ | ||
Heureka ověřeno PHP API | ||
======================= | ||
Heureka 'Ověřeno zákazníky' PHP API | ||
=================================== | ||
|
||
[Heureka Ověřeno](http://overeno.heureka.cz/) service API for PHP. | ||
[Heureka Ověřeno zákazníky](http://overeno.heureka.cz/) (ShopCertification) service API client implementation for PHP. | ||
|
||
Examples | ||
-------- | ||
|
||
You can check working examples in the folder `examples` of this repository. | ||
|
||
Usage | ||
----- | ||
|
||
Initialize Service using [your API key](http://sluzby.heureka.cz/sluzby/certifikat-spokojenosti/): | ||
Initialize class `Heureka\ShopCertification` using | ||
[your API key](http://sluzby.heureka.cz/sluzby/certifikat-spokojenosti/) (you need to log in): | ||
|
||
```php | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
$overeno = new \Heureka\Overeno('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); | ||
``` | ||
SK shops should initialize Heureka Overeno service with second parameter \Heureka\Overeno::LANGUAGE_SK: | ||
|
||
$overeno = new \Heureka\Overeno('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', \Heureka\Overeno::LANGUAGE_SK); | ||
|
||
Set customer email: | ||
|
||
```php | ||
$overeno->setEmail('[email protected]'); | ||
$shopCertification = new \Heureka\ShopCertification('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); | ||
``` | ||
|
||
Add product from order - encoded in UTF8 if possible. Service can handle WINDOWS-1250 and ISO-8859-2 if necessary | ||
|
||
**Keep in mind that your API key is only yours and it is supposed to be a secret.** Never post your API key to anyone, | ||
never put it into JavaScript or anywhere else. It should live on your server only. If you feel the need to break this | ||
rule then you are doing something wrong - please consult our [support department](http://onas.heureka.cz/kontakty) | ||
prior to any actions. | ||
|
||
SK shops should initialize the class with a service parameter in the options: | ||
|
||
```php | ||
$overeno->addProduct('Nokia N95'); | ||
$options = ['service' => \Heureka\ShopCertification::HEUREKA_SK]; | ||
$shopCertification = new \Heureka\ShopCertification('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', $options); | ||
``` | ||
|
||
Or add multiple products: | ||
Set the customer e-mail address: | ||
|
||
```php | ||
// array $products is populated elsewhere by shop application | ||
foreach ($products as $product) { | ||
$overeno->addProduct($product); | ||
} | ||
$shopCertification->setEmail('[email protected]'); | ||
``` | ||
or/and add products using [item ID](http://sluzby.heureka.cz/napoveda/xml-feed/#ITEM_ID): | ||
|
||
Set the customer's order ID (only integers are allowed): | ||
|
||
```php | ||
$overeno->addProductItemId('B1234'); | ||
$shopCertification->setOrderId(15195618851564); | ||
``` | ||
|
||
Provide order ID - BIGINT (0 - 18446744073709551615): | ||
|
||
Add products which the customer ordered (use IDs which you used in ITEM_ID field of the Heureka XML feed): | ||
```php | ||
$overeno->setOrderId(123456); | ||
$shopCertification->addProductItemId('B1234'); | ||
$shopCertification->addProductItemId('15968421'); | ||
$shopCertification->addProductItemId('814687'); | ||
``` | ||
|
||
Send the request: | ||
And finally send request to log the order: | ||
|
||
```php | ||
$overeno->send(); | ||
$shopCertification->logOrder(); | ||
``` | ||
|
||
[View all examples](https://github.com/heureka/heureka-overeno-php-api/tree/master/examples) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,36 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
try { | ||
$testingApiKey = '9b011a7086cfc0210cccfbdb7e51aac8'; // USE your own API key! | ||
|
||
$language = \Heureka\Overeno::LANGUAGE_CZ; // you can use LANGUAGE_SK as well | ||
|
||
$overeno = new \Heureka\Overeno($testingApiKey, $language); | ||
|
||
// set customer email - MANDATORY | ||
$overeno->setEmail('[email protected]'); | ||
|
||
/** | ||
* Products names should be provided in UTF-8 encoding. The service can handle | ||
* WINDOWS-1250 and ISO-8859-2 if necessary | ||
*/ | ||
$overeno->addProduct('Nokia N95'); | ||
|
||
/** | ||
* And/or add products using item ID | ||
*/ | ||
$overeno->addProductItemId('B1234'); | ||
|
||
// add order ID - BIGINT (0 - 18446744073709551615) | ||
$overeno->setOrderId(123456); | ||
|
||
// send request | ||
if ($overeno->send()) { | ||
print('Success'); | ||
} | ||
|
||
} catch (\Heureka\Overeno\Exception $e) { | ||
// handle errors | ||
print $e->getMessage(); | ||
} | ||
<?php | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
try { | ||
// Use your own API key here. And keep it secret! | ||
$apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; | ||
$options = [ | ||
// Use \Heureka\ShopCertification::HEUREKA_SK if your e-shop is on heureka.sk | ||
'service' => \Heureka\ShopCertification::HEUREKA_CZ, | ||
]; | ||
|
||
$shopCertification = new \Heureka\ShopCertification($apiKey, $options); | ||
|
||
// Set customer email - it is MANDATORY. | ||
$shopCertification->setEmail('[email protected]'); | ||
|
||
// Set order ID - it helps you track your customers' orders in Heureka shop administration. | ||
$shopCertification->setOrderId(1597884); | ||
|
||
// Add products using ITEM_ID (your products ID) - you HAVE TO put in all the products which the customer ordered. | ||
$shopCertification->addProductItemId('165899412'); | ||
$shopCertification->addProductItemId('998884614'); | ||
|
||
// And finally send the order to our service. | ||
$shopCertification->logOrder(); | ||
|
||
// Everything went well - we are done here. | ||
// You can redirect the customer to some nice page and thank him for the order. :-) | ||
|
||
} catch (\Heureka\ShopCertification\Exception $e) { | ||
// Something unexpected happened. | ||
// We can print the message for debug purposes only, | ||
// DO NOT ever do that on your production environment. | ||
var_dump($e->getMessage()); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.