EasyWebshop API
Το Application Programming Interface (API) γεφυρώνει το ηλεκτρονικό σας κατάστημα με εξωτερικές πλατφόρμες, όπως παρόχους πληρωμών, υπηρεσίες παράδοσης και εφαρμογές γραφείου. Έχουμε καταβάλει τεράστια προσπάθεια για να καταστήσουμε το API εύχρηστο, ακόμη και για μη τεχνικούς σπασίκλες. Αυτό σε ορισμένες περιπτώσεις θα επιτρέψει στους χρήστες μας να συνδέσουν το δικό τους webshop μόνοι τους, αντί να βασίζονται σε έναν ακριβό προγραμματιστή.
Χάρη στη συμβατότητα με τις γενικές πρακτικές και τα βιομηχανικά πρότυπα, οι συνδέσεις με το API μας μπορούν να γίνουν γρήγορα και ενδεχομένως με τη βοήθεια κώδικα που παράγεται από τεχνητή νοημοσύνη. Διαβάστε προσεκτικά αυτή τη σελίδα αν θέλετε να δημιουργήσετε μια σύνδεση μόνοι σας.
Επισκόπηση χαρακτηριστικών
- Σύνδεση με παρόχους υπηρεσιών πληρωμών
- Σύνδεση με υπηρεσίες παράδοσης
- Σύνδεση με λογισμικό POS, τοπικό και cloud
- Εισαγωγή προϊόντων από προμηθευτές ή χονδρέμπορους
- Εξαγωγή προϊόντων σε ιστότοπους σύγκρισης
- Σύνδεση λογισμικού τιμολόγησης
- Σύνδεση λογισμικού CRM
- Σύνδεση λογισμικού διαχείρισης logistics
- Ενημέρωση αποθεμάτων (απογραφή) σε πραγματικό χρόνο
- Αποδοχή ή απόρριψη πελατών βάσει συγκεκριμένων κριτηρίων
- Εξαγωγή παραγγελιών σε πραγματικό χρόνο για drop shipping
- Εξαγωγή πελατών για εφαρμογές ενημερωτικών δελτίων
- Εξαγωγή δεδομένων για αναφορές και αναλύσεις
- Δημιουργία συνδέσεων που εγκαθιστούν widgets HTML/JavaScript/CSS με το πάτημα ενός κουμπιού
- Δημιουργία προσαρμοσμένων αναφορών για αποθέματα, παραγγελίες, πελάτες και πωλήσεις
API, API Push και συνδέσεις
API | API Push | συνδέσεις |
---|---|---|
Για την εισαγωγή και εξαγωγή κατηγοριών, προϊόντων, παραγγελιών και πελατών. | Για το συγχρονισμό των αποθεμάτων ή την αποδοχή πελατών σε πραγματικό χρόνο. | Για τη σύνδεση παρόχων πληρωμών, υπηρεσιών παράδοσης, ιστότοπων σύγκρισης, σημείων πώλησης, εφαρμογών τιμολόγησης και εγκατάστασης widgets. |
Πιστοποίηση ταυτότητας με κουπόνι φορέα. | Εισαγωγή της διεύθυνσης URL Push στην ενότητα API. | Αυθεντικοποίηση με Bearer token (σύνδεση) και εγκατάσταση της σύνδεσης (χρήστης). |
Προσαρμοσμένη σε έναν χρήστη. | Προσαρμοσμένη σε έναν χρήστη. | Μπορεί να εγκατασταθεί από όλους τους χρήστες. |
API
Ενεργοποιήστε το EasyWebshop API στη διεύθυνση Ρυθμίσεις > Ενότητες > Easywebshop API χρησιμοποιώντας τον κωδικό ενεργοποίησης MODA.
Εάν το EasyWebshop API δεν εμφανίζεται στο μενού, μεταβείτε στο Ρυθμίσεις > Περισσότερες επιλογές > Επίπεδο εμπειρίας χρήστη και αλλάξτε το επίπεδο εμπειρίας χρήστη σε Εμπειρογνώμονας
Ενεργοποιήστε το API μόνο αν πρόκειται να το χρησιμοποιήσετε. Για λόγους ασφαλείας, απενεργοποιήστε το API όταν δεν το χρησιμοποιείτε.
- Τελικό σημείο APIαντίγραφο
- https://easywebshop.com/apiΧρησιμοποιείτε πάντα την έκδοση https! Η αυθεντικοποίηση μέσω http απλού κειμένου μπορεί να προκαλέσει διαρροή του Token API σας.
Μην περιλαμβάνετε τον υποτομέα www. - ?format=xml
- Αλλάξτε τη μορφή εξόδου από JSON σε XML.
- ?pretty=1
- Όμορφη έξοδος για βελτιωμένη αναγνωσιμότητα από τον άνθρωπο. Αφαιρέστε το για εξοικονόμηση εύρους ζώνης σε αυτοματοποιημένα συστήματα.
Όταν χρησιμοποιείτε πολλαπλές παραμέτρους, διαχωρίστε τις με & (τελεία και παύλα). Για παράδειγμα: ?format=xml&pretty=1.
Στη γραμμή εντολών, αποφύγετε τις τελείες ως εξής: ?format=xml\&pretty=1.
Χρησιμοποιήστε το API μας με προσοχή και ζητήστε ή ενημερώστε μόνο ό,τι χρειάζεστε. Μην χρησιμοποιείτε τη λειτουργία polling, εάν αντί αυτής μπορεί να χρησιμοποιηθεί η λειτουργία API Push Τα Όρια επιβάλλονται για να αποφευχθεί η σπατάλη πόρων του διακομιστή.
Αυθεντικοποίηση
Κάντε κλικ στο κουμπί Add για να δημιουργήσετε ένα API Token και επιλέξτε τα επιθυμητά δικαιώματα για αυτό το token.
Για μεγαλύτερη ασφάλεια, επιλέξτε μόνο τα δικαιώματα που είναι απολύτως απαραίτητα. Ανακαλέστε τα δικαιώματα όταν δεν είναι απαραίτητα.
Μετά την αποθήκευση, αντιγράψτε το Token API για χρήση στην εφαρμογή σας ή για να το στείλετε σε έναν προγραμματιστή. Μπορείτε να το κάνετε αυτό μόνο μία φορά: αν χάσετε το Token API σας, θα πρέπει να το διαγράψετε και να δημιουργήσετε ένα νέο.
Χρησιμοποιήστε το Token API με προσοχή.
Μην στέλνετε το Token API σας μέσω ενός μη ασφαλούς καναλιού επικοινωνίας, όπως το email ή το WhatsApp. Συνιστούμε το SimpleX Chat εάν πρέπει να στείλετε το Token API σας σε έναν προγραμματιστή. Μην αποθηκεύετε το Token API σας σε μη ασφαλή συσκευή. Δεν αποθηκεύουμε καθόλου το Token API σας, παρά μόνο ένα hash αυτού.
- Αίτηση
- Απόκριση
- curl
- PHP
GET /api/status HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
HTTP/2 200
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"status": "success",
"message": "API online"
}
Ανάκτηση της κατάστασης του API
curl -D - https://easywebshop.com/api/status
Αποθηκεύει την απόκριση σε αρχείο JSON
curl https://easywebshop.com/api/status -o status.json
-D, --dump-header
-o, --output <file>
curl man page:
https://curl.se/docs/manpage.html
<?php
header("Content-Type: text/plain");
// API endpoint
const API_URL = 'https://easywebshop.com/api/status';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Optional: If you are sending data (e.g., for a POST request)
// Uncomment the following lines to send a JSON payload
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
*/
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
}
// Close the cURL session
curl_close($ch);
?>
Σε αυτή την τεκμηρίωση, παρέχουμε παραδείγματα για curl και PHP Η σύγχρονη τεχνητή νοημοσύνη είναι όλο και πιο καλή στη μετατροπή κώδικα σε άλλες γλώσσες προγραμματισμού, όπως η C, η Java ή η Python.
Κατηγορίες
Προβολή κατηγοριών
- GET /api/category
- Ανάκτηση όλων των κατηγοριών
- GET /api/category/[categoryName]
- Ανάκτηση όλων των προϊόντων σε μια συγκεκριμένη κατηγορία
Χρήση του ονόματος της κατηγορίας στην προεπιλεγμένη γλώσσα του ηλεκτρονικού καταστήματος
GET /api/category HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
HTTP/2 200
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"categorylist": [
{
"category": {
"name:lang=en": "Cocktails",
"name:lang=fr": "Cocktails",
"name:lang=nl": "Cocktails",
"visible": "1",
"image": "https:\/\/ew.ms\/shops\/fashion\/category\/cocktails.jpg",
"url": "https:\/\/all4you.be\/cocktails",
"categorylist": [
{
"category": {
"name:lang=en": "Non-alcoholic",
"name:lang=fr": "Sans alcool",
"name:lang=nl": "Alcoholvrij",
"visible": "1",
"url": "https:\/\/all4you.be\/non-alcoholic"
}
}
]
}
}
]
}
Ανάκτηση όλων των κατηγοριών
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/category
Ανάκτηση όλων των προϊόντων σε μια συγκεκριμένη κατηγορία
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/category/Cocktails
Ανάκτηση όλων των κατηγοριών σε αναγνώσιμη από τον άνθρωπο μορφή JSON
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/category?pretty=1
Ανάκτηση όλων των κατηγοριών σε αναγνώσιμη από τον άνθρωπο μορφή XML
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/category?format=xml\&pretty=1
<?php
header("Content-Type: text/plain");
// API endpoint
// You can add a category name behind the slash for searching products within that category
const API_URL = 'https://easywebshop.com/api/category/';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Optional: If you are sending data (e.g., for a POST request)
// Uncomment the following lines to send a JSON payload
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
*/
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
// Print response in PHP array
if ($response_array = json_decode($response, true)) {
echo "\n\n" . print_r($response_array, true);
}
}
// Close the cURL session
curl_close($ch);
?>
{
"categorylist": [
{
"category": {
"name:lang=en": "Cocktails",
"name:lang=fr": "Cocktails",
"name:lang=nl": "Cocktails",
"visible": "1",
"image": "https:\/\/ew.ms\/shops\/fashion\/category\/cocktails.jpg",
"url": "https:\/\/all4you.be\/cocktails",
"categorylist": [
{
"category": {
"name:lang=en": "Non-alcoholic",
"name:lang=fr": "Sans alcool",
"name:lang=nl": "Alcoholvrij",
"visible": "1",
"url": "https:\/\/all4you.be\/non-alcoholic"
}
}
]
}
}
]
}
<?xml version="1.0" encoding="UTF-8" ?>
<categorylist>
<category>
<name lang="en">Cocktails</name>
<name lang="fr">Cocktails</name>
<name lang="nl">Cocktails</name>
<visible>1</visible>
<image>https://ew.ms/shops/fashion/category/cocktails.jpg</image>
<url>https://all4you.be/cocktails</url>
<categorylist>
<category>
<name lang="en">Non-alcoholic</name>
<name lang="fr">Sans alcool</name>
<name lang="nl">Alcoholvrij</name>
<visible>1</visible>
<url>https://all4you.be/non-alcoholic</url>
</category>
</categorylist>
</category>
</categorylist>
Οι κατηγορίες μπορούν να προβληθούν μόνο. Δεν υπάρχει υλοποίηση API για τη δημιουργία, την επεξεργασία και τη διαγραφή κατηγοριών, επειδή αυτές οι λειτουργίες χρησιμοποιούνται σπάνια και θα δημιουργούσαν πρόσθετη επιφάνεια επίθεσης. Η διαχείριση των κατηγοριών μπορεί να γίνει με τη χρήση της διεπαφής ιστού.
Προιόντα
Προβολή προϊόντων
EasyWebshop ακολουθεί τη μορφή schema.org/Product όποτε είναι δυνατόν.
- GET /api/product
- Ανακτά τα τελευταία 1000 προϊόντα
- GET /api/product?offset=1000
- Ανακτά τα τελευταία 1000 προϊόντα, αλλά παραλείπει τα πρώτα 1000 προϊόντα
- GET /api/product/86400
- Ανακτά προϊόντα που προστέθηκαν ή τροποποιήθηκαν τις τελευταίες 24 ώρες.
- GET /api/product/[productID]
- Αναζητά ένα προϊόν με βάση το productID, με ευαισθησία στην πεζότητα
GET /api/product HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
HTTP/2 200
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"productlist": [
{
"product": {
"productID": "LA-B03",
"category": "Ambiance",
"price": 49.99,
"stock": 0,
"weight": 5,
"status": "Available",
"vat_code": 0,
"old_price": "75",
"colors": "Blue,Red,Violet",
"promotion": 1
}
},
{
"product": {
"productID": "LA-C05",
"category": "Ambiance",
"name:lang=en": "Example paint",
"name:lang=nl": "Voorbeeld verf",
"description:lang=en": "Lorem ipsum dolor sit amet.",
"price": 79,
"stock": 1,
"status": "Available",
"weight": 5,
"vat_code": 0,
"condition": "New",
"gtin": "123456",
"old_price": "179",
"units": "test",
"mpq": 1,
"purchase_price": 50,
"promo": 1,
"label_id": 1,
"colors": "Blue,Red,Violet",
"params": "T,en,Name,,,\nS,en,Select size,[A|B|C],A,1",
"review": 1
}
},
{
"product": {
"productID": "LA-C05-A",
"parent_productID": "LA-C05",
"name:lang=en": "Variation A",
"price": "79",
"colors": "LightCoral"
}
},
{
"product": {
"productID": "LA-C05-B",
"parent_productID": "LA-C05",
"name:lang=en": "Variation B",
"price": "89"
}
}
]
}
Ανακτά τα τελευταία 1000 προϊόντα
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/product
Ανακτά τα τελευταία 1000 προϊόντα, αλλά παραλείπει τα πρώτα 1000 προϊόντα
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/product?offset=1000
Ανακτά προϊόντα που προστέθηκαν ή τροποποιήθηκαν τις τελευταίες 24 ώρες.
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/product/86400
Αναζητά ένα προϊόν με βάση το productID, με ευαισθησία στην πεζότητα
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/product/LA-C05
<?php
header("Content-Type: text/plain");
// API endpoint
// You can add a product search behind the slash
const API_URL = 'https://easywebshop.com/api/product/';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Optional: If you are sending data (e.g., for a POST request)
// Uncomment the following lines to send a JSON payload
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
*/
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
// Print response in PHP array
if ($categories = json_decode($response, true)) {
echo "\n\n" . print_r($categories, true);
}
}
// Close the cURL session
curl_close($ch);
?>
{
"productlist": [
{
"product": {
"productID": "LA-B03",
"category": "Ambiance",
"price": 49.99,
"stock": 0,
"weight": 5,
"status": "Available",
"vat_code": 0,
"old_price": "75",
"colors": "Blue,Red,Violet",
"promotion": 1
}
},
{
"product": {
"productID": "LA-C05",
"category": "Ambiance",
"name:lang=en": "Example paint",
"name:lang=nl": "Voorbeeld verf",
"description:lang=en": "Lorem ipsum dolor sit amet.",
"price": 79,
"stock": 1,
"status": "Available",
"weight": 5,
"vat_code": 0,
"condition": "New",
"gtin": "123456",
"old_price": "179",
"units": "test",
"mpq": 1,
"purchase_price": 50,
"promo": 1,
"label_id": 1,
"colors": "Blue,Red,Violet",
"params": "T,en,Name,,,\nS,en,Select size,[A|B|C],A,1",
"review": 1
}
},
{
"product": {
"productID": "LA-C05-A",
"parent_productID": "LA-C05",
"name:lang=en": "Variation A",
"price": "79",
"colors": "LightCoral"
}
},
{
"product": {
"productID": "LA-C05-B",
"parent_productID": "LA-C05",
"name:lang=en": "Variation B",
"price": "89"
}
}
]
}
<?xml version="1.0" encoding="UTF-8" ?>
<productlist>
<product>
<productID>LA-B03</productID>
<category>Ambiance</category>
<price>49.99</price>
<stock>0</stock>
<weight>5</weight>
<status>Available</status>
<vat_code>0</vat_code>
<old_price>75</old_price>
<colors>Blue,Red,Violet</colors>
<promotion>1</promotion>
</product>
<product>
<productID>LA-C05</productID>
<category>Ambiance</category>
<name lang="en">Example paint</name>
<name lang="nl">Voorbeeld verf</name>
<description lang="en">Lorem ipsum dolor sit amet.</description>
<price>79</price>
<stock>1</stock>
<status>Available</status>
<weight>5</weight>
<vat_code>0</vat_code>
<condition>New</condition>
<gtin>123456</gtin>
<old_price>179</old_price>
<units>test</units>
<mpq>1</mpq>
<purchase_price>50</purchase_price>
<promo>1</promo>
<label_id>1</label_id>
<colors>Blue,Red,Violet</colors>
<params>T,en,Name,,,
S,en,Select size,[A|B|C],A,1</params>
<review>1</review>
</product>
<product>
<productID>LA-C05-A</productID>
<parent_productID>LA-C05</parent_productID>
<name lang="en">Variation A</name>
<price>79</price>
<colors>LightCoral</colors>
</product>
<product>
<productID>LA-C05-B</productID>
<parent_productID>LA-C05</parent_productID>
<name lang="en">Variation B</name>
<price>89</price>
</product>
</productlist>
Εισαγωγή προϊόντων
- POST /api/product
- Σε περίπτωση επιτυχίας, θα επιστραφεί 201 Created
POST /api/product HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"productlist": [
{
"product": {
"productID": "LA-B03",
"category": "Ambiance",
"price": 49.99,
"stock": 0,
"weight": 5,
"status": "Available",
"vat_code": 0,
"old_price": "75",
"colors": "Blue,Red,Violet",
"promotion": 1
}
},
{
"product": {
"productID": "LA-C05",
"category": "Ambiance",
"name:lang=en": "Example paint",
"name:lang=nl": "Voorbeeld verf",
"description:lang=en": "Lorem ipsum dolor sit amet.",
"price": 79,
"stock": 1,
"status": "Available",
"weight": 5,
"vat_code": 0,
"condition": "New",
"gtin": "123456",
"old_price": "179",
"units": "test",
"mpq": 1,
"purchase_price": 50,
"promo": 1,
"label_id": 1,
"colors": "Blue,Red,Violet",
"params": "T,en,Name,,,\nS,en,Select size,[A|B|C],A,1",
"review": 1
}
},
{
"product": {
"productID": "LA-C05-A",
"parent_productID": "LA-C05",
"name:lang=en": "Variation A",
"price": "79",
"colors": "LightCoral"
}
},
{
"product": {
"productID": "LA-C05-B",
"parent_productID": "LA-C05",
"name:lang=en": "Variation B",
"price": "89"
}
}
]
}
HTTP/2 201
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"status": "success",
"message": [
"4 products inserted"
]
}
curl -X POST -H "Authorization: Bearer YOUR_API_TOKEN" -d @product-import.json https://easywebshop.com/api/product
<?php
header("Content-Type: text/plain");
// API endpoint
const API_URL = 'https://easywebshop.com/api/product/';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Uncomment the following lines to set data in PHP
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
$data = json_encode($data);
*/
// Get data from file
$data = file_get_contents('product-import.json');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
// Print response in PHP array
if ($response_array = json_decode($response, true)) {
echo "\n\n" . print_r($response_array, true);
}
}
// Close the cURL session
curl_close($ch);
?>
{
"productlist": [
{
"product": {
"productID": "LA-B03",
"category": "Ambiance",
"price": 49.99,
"stock": 0,
"weight": 5,
"status": "Available",
"vat_code": 0,
"old_price": "75",
"colors": "Blue,Red,Violet",
"promotion": 1
}
},
{
"product": {
"productID": "LA-C05",
"category": "Ambiance",
"name:lang=en": "Example paint",
"name:lang=nl": "Voorbeeld verf",
"description:lang=en": "Lorem ipsum dolor sit amet.",
"price": 79,
"stock": 1,
"status": "Available",
"weight": 5,
"vat_code": 0,
"condition": "New",
"gtin": "123456",
"old_price": "179",
"units": "test",
"mpq": 1,
"purchase_price": 50,
"promo": 1,
"label_id": 1,
"colors": "Blue,Red,Violet",
"params": "T,en,Name,,,\nS,en,Select size,[A|B|C],A,1",
"review": 1
}
},
{
"product": {
"productID": "LA-C05-A",
"parent_productID": "LA-C05",
"name:lang=en": "Variation A",
"price": "79",
"colors": "LightCoral"
}
},
{
"product": {
"productID": "LA-C05-B",
"parent_productID": "LA-C05",
"name:lang=en": "Variation B",
"price": "89"
}
}
]
}
<?xml version="1.0" encoding="UTF-8" ?>
<productlist>
<product>
<productID>LA-B03</productID>
<category>Ambiance</category>
<price>49.99</price>
<stock>0</stock>
<weight>5</weight>
<status>Available</status>
<vat_code>0</vat_code>
<old_price>75</old_price>
<colors>Blue,Red,Violet</colors>
<promotion>1</promotion>
</product>
<product>
<productID>LA-C05</productID>
<category>Ambiance</category>
<name lang="en">Example paint</name>
<name lang="nl">Voorbeeld verf</name>
<description lang="en">Lorem ipsum dolor sit amet.</description>
<price>79</price>
<stock>1</stock>
<status>Available</status>
<weight>5</weight>
<vat_code>0</vat_code>
<condition>New</condition>
<gtin>123456</gtin>
<old_price>179</old_price>
<units>test</units>
<mpq>1</mpq>
<purchase_price>50</purchase_price>
<promo>1</promo>
<label_id>1</label_id>
<colors>Blue,Red,Violet</colors>
<params>T,en,Name,,,
S,en,Select size,[A|B|C],A,1</params>
<review>1</review>
</product>
<product>
<productID>LA-C05-A</productID>
<parent_productID>LA-C05</parent_productID>
<name lang="en">Variation A</name>
<price>79</price>
<colors>LightCoral</colors>
</product>
<product>
<productID>LA-C05-B</productID>
<parent_productID>LA-C05</parent_productID>
<name lang="en">Variation B</name>
<price>89</price>
</product>
</productlist>
Μπορείτε να βρείτε λεπτομερή επεξήγηση όλων των πεδίων προϊόντων στη σελίδα τεκμηρίωσης της Βασικής διαχείρισης προϊόντων και της Προχωρημένης διαχείρισης προϊόντων
Παράμετρος | Τύπος | Περιγραφή |
---|---|---|
productID | string | Προιόν. Ένα μοναδικό και καθορισμένο από τον χρήστη αναγνωριστικό για το προϊόν. Αποφύγετε τους ειδικούς χαρακτήρες και τα διπλά ή διφορούμενα αναγνωριστικά. Κατά την επεξεργασία ενός προϊόντος, το productID χρησιμοποιείται ως αναγνωριστικό. Το productID μπορεί να αλλάξει μόνο με τη διαχείριση του προϊόντος. |
parent_productID | string | Εάν θέλετε αυτό το προϊόν να είναι μια παραλλαγή προϊόντος, εισαγάγετε εδώ το productID του μητρικού προϊόντος. Οι παραλλαγές λειτουργούν σαν προϊόντα από μόνα τους. Συνδέονται με ένα γονικό προϊόν αντί για μια κατηγορία και επομένως δεν είναι ορατές στις λίστες προϊόντων. Οι υποπαραλλαγές δεν συνιστώνται και μπορούν να οριστούν μόνο με τη διαχείριση προϊόντων. |
category | string | Το όνομα της κατηγορίας στην προεπιλεγμένη γλώσσα του ηλεκτρονικού καταστήματος. Δεν ισχύει για τις παραλλαγές προϊόντων. |
name:lang | string | Ονομα. Μπορείτε να ορίσετε ονόματα και περιγραφές για όλες τις γλώσσες, ακόμη και αν δεν είναι ενεργοποιημένες στο webshop. Διαθέσιμες γλώσσες (ISO 639-1): cs, da, de, el, en, es, fi, fr, it, ja, ko, nl, no, pl, pt, ro, ru, sv, tr, zh |
description:lang | string | Περιγραφή Διαθέσιμες γλώσσες (ISO 639-1): cs, da, de, el, en, es, fi, fr, it, ja, ko, nl, no, pl, pt, ro, ru, sv, tr, zh |
price | string | Τιμή. Μπορεί να είναι δεκαδικός, ακέραιος, κενό ή μια συμβολοσειρά. |
stock | integer | Διαθέσιμο απόθεμα. Αφήστε το 0 για άπειρο απόθεμα ή απενεργοποιημένο απόθεμα. |
status | string | Καθεστώς Available, Available but not online, Pre-order, Sold Out, Invisible, Customers only, Price visible for customers, Choose property, Hide status, custom0, custom1, ..., custom9 |
image:no | string | Συμπεριλάβετε μια διεύθυνση URL εικόνας για να ανεβάσετε φωτογραφίες προϊόντων Η πρώτη εικόνα είναι η κύρια φωτογραφία, οι επόμενες τέσσερις είναι οι υποφωτογραφίες. Όταν μια φωτογραφία προϊόντος υπάρχει ήδη, θα αντικατασταθεί. Μετά το ανέβασμα, οι εικόνες θα κλιμακωθούν αναλογικά σύμφωνα με τις ρυθμίσεις του ηλεκτρονικού καταστήματος, θα δημιουργηθούν αυτόματα μικρογραφίες και η εικόνα θα συγχρονιστεί σε πολλαπλούς διακομιστές αρχείων. Βεβαιωθείτε ότι κάθε εικόνα έχει έγκυρη διεύθυνση URL, μέγιστο μέγεθος αρχείου 25MB, έγκυρη επέκταση (.jpg, .jpeg, .png ή .gif) και έγκυρο τύπο MIME (image/jpeg, image/jpg, image/png, image/gif). Το ανέβασμα εικόνων απαιτεί χρόνο και πόρους του διακομιστή. Αποφύγετε την αντικατάσταση των ίδιων εικόνων κατά την ενημέρωση των προϊόντων. Εάν αντιμετωπίσετε χρονικές διακοπές, ανεβάστε περιορισμένο αριθμό προϊόντων σε παρτίδες των 25 εικόνων η καθεμία.1 - 5 |
thumbnail:no | string | Οι μικρογραφίες δημιουργούνται αυτόματα. Αυτή είναι μια παράμετρος μόνο για ανάγνωση. |
weight | decimal | Βάρος. Μονάδα SI χιλιόγραμμο. |
vat_code | integer | συντελεστής ΦΠΑ. Συντελεστής ΦΠΑ που έχει οριστεί στις Ρυθμίσεις τιμολογίου 0, 1, 2 |
condition | string | Kατάσταση New, Used, Refurbished |
gtin | string | Κωδικός EAN |
old_price | string | Παλαιά τιμή |
units | string | Ποσότητα τεμαχίων |
mpq | integer | Ελάχιστη αγορά |
purchase_price | decimal | τιμή κτήσεως |
promo | boolean | Προωθήστε αυτό το προϊόν στην αρχική σελίδα του καταστήματός μου. Δεν ισχύει για παραλλαγές προϊόντων. |
label_id | integer | Ετικέτα. Αφήστε το 0 για να μην υπάρχει ετικέτα. Δεν ισχύει για παραλλαγές προϊόντων. 0 - 100 |
colors | string | Χρωματιστά. Επιλέξτε από τα 256 ασφαλή ονόματα χρωμάτων στο διαδίκτυο στα αγγλικά, χωρισμένα με κόμμα. |
params | string | Προσαρμογή προϊόντων. Οι παράμετροι έχουν ειδική μορφή και μπορούν να οριστούν καλύτερα χρησιμοποιώντας το περιβάλλον διαχείρισης προϊόντων. Μόλις έχετε ένα παράδειγμα, μπορείτε να το αντιγράψετε για εισαγωγή. |
review | boolean | Γνώμες. Ενεργοποιήστε ή απενεργοποιήστε τις κριτικές προϊόντων. |
last_update | datetime | Τελευταία Δραστηριότητα. Μόνο για ανάγνωση. |
Αυτές οι ενότητες μπορούν να οριστούν μόνο μέσω της διεπαφής διαχείρισης: Εκπτωση όγκου, Ομάδες πελατών, Δωροεπιταγές, Κρατήσεις, Εικονικά προϊόντα, Φίλτρα, Παρόμοια προϊόντα.
Μπορούν να εισαχθούν ταυτόχρονα έως και 100 προϊόντα. Αν θέλετε να εισάγετε περισσότερα προϊόντα, μπορείτε να επαναλάβετε την εντολή μία φορά κάθε 5 λεπτά.
Επεξεργασία προϊόντων
Μπορείτε επίσης να επεξεργαστείτε προϊόντα χρησιμοποιώντας τη λειτουργία γρήγορης επεξεργασίας, τη λειτουργία εισαγωγής και τη λειτουργία μαζικών λειτουργιών
- PUT /api/product
- Σε περίπτωση επιτυχίας, θα επιστραφεί 200 OK
PUT /api/product HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"productlist": [
{
"product": {
"code": "LA-C05",
"price": 16,
"status": "Available",
"stock": 7,
"image:no=1": "https://easywebshop.com/img/slideshow/9001.jpg",
"image:no=2": "https://easywebshop.com/img/easywebshop.png"
}
},
{
"product": {
"code": "SI-V55",
"price": "28",
"status": "Sold Out",
"stock": "0",
"weight": "2",
"old_price": "43"
}
}
]
}
HTTP/2 200
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"status": "success",
"message": [
"Product SI-V55 not found, skipping",
"1 products updated"
]
}
curl -X PUT -H "Authorization: Bearer YOUR_API_TOKEN" -d @product-edit.json https://easywebshop.com/api/product
<?php
header("Content-Type: text/plain");
// API endpoint
const API_URL = 'https://easywebshop.com/api/product/';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Uncomment the following lines to set data in PHP
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
$data = json_encode($data);
*/
// Get data from file
$data = file_get_contents('product-edit.json');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
// Print response in PHP array
if ($response_array = json_decode($response, true)) {
echo "\n\n" . print_r($response_array, true);
}
}
// Close the cURL session
curl_close($ch);
?>
{
"productlist": [
{
"product": {
"code": "LA-C05",
"price": 16,
"status": "Available",
"stock": 7,
"image:no=1": "https://easywebshop.com/img/slideshow/9001.jpg",
"image:no=2": "https://easywebshop.com/img/easywebshop.png"
}
},
{
"product": {
"code": "SI-V55",
"price": "28",
"status": "Sold Out",
"stock": "0",
"weight": "2",
"old_price": "43"
}
}
]
}
<?xml version="1.0" encoding="UTF-8" ?>
<productlist>
<product>
<code>LA-C05</code>
<price>16</price>
<status>Available</status>
<stock>7</stock>
<image no="1">https://easywebshop.com/img/slideshow/9001.jpg</image>
<image no="2">https://easywebshop.com/img/easywebshop.png</image>
</product>
<product>
<code>SI-V55</code>
<price>28</price>
<status>Sold Out</status>
<stock>0</stock>
<weight>2</weight>
<old_price>43</old_price>
</product>
</productlist>
Αν θέλετε να ενημερώσετε το απόθεμα προϊόντων, ενημερώστε μόνο τα πεδία κατάσταση και απόθεμα. Θυμηθείτε να ορίσετε την κατάλληλη κατάσταση προϊόντος για περιπτώσεις όπως Sold out ή Infinite stock.
Μπορούν να ενημερωθούν ταυτόχρονα έως και 100 προϊόντα. Αν θέλετε να ενημερώσετε περισσότερα προϊόντα, μπορείτε να επαναλάβετε την εντολή μία φορά κάθε 5 λεπτά.
Διαγραφή προϊόντων
- DELETE /api/product/[productID]
- Σε περίπτωση επιτυχίας, θα επιστραφεί 204 No Content
- Αίτηση
- Απόκριση
- curl
- PHP
DELETE /api/product/LA-C05 HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
HTTP/2 204
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
curl -k -X DELETE -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/product/LA-C05
<?php
header("Content-Type: text/plain");
// API endpoint
const API_URL = 'https://easywebshop.com/api/product/LA-B03';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpcode == 204) {
echo "Delete successful";
} else {
echo $response;
}
// Print response in PHP array
if ($response_array = json_decode($response, true)) {
echo "\n\n" . print_r($response_array, true);
}
}
// Close the cURL session
curl_close($ch);
?>
Πελάτες
Προβολή πελατών
EasyWebshop ακολουθεί τη μορφή schema.org/Person
- GET /api/customer
- Ανακτά τους τελευταίους 1000 πελάτες
- GET /api/customer?offset=1000
- Ανακτά τους τελευταίους 1000 πελάτες, αλλά παραλείπει τους πρώτους 1000 πελάτες
- GET /api/customer/86400
- Ανακτά πελάτες που προστέθηκαν ή τροποποιήθηκαν τις τελευταίες 24 ώρες.
- GET /api/customer/[email]
- Ανάκτηση συγκεκριμένου πελάτη με βάση τη διεύθυνση ηλεκτρονικού ταχυδρομείου
GET /api/customer HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
HTTP/2 200
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"customerlist": [
{
"customer": {
"givenName": "Test",
"familyName": "Buddy",
"brand": "",
"vatID": "",
"knowsLanguage": "en",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "testbuddy@ew.ms",
"memberOf": "OpenGroup",
"denied": 0
}
},
{
"customer": {
"givenName": "Cindy",
"familyName": "Test",
"brand": "",
"vatID": "",
"knowsLanguage": "nl",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "cindytest@ew.ms",
"denied": 0
}
}
]
}
Ανακτά τους τελευταίους 1000 πελάτες
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/customer
Ανακτά τους τελευταίους 1000 πελάτες, αλλά παραλείπει τους πρώτους 1000 πελάτες
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/customer?offset=1000
Ανακτά πελάτες που προστέθηκαν ή τροποποιήθηκαν τις τελευταίες 24 ώρες.
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/customer/86400
Ανάκτηση συγκεκριμένου πελάτη με βάση τη διεύθυνση ηλεκτρονικού ταχυδρομείου
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/customer/email@address.com
<?php
header("Content-Type: text/plain");
// API endpoint
// You can add an email address behind the slash for searching a specific customer
const API_URL = 'https://easywebshop.com/api/customer/';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Optional: If you are sending data (e.g., for a POST request)
// Uncomment the following lines to send a JSON payload
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
*/
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
// Print response in PHP array
if ($categories = json_decode($response, true)) {
echo "\n\n" . print_r($categories, true);
}
}
// Close the cURL session
curl_close($ch);
?>
{
"customerlist": [
{
"customer": {
"givenName": "Test",
"familyName": "Buddy",
"brand": "",
"vatID": "",
"knowsLanguage": "en",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "testbuddy@ew.ms",
"memberOf": "OpenGroup",
"denied": 0
}
},
{
"customer": {
"givenName": "Cindy",
"familyName": "Test",
"brand": "",
"vatID": "",
"knowsLanguage": "nl",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "cindytest@ew.ms",
"denied": 0
}
}
]
}
<?xml version="1.0" encoding="UTF-8" ?>
<customerlist>
<customer>
<givenName>Test</givenName>
<familyName>Buddy</familyName>
<brand></brand>
<vatID></vatID>
<knowsLanguage>en</knowsLanguage>
<address>
<addressCountry>BE</addressCountry>
<addressLocality>Gent</addressLocality>
<addressRegion></addressRegion>
<postalCode>9000</postalCode>
<streetAddress>Veldstraat</streetAddress>
<houseNo>1</houseNo>
</address>
<telephone>123456789</telephone>
<email>testbuddy@ew.ms</email>
<memberOf>OpenGroup</memberOf>
<denied>0</denied>
</customer>
<customer>
<givenName>Cindy</givenName>
<familyName>Test</familyName>
<brand></brand>
<vatID></vatID>
<knowsLanguage>nl</knowsLanguage>
<address>
<addressCountry>BE</addressCountry>
<addressLocality>Gent</addressLocality>
<addressRegion></addressRegion>
<postalCode>9000</postalCode>
<streetAddress>Veldstraat</streetAddress>
<houseNo>1</houseNo>
</address>
<telephone>123456789</telephone>
<email>cindytest@ew.ms</email>
<denied>0</denied>
</customer>
</customerlist>
Εισαγωγή πελατών
Κάθε πελάτης λαμβάνει ένα email για την επαλήθευση της διεύθυνσης ηλεκτρονικού ταχυδρομείου.
- POST /api/customer
- Σε περίπτωση επιτυχίας, θα επιστραφεί 201 Created
POST /api/customer HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"customerlist": [
{
"customer": {
"givenName": "Test",
"familyName": "Buddy",
"brand": "",
"vatID": "",
"knowsLanguage": "en",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "testbuddy@ew.ms",
"memberOf": "OpenGroup",
"denied": 0
}
},
{
"customer": {
"givenName": "Cindy",
"familyName": "Test",
"brand": "",
"vatID": "",
"knowsLanguage": "nl",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "cindytest@ew.ms",
"denied": 0
}
}
]
}
HTTP/2 201
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"status": "success",
"message": [
"Customer testbuddy@ew.ms: inserted successfully",
"Customer testbuddy@ew.ms: verification email sent successfully",
"Customer cindytest@ew.ms: inserted successfully",
"Customer cindytest@ew.ms: verification email sent successfully",
"2 customers inserted"
]
}
curl -X POST -H "Authorization: Bearer YOUR_API_TOKEN" -d @customer-import.json https://easywebshop.com/api/customer
<?php
header("Content-Type: text/plain");
// API endpoint
const API_URL = 'https://easywebshop.com/api/customer/';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Uncomment the following lines to set data in PHP
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
$data = json_encode($data);
*/
// Get data from file
$data = file_get_contents('customer-import.json');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
// Print response in PHP array
if ($response_array = json_decode($response, true)) {
echo "\n\n" . print_r($response_array, true);
}
}
// Close the cURL session
curl_close($ch);
?>
{
"customerlist": [
{
"customer": {
"givenName": "Test",
"familyName": "Buddy",
"brand": "",
"vatID": "",
"knowsLanguage": "en",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "testbuddy@ew.ms",
"memberOf": "OpenGroup",
"denied": 0
}
},
{
"customer": {
"givenName": "Cindy",
"familyName": "Test",
"brand": "",
"vatID": "",
"knowsLanguage": "nl",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "cindytest@ew.ms",
"denied": 0
}
}
]
}
<?xml version="1.0" encoding="UTF-8" ?>
<customerlist>
<customer>
<givenName>Test</givenName>
<familyName>Buddy</familyName>
<brand></brand>
<vatID></vatID>
<knowsLanguage>en</knowsLanguage>
<address>
<addressCountry>BE</addressCountry>
<addressLocality>Gent</addressLocality>
<addressRegion></addressRegion>
<postalCode>9000</postalCode>
<streetAddress>Veldstraat</streetAddress>
<houseNo>1</houseNo>
</address>
<telephone>123456789</telephone>
<email>testbuddy@ew.ms</email>
<memberOf>OpenGroup</memberOf>
<denied>0</denied>
</customer>
<customer>
<givenName>Cindy</givenName>
<familyName>Test</familyName>
<brand></brand>
<vatID></vatID>
<knowsLanguage>nl</knowsLanguage>
<address>
<addressCountry>BE</addressCountry>
<addressLocality>Gent</addressLocality>
<addressRegion></addressRegion>
<postalCode>9000</postalCode>
<streetAddress>Veldstraat</streetAddress>
<houseNo>1</houseNo>
</address>
<telephone>123456789</telephone>
<email>cindytest@ew.ms</email>
<denied>0</denied>
</customer>
</customerlist>
Αναλυτικές πληροφορίες μπορείτε να βρείτε στη σελίδα διαχείριση πελατών wiki
Παράμετρος | Τύπος | Περιγραφή |
---|---|---|
string | Ηλεκτρονική διεύθυνση. Η διεύθυνση ηλεκτρονικού ταχυδρομείου είναι το μοναδικό αναγνωριστικό του πελάτη. | |
givenName | string | Ονομα |
familyName | string | Επώνυμο |
brand | string | Επιχείρηση |
vatID | string | Αριθμός ΦΠΑ |
knowsLanguage | string | Γλώσσα (ISO 639-1): cs, da, de, el, en, es, fi, fr, it, ja, ko, nl, no, pl, pt, ro, ru, sv, tr, zh |
addressCountry | string | Χώρα (ISO_3166-1) |
addressLocality | string | Περιοχή |
addressRegion | string | Επαρχία. Δεν απαιτείται για τις περισσότερες χώρες και συχνά παραλείπεται για να γίνει μικρότερη η φόρμα πληρωμής. |
postalCode | string | Ταχυδρομικός τομέας. Δεν έχουν όλες οι χώρες ταχυδρομικούς κώδικες. |
streetAddress | string | Οδός |
houseNo | string | Αριθμός κατοικίας. Ορισμένα μέρη δεν έχουν αριθμούς σπιτιών. |
telephone | string | Τηλέφωνο |
memberOf | string | Ομάδα πελατών |
status | string | Καθεστώς Unconfirmed, Confirmed, Denied |
denied | boolean | Αρνηση 0 - 1 |
newsletter | boolean | Εγγραφή στο Ενημερωτικό Δελτίο (Newsletter). Μόνο οι ίδιοι οι πελάτες μπορούν να τον ενεργοποιήσουν. |
registration_date | datetime | Ημερομηνία εγγραφής. Μόνο για ανάγνωση. |
Μπορούν να εισαχθούν ταυτόχρονα έως και 100 πελάτες. Εάν θέλετε να εισάγετε περισσότερους πελάτες, μπορείτε να επαναλάβετε την εντολή μία φορά κάθε 5 λεπτά.
Επεξεργασία πελατών
Σημειώστε ότι μόνο οι πελάτες μπορούν να ενημερώσουν τα δεδομένα τους ως μέτρο ασφαλείας. Μπορείτε να ενημερώσετε την ομάδα πελατών και την κατάσταση του πελάτη (επιτρέπεται ή απορρίπτεται).
- PUT /api/customer
- Σε περίπτωση επιτυχίας, θα επιστραφεί 200 OK
PUT /api/customer HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"customerlist": [
{
"customer": {
"email": "cindytest@ew.ms",
"memberOf": "OpenGroup",
"denied": 0
}
}
]
}
HTTP/2 200
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"status": "success",
"message": [
"Customer cindytest@ew.ms: updated successfully",
"1 customers updated"
]
}
curl -X PUT -H "Authorization: Bearer YOUR_API_TOKEN" -d @customer-edit.json https://easywebshop.com/api/customer
<?php
header("Content-Type: text/plain");
// API endpoint
const API_URL = 'https://easywebshop.com/api/customer/';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Uncomment the following lines to set data in PHP
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
$data = json_encode($data);
*/
// Get data from file
$data = file_get_contents('customer-edit.json');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
// Print response in PHP array
if ($response_array = json_decode($response, true)) {
echo "\n\n" . print_r($response_array, true);
}
}
// Close the cURL session
curl_close($ch);
?>
{
"customerlist": [
{
"customer": {
"email": "cindytest@ew.ms",
"memberOf": "OpenGroup",
"denied": 0
}
}
]
}
<?xml version="1.0" encoding="UTF-8" ?>
<customerlist>
<customer>
<email>cindytest@ew.ms</email>
<memberOf>OpenGroup</memberOf>
<denied>0</denied>
</customer>
</customerlist>
Μπορούν να ενημερωθούν ταυτόχρονα έως και 100 πελάτες. Εάν θέλετε να ενημερώσετε περισσότερους πελάτες, μπορείτε να επαναλάβετε την εντολή μία φορά κάθε 5 λεπτά.
Διαγραφή πελατών
- DELETE /api/customer/[email]
- Σε περίπτωση επιτυχίας, θα επιστραφεί 204 No Content
- Αίτηση
- Απόκριση
- curl
- PHP
DELETE /api/customer/email@address.com HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
HTTP/2 204
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
curl -k -X DELETE -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/customer/email@address.com
<?php
header("Content-Type: text/plain");
// API endpoint
const API_URL = 'https://easywebshop.com/api/customer/email@address.com';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpcode == 204) {
echo "Delete successful";
} else {
echo $response;
}
// Print response in PHP array
if ($response_array = json_decode($response, true)) {
echo "\n\n" . print_r($response_array, true);
}
}
// Close the cURL session
curl_close($ch);
?>
Παραγγελίες
Προβολή παραγγελιών
EasyWebshop ακολουθεί τη μορφή schema.org/Order όποτε είναι δυνατόν.
- GET /api/order
- Ανακτά τις τελευταίες 1000 παραγγελίες
- GET /api/order?offset=1000
- Ανακτά τις τελευταίες 1000 εντολές, αλλά παραλείπει τις πρώτες 1000 εντολές
- GET /api/order/86400
- Ανακτά τις εντολές που τοποθετήθηκαν ή τροποποιήθηκαν τις τελευταίες 24 ώρες
- GET /api/order/[orderNumber]
- Ανάκτηση συγκεκριμένης παραγγελίας με βάση τον αριθμό παραγγελίας
GET /api/order HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
HTTP/2 200
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"orderlist": [
{
"order": {
"@context": "https:\/\/schema.org",
"@type": "Order",
"orderNumber": "20250-71911-55107-56027",
"orderDate": "2025-04-16 15:39:52",
"OrderStatus": "OrderPaymentDue",
"description": "",
"language": "en",
"currency": "EUR",
"totalprice": "79",
"productlist": [
{
"product": {
"@type": "Product",
"productId": "LA-C05",
"description": "Example paint",
"price": "79",
"amount": "1",
"vat_code": "0"
}
}
],
"customer": {
"@context": "https:\/\/schema.org",
"@type": "Person",
"givenName": "Test",
"familyName": "Buddy",
"brand": "",
"vatID": "",
"knowsLanguage": "nl",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "testbuddy@ew.ms",
"status": "Confirmed",
"newsletter": 0,
"registration_date": "2009-03-27 15:42:02"
},
"paymentMethod": "bank",
"paymentUrl": "https:\/\/all4you.be\/payment\/20250-71911-55107-56027",
"last_update": "2025-04-19 13:18:17"
}
}
]
}
Ανακτά τις τελευταίες 1000 παραγγελίες
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/order
Ανακτά τις τελευταίες 1000 εντολές, αλλά παραλείπει τις πρώτες 1000 εντολές
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/order?offset=1000
Ανακτά τις εντολές που τοποθετήθηκαν ή τροποποιήθηκαν τις τελευταίες 24 ώρες
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/order/86400
Ανάκτηση συγκεκριμένης παραγγελίας με βάση τον αριθμό παραγγελίας
curl -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/order/20250-00544-27497-22264
<?php
header("Content-Type: text/plain");
// API endpoint
// You can add an order code behind the slash for searching a specific order
const API_URL = 'https://easywebshop.com/api/order/';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Optional: If you are sending data (e.g., for a POST request)
// Uncomment the following lines to send a JSON payload
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
*/
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
// Print response in PHP array
if ($categories = json_decode($response, true)) {
echo "\n\n" . print_r($categories, true);
}
}
// Close the cURL session
curl_close($ch);
?>
{
"orderlist": [
{
"order": {
"@context": "https:\/\/schema.org",
"@type": "Order",
"orderNumber": "20250-71911-55107-56027",
"orderDate": "2025-04-16 15:39:52",
"OrderStatus": "OrderPaymentDue",
"description": "",
"language": "en",
"currency": "EUR",
"totalprice": "79",
"productlist": [
{
"product": {
"@type": "Product",
"productId": "LA-C05",
"description": "Example paint",
"price": "79",
"amount": "1",
"vat_code": "0"
}
}
],
"customer": {
"@context": "https:\/\/schema.org",
"@type": "Person",
"givenName": "Test",
"familyName": "Buddy",
"brand": "",
"vatID": "",
"knowsLanguage": "nl",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "testbuddy@ew.ms",
"status": "Confirmed",
"newsletter": 0,
"registration_date": "2009-03-27 15:42:02"
},
"paymentMethod": "bank",
"paymentUrl": "https:\/\/all4you.be\/payment\/20250-71911-55107-56027",
"last_update": "2025-04-19 13:18:17"
}
}
]
}
<?xml version="1.0" encoding="UTF-8" ?>
<orderlist>
<order>
<@context>https://schema.org</@context>
<@type>Order</@type>
<orderNumber>20250-71911-55107-56027</orderNumber>
<orderDate>2025-04-16 15:39:52</orderDate>
<OrderStatus>OrderPaymentDue</OrderStatus>
<description></description>
<language>en</language>
<currency>EUR</currency>
<totalprice>79</totalprice>
<productlist>
<product>
<@type>Product</@type>
<productId>LA-C05</productId>
<description>Example paint</description>
<price>79</price>
<amount>1</amount>
<vat_code>0</vat_code>
</product>
</productlist>
<customer>
<@context>https://schema.org</@context>
<@type>Person</@type>
<givenName>Test</givenName>
<familyName>Buddy</familyName>
<brand></brand>
<vatID></vatID>
<knowsLanguage>nl</knowsLanguage>
<address>
<addressCountry>BE</addressCountry>
<addressLocality>Gent</addressLocality>
<addressRegion></addressRegion>
<postalCode></postalCode>
<streetAddress>Veldstraat</streetAddress>
<houseNo>1</houseNo>
</address>
<telephone>123456789</telephone>
<email>testbuddy@ew.ms</email>
<status>Confirmed</status>
<newsletter>0</newsletter>
<registration_date>2009-03-27 15:42:02</registration_date>
</customer>
<paymentMethod>bank</paymentMethod>
<paymentUrl>https://all4you.be/payment/20250-71911-55107-56027</paymentUrl>
<last_update>2025-04-19 13:18:17</last_update>
</order>
</orderlist>
Εισαγωγή παραγγελιών
Λόγω της πολύπλοκης φύσης της ροής πληρωμής, οι παραγγελίες μπορούν να εισαχθούν μόνο με την τοποθέτηση της παραγγελίας στο διαδικτυακό κατάστημα ή με τη χρήση της εφαρμογής POS app
Επεξεργασία παραγγελιών
- PUT /api/order
- Σε περίπτωση επιτυχίας, θα επιστραφεί 200 OK
PUT /api/customer HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"orderlist": [
{
"order": {
"code": "20250-71911-55107-56027",
"status": "OrderDelivered",
"reference": "Internal note",
"mail_customer": 1
}
}
]
}
HTTP/2 200
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
{
"status": "success",
"message": [
"Order 20250-71911-55107-56027: updated successfully",
"Order 20250-71911-55107-56027: email successfully sent to testbuddy@ew.ms"
]
}
curl -X PUT -H "Authorization: Bearer YOUR_API_TOKEN" -d @order-edit.json https://easywebshop.com/api/order
<?php
header("Content-Type: text/plain");
// API endpoint
const API_URL = 'https://easywebshop.com/api/order/';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
// Uncomment the following lines to set data in PHP
/*
$data = [
'key1' => 'value1',
'key2' => 'value2'
];
$data = json_encode($data);
*/
// Get data from file
$data = file_get_contents('order-edit.json');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
echo $response;
// Print response in PHP array
if ($response_array = json_decode($response, true)) {
echo "\n\n" . print_r($response_array, true);
}
}
// Close the cURL session
curl_close($ch);
?>
{
"orderlist": [
{
"order": {
"code": "20250-71911-55107-56027",
"status": "OrderDelivered",
"reference": "Internal note",
"mail_customer": 1
}
}
]
}
<?xml version="1.0" encoding="UTF-8" ?>
<orderlist>
<order>
<code>20250-71911-55107-56027</code>
<status>OrderDelivered</status>
<reference>Internal note</reference>
<mail_customer>1</mail_customer>
</order>
</orderlist>
Αναλυτικές πληροφορίες μπορείτε να βρείτε στη σελίδα διαχείριση παραγγελιών wiki
Παράμετρος | Τύπος | Περιγραφή | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
orderNumber | string | Αριθμός παραγγελίας. Ο αριθμός παραγγελίας ή ο κωδικός παραγγελίας είναι το μοναδικό αναγνωριστικό της παραγγελίας. | ||||||||||||||||
status | string | Καθεστώς | ||||||||||||||||
| ||||||||||||||||||
reference | string | Πρόκειται για μια αναφορά για εσωτερικούς σκοπούς που μπορεί να οριστεί για κάθε παραγγελία. Η αναφορά δεν θα εμφανίζεται στον πελάτη. | ||||||||||||||||
mail_customer | boolean | Αποστολή ειδοποίησης μέσω ηλεκτρονικού ταχυδρομείου στον πελάτη. |
Μπορούν να ενημερωθούν ταυτόχρονα έως και 100 παραγγελίες. Αν θέλετε να ενημερώσετε περισσότερες παραγγελίες, μπορείτε να επαναλάβετε την εντολή μία φορά κάθε 5 λεπτά.
Διαγραφή παραγγελιών
- DELETE /api/order/[orderNumber]
- Σε περίπτωση επιτυχίας, θα επιστραφεί 204 No Content
- Αίτηση
- Απόκριση
- curl
- PHP
DELETE /api/order/20250-00544-27497-22264 HTTP/2
Host: easywebshop.com
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
HTTP/2 204
Server: nginx
Date: Wed, 12 Mar 2025 12:00:00 GMT
Content-Type: text/plain;charset=UTF-8
curl -k -X DELETE -H "Authorization: Bearer YOUR_API_TOKEN" -D - https://easywebshop.com/api/order/20250-00544-27497-22264
<?php
header("Content-Type: text/plain");
// API endpoint
const API_URL = 'https://easywebshop.com/api/order/20250-71911-55107-56027';
// Your Bearer token
const API_TOKEN = 'YOUR_API_TOKEN';
// True: show request and response headers
const DEBUG = true;
// Initialize cURL session
$ch = curl_init(API_URL);
// Set cURL options
// Return the response as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . API_TOKEN,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
// Activate request and response details (for showing later)
if (DEBUG) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
// Execute the cURL request
$response = curl_exec($ch);
// Show the request details
if (DEBUG) {
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
}
// Check for errors
if (curl_errno($ch)) {
echo 'cURL error: ' . curl_error($ch);
// Print the response
} else {
// Print request and response header
if (DEBUG) {
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$response = substr($response, $header_size);
echo $header;
}
// Print response
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpcode == 204) {
echo "Delete successful";
} else {
echo $response;
}
// Print response in PHP array
if ($response_array = json_decode($response, true)) {
echo "\n\n" . print_r($response_array, true);
}
}
// Close the cURL session
curl_close($ch);
?>
Σημειώστε ότι κατά την διαγραφή παραγγελιών ή την αλλαγή της κατάστασης σε Ακυρωμένη, το απόθεμα θα προστεθεί εκ νέου (εάν τα προϊόντα εξακολουθούν να υπάρχουν) και τα προϊόντα θα αλλάξουν κατάσταση από Εξαντλημένα σε Διαθέσιμα, εάν ισχύει. Κατά την ακύρωση μιας παραγγελίας, το απόθεμα θα αφαιρεθεί ξανά από τα προϊόντα.
Όρια
Το EasyWebshop είναι βελτιστοποιημένο για πλεονασμό και εξαιρετικά γρήγορους χρόνους φόρτωσης του ιστότοπου. Πίσω από τις σκηνές, υπάρχει ένα σύμπλεγμα διακομιστών που κατανέμεται γεωγραφικά σε πολλά κέντρα δεδομένων σε διάφορες χώρες. Αυτό έχει ένα κόστος: κατά την προσθήκη και την ενημέρωση δεδομένων και αρχείων, πρέπει να συγχρονιστούν σε όλο το σύμπλεγμα διακομιστών και οι προσωρινές μνήμες αποθήκευσης πρέπει να καθαριστούν σε όλους τους διακομιστές. Οι εικόνες πρέπει να συμπιεστούν και να αλλάξουν μέγεθος σε διάφορες μορφές για φωτογραφίες zoom και μικρογραφίες, πρέπει να ελεγχθούν και να δημιουργηθούν ονόματα SEO-αρχείων και όλα τα δεδομένα πρέπει να συγχρονιστούν σε κατανεμημένους διακομιστές αρχείων και σε διακομιστές με αντίγραφα ασφαλείας.
Ο σκοπός των ορίων είναι να μην μπορεί ένας χρήστης να υπερφορτώσει τα συστήματά μας, γεγονός που θα προκαλούσε βλάβη στους άλλους χρήστες.
Αιτήματα API | 300 Αιτήματα ανά 24ωρο |
---|---|
Προβολή στοιχείων | 1000 Είδη ανά αίτηση |
Εισαγωγή στοιχείων | 100 Είδη ανά αίτηση |
Ενημέρωση στοιχείων | 100 Είδη ανά αίτηση |
Ανέβασμα εικόνων | 100 Εικόνες ανά αίτημα (25 Megabyte per image) |
Υψηλά όρια API
Σε κανονικές καταστάσεις, τα προεπιλεγμένα όρια θα πρέπει να είναι επαρκή. Μόνο για webshops με τεράστιο αριθμό προϊόντων τα όρια θα μπορούσαν να αποτελέσουν εμπόδιο.
Στο Ρυθμίσεις > Περισσότερες επιλογές > EasyWebshop API μπορεί να ενεργοποιηθεί η λειτουργία Υψηλά όρια API Αυτό επιτρέπει την αγορά επιπλέον αιτήσεων API.
API Push
Το API Push στέλνει ένα αίτημα HTTPS με δεδομένα JSON ή XML. Τα δεδομένα αυτά μπορούν να "συλληφθούν" από έναν διακομιστή και να υποβληθούν σε επεξεργασία.
Εάν θέλετε απλώς να λαμβάνετε ένα μήνυμα ηλεκτρονικού ταχυδρομείου με τις παραγγελίες σας σε έναν πρόσθετο προορισμό, χρησιμοποιήστε λογαριασμούς διαχειριστή Μπορείτε επίσης να λαμβάνετε αμέσως ειδοποιήσεις για τις εισερχόμενες παραγγελίες.
Στη διεύθυνση Ρυθμίσεις > Ενότητες > EasyWebshop API > API Push, εισαγάγετε τη διεύθυνση URL της εφαρμογής σας και αποθηκεύστε. Μετά την αποθήκευση, θα εμφανιστεί ένα κουμπί Δοκιμή, το οποίο σας επιτρέπει να στείλετε ένα παράδειγμα αιτήματος. Για να απενεργοποιήσετε, απλά αφήστε τις διευθύνσεις URL κενές και αποθηκεύστε.
Customer Push | Order Push |
---|---|
Ένα αίτημα HTTPS αποστέλλεται όταν ένας πελάτης δημιουργεί έναν λογαριασμό που περιέχει όλες τις πληροφορίες σχετικά με τον πελάτη, παρόμοια με το Customer API | Ένα αίτημα HTTPS αποστέλλεται όταν ένας πελάτης πραγματοποιεί μια παραγγελία στο διαδικτυακό κατάστημα ή όταν μια παραγγελία πραγματοποιείται χρησιμοποιώντας το POS Αυτό το αίτημα περιέχει όλα τα δεδομένα της παραγγελίας, τα προϊόντα που αγοράστηκαν και πληροφορίες σχετικά με τον πελάτη, παρόμοια με το Order API |
- Customer Push
- Order Push
- index.php
{
"customerlist": [
{
"customer": {
"givenName": "Test",
"familyName": "Buddy",
"brand": "",
"vatID": "",
"knowsLanguage": "en",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "testbuddy@ew.ms",
"memberOf": "OpenGroup",
"denied": 0
}
},
{
"customer": {
"givenName": "Cindy",
"familyName": "Test",
"brand": "",
"vatID": "",
"knowsLanguage": "nl",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "9000",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "cindytest@ew.ms",
"denied": 0
}
}
]
}
{
"orderlist": [
{
"order": {
"@context": "https:\/\/schema.org",
"@type": "Order",
"orderNumber": "20250-71911-55107-56027",
"orderDate": "2025-04-16 15:39:52",
"OrderStatus": "OrderPaymentDue",
"description": "",
"language": "en",
"currency": "EUR",
"totalprice": "79",
"productlist": [
{
"product": {
"@type": "Product",
"productId": "LA-C05",
"description": "Example paint",
"price": "79",
"amount": "1",
"vat_code": "0"
}
}
],
"customer": {
"@context": "https:\/\/schema.org",
"@type": "Person",
"givenName": "Test",
"familyName": "Buddy",
"brand": "",
"vatID": "",
"knowsLanguage": "nl",
"address": {
"addressCountry": "BE",
"addressLocality": "Gent",
"addressRegion": "",
"postalCode": "",
"streetAddress": "Veldstraat",
"houseNo": "1"
},
"telephone": "123456789",
"email": "testbuddy@ew.ms",
"status": "Confirmed",
"newsletter": 0,
"registration_date": "2009-03-27 15:42:02"
},
"paymentMethod": "bank",
"paymentUrl": "https:\/\/all4you.be\/payment\/20250-71911-55107-56027",
"last_update": "2025-04-19 13:18:17"
}
}
]
}
<?php
/*--------------------------------------------
* EasyWebshop API Push test script
--------------------------------------------*/
// Address to send data to
$email = 'test@ew.ms';
// Collect data
$feedback = "\n\nGET variables:\n\n";
foreach ($_GET as $name => $value) {
$feedback .= $name . ': ' . $value . "\n";
}
$feedback .= "\n\nPOST variables:\n\n";
foreach ($_POST as $name => $value) {
$feedback .= $name . ': ' . $value . "\n";
}
$feedback .= "\n\nInput data:\n\n" . file_get_contents("php://input");
// Send mail
mail($email, 'EasyWebshop API Push ', $feedback . "\n\n" .
// Username
(isset($_SERVER['PHP_AUTH_USER']) ? 'User: ' . $_SERVER['PHP_AUTH_USER'] . "\n" : '') .
// IP Address
(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] . "\n" : '') .
$_SERVER['REMOTE_ADDR']);
// Return success
header('HTTP/1.1 200 OK');
die('200 OK');
?>
συνδέσεις
Οι συνδέσεις είναι μικρές διαδικτυακές εφαρμογές που ζουν στο δικό τους διακομιστή και έχουν τη δική τους διεύθυνση URL. Μπορούν να εγκατασταθούν από όλα τα webshops, επομένως ο κώδικάς τους μπορεί να επαναχρησιμοποιηθεί από όλους τους χρήστες του EasyWebshop.
Στη διεύθυνση Ρυθμίσεις > Ενότητες > EasyWebshop API > Token συνδέσεων, κάντε κλικ στο κουμπί Προσθήκη για να δημιουργήσετε ένα νέο Τοκέν σύνδεσης API Θα πρέπει να εισαγάγετε τη διεύθυνση URL της σύνδεσης.
Βεβαιωθείτε ότι δημιουργείτε ένα Τοκτέν σύνδεσης API και όχι ένα κανονικό Τοκτέν API
Οι τύποι των συνδέσεων είναι οι εξής:
Υπηρεσία παράδοσης, HTML widget, Τιμολόγιο, Τροφοδοσία προϊόντος, Πάροχος υπηρεσιών πληρωμών.
Οι συνδέσεις έχουν συνήθως έναν αριθμό αρχείων:
Κατάλογος | Περιγραφή |
---|---|
settings.xml | Αυτό είναι το αρχείο διαμόρφωσης της σύνδεσης.
|
easywebshop.php | Αυτό είναι το αρχείο που συνδέεται με το API EasyWebshop. Ορίστε το Τοκτέν σύνδεσης API (όχι ένα κανονικό τοκτέν API) σε αυτό το αρχείο. |
index.php | Αυτό είναι το κύριο αρχείο και το πρώτο αρχείο στο οποίο θα γίνει πρόσβαση όταν χρησιμοποιείται η σύνδεση. Σε περίπτωση υπηρεσίας παράδοσης, τα πεδία GET με τη διεύθυνση των πελατών αποστέλλονται σε αυτό το αρχείο. Στην περίπτωση ενός PSP, τα πεδία POST της παραγγελίας αποστέλλονται σε αυτό το αρχείο. |
report.php | Αυτό το αρχείο χρησιμοποιείται στην περίπτωση PSP και Invoice και συνήθως ζητείται στο παρασκήνιο από τον PSP για να στείλει ενημερώσεις σχετικά με την κατάσταση πληρωμής. Αυτό το αρχείο ενημερώνει στη συνέχεια την κατάσταση της παραγγελίας στο ηλεκτρονικό κατάστημα σε Payment received (Πληρωμή παραλήφθηκε). |
Για να διευκολύνουμε τη δημιουργία νέων συνδέσεων, κρατήσαμε τα παρακάτω παραδείγματα όσο το δυνατόν πιο απλά και ευδιάκριτα.
Υπηρεσία παράδοσης
Χρησιμοποιήστε το παρακάτω παράδειγμα για τη δημιουργία συνδέσεων με υπηρεσίες παράδοσης ή μεταφοράς.
Η σύνδεση πρέπει να εγκατασταθεί από τον έμπορο και οι μέθοδοι αποστολής πρέπει να συνδεθούν επιλέγοντάς τες.
- Ο πελάτης βρίσκεται στη σελίδα πληρωμής και επιλέγει μια μέθοδο αποστολής. Επειδή η σύνδεσή σας είναι συνδεδεμένη με μια μέθοδο αποστολής, αυτό ενεργοποιεί ένα αναδυόμενο παράθυρο με ένα iframe που παραπέμπει στο αρχείο index.php
- Τα δεδομένα της διεύθυνσης του πελάτη αποστέλλονται ως μεταβλητές GET στη συμβολοσειρά ερωτήματος.
- Στη σύνδεσή σας, ο πελάτης μπορεί να επιλέξει μια μέθοδο αποστολής ή να επιλέξει ένα σημείο παραλαβής από έναν χάρτη.
- Η σύνδεσή σας αποστέλλει το όνομα της μεθόδου αποστολής, την τιμή, την περιγραφή και ένα λογότυπο στη διεύθυνση URL επιβεβαίωσης (/dsconfirm).
- Τα δεδομένα προστίθενται στην παραγγελία και ο πελάτης λαμβάνει μια επιβεβαίωση.
- settings.xml
- easywebshop.php
- index.php
- style.css
<?xml version="1.0" encoding="UTF-8" ?>
<settings>
<name>ExampleDeliveryService</name>
<logo>logo.png</logo>
<type>ds</type>
<url>https://www.webshopdata.com/app/easywebshop-ds/index.php</url>
<parameter name="Account ID"></parameter>
<parameter name="Passphrase"></parameter>
</settings>
<?php
/*
EasyWebshop API Connector
Documentation: https://easywebshop.com/doc/api
*/
function easyApp($data = '') {
// Set your API Connection Token (not API Token!) here
$conn_token = 'YOUR_API_TOKEN';
// No need to change anything below. You can watch, but you can't touch!
if (!isset($_REQUEST['shop_id']) || !$_REQUEST['shop_id'] ||
!filter_var($_REQUEST['shop_id'], FILTER_VALIDATE_INT,
array('options' => array('min_range' => 1, 'max_range' => 1000000000)))) {
die('Error: $_REQUEST[\'shop_id\'] not set');
}
$settings = new SimpleXMLElement(file_get_contents(dirname(__FILE__) . '/settings.xml'));
$method = isset($data['function']) && substr($data['function'], 0, 3) == 'set' ? 'PUT' : 'GET';
$format = isset($data['format']) && in_array(strtolower($data['format']), array('json', 'xml')) ?
strtolower($data['format']) : 'array';
$data = is_array($data) ? ($method == 'GET' ? http_build_query($data) : json_encode($data)) : '';
$apiurl = 'https://easywebshop.jan/api/conn/' . $_REQUEST['shop_id'] . '/' . $settings->name .
($method == 'GET' && $data ? '?' . $data : ''); // HTTPS only
$opts = array(
'http' => array(
'header' => "Content-Type: application/x-www-form-urlencoded\r\n" .
'Authorization: Bearer ' .
hash('sha512', $_REQUEST['shop_id'] . $settings->name . hash('sha256', $conn_token) . $data) . "\r\n",
'method' => $method,
'ignore_errors' => true),
'ssl' => array('verify_peer' => false, 'verify_peer_name' => false)
);
if ($method == 'PUT') { $opts['http']['content'] = $data; }
$response = file_get_contents($apiurl, false, stream_context_create($opts));
$appdata = $format == 'array' ? json_decode($response, true) : $response;
// Output log - only in debug mode
if (defined('DEBUG') && DEBUG) {
echo "-- easywebshop.php " . $settings->name . "\n> Accessing API: " .
$apiurl . "\n> API response: " . $response . "--\n";
}
return $appdata; // this can be a PHP array, JSON or XML, depending on the $data['format'] value
} // easyApp()
?>
<?php
/*--------------------------------------------
EasyWebshop Delivery service example
Install link:
https://easywebshop.com/software/connections?install=https://www.webshopdata.com/app/easywebshop-ds
Block 1: Variables
Block 2: Languages
Block 3: Delivery service API code
Block 4: Process form data
Block 5: Start page
--------------------------------------------*/
/*--------------------------------
Block 1: Variables
-------------------------------*/
// Debug mode for testing, set to false in production
define('DEBUG', true);
// Use test data
define('TEST', true);
// Use for testing without GET vars from checkout form
if (TEST) {
$_REQUEST = array('shop_id' => 71911, 'lang' => 'en');
$_GET = array('shop_id' => $_REQUEST['shop_id'],
'webshop_url' => 'https://all4you.be',
'shipping_method' => 'Standard delivery',
#'shipping_method' => 'Pickup at collection point',
'firstname' => 'Bruno',
'lastname' => 'Test',
'street' => 'Mottakerveien',
'no' => '14',
'zipcode' => '0150',
'city' => 'Oslo',
'province' => '',
'country' => 'NO',
'lang' => $_REQUEST['lang'],
'weight' => 0.5, // total weight of the shopping basket in kg
'freeshipping' => '', // shipping discount
'email' => 'bruno@mailinator.com',
'phone' => '12345678',
'total' => 100); // total price of the order, can be used to give discounts
} // TEST
// Get the connection settings
$settings = new SimpleXMLElement(file_get_contents(dirname(__FILE__) . '/settings.xml'));
// Get the data from the webshop
require 'easywebshop.php';
$appdata = easyApp();
/* This gives us the following array
Array
(
[webshop] => Array
(
[email] => example@voorbeeldshop.be
[url] => https://voorbeeldshop.be
[name] => Voorbeeld webshop
[country] => BE
[lang] => nl
[currency] => EUR
)
[response_time] => 0.00084
)*/
// Show all the data we have for testing
if (DEBUG) {
echo "<pre>--------------------------------\n\tGET variables:\n--------------------------------\n\n";
print_r($_GET);
echo "\n\n</pre>";
echo "<pre>--------------------------------\n\tConnection variables:\n--------------------------------\n\n";
print_r($appdata);
echo "\n\n</pre>";
}
/*--------------------------------
Block 3: Delivery service API code
Delivery variables
- These can be hard coded, or requested from another source
- Prices can also depend on customer location, use $_GET['zipcode'] for this
-------------------------------*/
$delivery_prices = array(2.5, 1.5, 0);
/*--------------------------------
Block 2: Languages
-------------------------------*/
// Dutch
if ($_REQUEST['lang'] == 'nl') {
$l_deliverymethod = 'Kies uw verzendmethode';
$l_deliverymethods = array('Levering met drone', 'Levering met fiets', 'Afhalen in pakketautomaat');
$l_confirm = 'Bevestigen';
// Other languages
} else {
$l_deliverymethod = 'Choose your delivery method';
$l_deliverymethods = array('Delivery by drone', 'Delivery by bicycle', 'Pick up in a parcel machine');
$l_confirm = 'Confirm';
}
/*--------------------------------
Block 4: Process form data
-------------------------------*/
if (isset($_POST['deliverymethod'])) {
// Send delivery method
$ds_method = $l_deliverymethods[0];
if (is_numeric($_POST['deliverymethod']) && isset($l_deliverymethods[$_POST['deliverymethod']])) {
$ds_method = $l_deliverymethods[$_POST['deliverymethod']];
}
// Separate prices per delivery method
$ds_price = $delivery_prices[0];
if (is_numeric($_POST['deliverymethod']) && isset($delivery_prices[$_POST['deliverymethod']])) {
$ds_price = $delivery_prices[$_POST['deliverymethod']];
}
// Show a logo on the confirm page, always use HTTPS for displaying images on a HTTPS page
$ds_logo = 'https://www.webshopdata.com/app/easywebshop-ds/logo.png';
// Order number
$ds_info = 'Reference ' . rand(0, 10000); // this can be a reference to an external database
// Confirm delivery method
header('Location: ' . $appdata['webshop']['url'] . '/dsconfirm' .
'?ds=' . urlencode($settings->name) .
'&ds_price=' . $ds_price .
'&ds_method=' . urlencode($ds_method) .
'&ds_info=' . urlencode($ds_info) .
'&ds_logo=' . urlencode($ds_logo) .
'&ds_seconds=5'); // how long to show the confirmation message
die;
}
/*--------------------------------
Block 5: Start page
- Let's keep it very simple
-------------------------------*/
// Header
echo '<!DOCTYPE html><html lang="en"><head><title>' . $settings->name . '</title><meta charset="utf-8">' .
'<link rel="stylesheet" href="style.css"></head>' . // you can also include javascript here
'<body><main><img src="logo.png" alt="' . $settings->name . '" id="logo"><h1>' . $settings->name . '</h1>' .
// Form
'<form method="POST">' .
'<input type="hidden" name="shop_id" value="' . $_REQUEST['shop_id'] . '">' .
'<input type="hidden" name="lang" value="' . $_REQUEST['lang'] . '">' .
'<table>' .
'<tr><td>' . $l_deliverymethod . '</td><td>';
// Loop delivery methods
foreach ($l_deliverymethods as $k => $v) {
echo '<input type="radio" name="deliverymethod" value="' . $k . '" id="' . $k . '">' .
'<label for="' . $k . '">' . $v . ' <strong>€ ' . $delivery_prices[$k] . '</strong></label><br>';
}
echo '</td></tr>' .
// Submit form
'<tr><td></td><td><input type="submit" name="submit" value="' . $l_confirm . '"></td></tr>' .
'</table></form>' .
// End page
'</main></body></html>';
?>
body { margin: 0; font-family: Helvetica, Arial, sans-serif; color: #333; background-color: #E4E4E4; }
main { margin: 0 auto; margin-top: 30px; margin-bottom: 30px; padding: 20px; width: 760px; background-color: #FFF; border-radius: 8px; border: 1px solid #CCC; box-shadow: 5px 5px 5px #888; }
#logo { margin-bottom: 10px; }
h1 { font-size: 22px; margin: 0; padding: 0; color: #06C; margin-bottom: 80px; }
hr { clear: both; border-style: solid; border-width: 1px 0 0 0; border-color: #E4E4E4; margin: 20px 0; }
/*--------------------------------
Navigation
-------------------------------*/
nav { margin: 40px 0; clear: both; }
nav a {
display: block; width: 70%; margin: 30px auto; padding: 20px; vertical-align: top;
border: 1px solid #E4E4E4; box-shadow: 2px 2px 2px #888;
/*border-style: solid; border-width: 0 0 1px 0; border-color: #CCC;*/
text-decoration: none; color: #06C; font-size: 20px; font-weight: bold;
transition: background 0.4s;
}
nav a:hover { background: #EEE; }
nav img { display: inline-block; float: left; width: 100px; height: 100px; vertical-align: top; }
nav span{ display: inline-block; line-height: 100px; text-indent: 30px; }
.langselect { font-size: 0.8em; font-weight: bold; }
/*--------------------------------
Buttons
-------------------------------*/
a.glowbutton, input[type="submit"], input[type="button"] {
white-space: nowrap; display: inline-block; min-width: 210px; margin: 0 0 10px 0; padding: 0;
text-decoration: none; text-align: center;
color: #FFF; background-color: #06C; border: 0; border-radius: 3px;
line-height: 33px; height: 33px; font-weight: bold; font-size: 0.9em;
-webkit-appearance: none; -moz-appearance: none; appearance: none;
transition: background 0.4s;
}
a.glowbutton:hover, input[type="submit"]:hover {
background-color: #06F; text-decoration: none;
}
/*--------------------------------
Fancy
-------------------------------*/
a { color: #06C; text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 1.6em; }
h3 { font-size: 1.4em; }
h4 { font-size: 1.1em; color: #666; }
.blue { color: #06C; }
.orange { color: #F60; }
.code { font-family: monospace; color: #090; }
.code a { font-weight: bold; color: #090; }
.warn { background-color: #FC0; padding: 15px 5px; text-align: center; border-radius: 5px; font-size: 0.9em; box-shadow: 2px 2px 2px #888; }
/*--------------------------------
Forms
-------------------------------*/
textarea { width: 99%; height: 200px; font-size: 1.2em; color: #666; }
input, select, textarea { border: 1px solid #CCC; border-radius: 3px; padding: 3px; }
input:focus, textarea:focus { background-color: #EEE; }
input[type="checkbox"], input[type="radio"] { border: 0;}
input[type="submit"], input[type="button"] { cursor: pointer; float: right; margin: 10px 0 0 0; }
form table { width: 100%; }
form table td:first-child { width: 50%; }
label { display: inline-block; max-width: 90%; padding: 0 0 0 10px; cursor: pointer; }
/*--------------------------------
Responsive
-------------------------------*/
@media all and (max-width: 790px) {
main { width: 100%; margin: 0; padding: 20px 0; border: none; border-radius: 0; }
nav a { margin: 0 auto; margin-top: 20px; margin-bottom: 20px; }
textarea { width: 97%; }
}
HTML widget
Τα widgets μπορούν να χρησιμοποιηθούν για την εύκολη εισαγωγή κώδικα HTML, CSS και JavaScript. Ο χρήστης μπορεί να επιλέξει σε ποιες σελίδες του ιστότοπου θέλει να εγκαταστήσει αυτόν τον κώδικα. Είναι ουσιαστικά το ίδιο με την αντιγραφή και επικόλληση, αλλά πιο φιλικό προς το χρήστη.
- settings.xml
<?xml version="1.0" encoding="UTF-8" ?>
<settings>
<name>ExampleWidget</name>
<type>html</type>
<parameter name="Enter variable data 1">Example data 1</parameter>
<parameter name="Enter variable data 2">Example data 2</parameter>
<url>https://www.webshopdata.com/app/easywebshop-html/settings.xml</url>
<html><![CDATA[<p>
Hello! I'm a <strong>HTML example</strong>.<br>
You can use HTML, CSS and JavaScript code here.<br>
The user can insert it on any page of the website.
</p>
<p>
Your first parameter was <strong>[PARAMETER1]</strong>.<br>
Your second parameter was <strong>[PARAMETER2]</strong>.
</p>
<p>
To install me, redirect your user to:<br>
https://easywebshop.com/software/connections?install=https://www.webshopdata.com/app/easywebshop-html
</p>
<p>
Replace the second part of the URL by the directory on your sever.<br>
Only this settings.xml file is required in the directory.
</p>]]></html>
</settings>
Τιμολόγιο
Το Invoice λειτουργεί με τον ίδιο τρόπο όπως το Payment Service Provider, αλλά επικεντρώνεται στην πληρωμή με τιμολόγιο όπου απαιτούνται δεδομένα πελατών. Όταν ο τύπος έχει οριστεί σε psp, είναι διαθέσιμα μόνο τα απαραίτητα δεδομένα που χρειάζεται ένας PSP για να επεξεργαστεί μια πληρωμή. Όταν ο τύπος είναι τιμολόγιο, τα δεδομένα του πελάτη καθίστανται επίσης διαθέσιμα.
Τροφοδοσία προϊόντος
Χρησιμοποιείται για την ανάκτηση δεδομένων προϊόντων, για παράδειγμα για χρήση σε ιστότοπους σύγκρισης.
- settings.xml
- easywebshop.php
- index.php
- style.css
<?xml version="1.0" encoding="UTF-8" ?>
<settings>
<name>DemoFeed</name>
<type>productfeed</type>
<url>https://www.webshopdata.com/app/easywebshop-productfeed/index.php</url>
</settings>
<?php
/*
EasyWebshop API Connector
Documentation: https://easywebshop.com/doc/api
*/
function easyApp($data = '') {
// Set your API Connection Token (not API Token!) here
$conn_token = 'YOUR_API_TOKEN';
// No need to change anything below. You can watch, but you can't touch!
if (!isset($_REQUEST['shop_id']) || !$_REQUEST['shop_id'] ||
!filter_var($_REQUEST['shop_id'], FILTER_VALIDATE_INT,
array('options' => array('min_range' => 1, 'max_range' => 1000000000)))) {
die('Error: $_REQUEST[\'shop_id\'] not set');
}
$settings = new SimpleXMLElement(file_get_contents(dirname(__FILE__) . '/settings.xml'));
$method = isset($data['function']) && substr($data['function'], 0, 3) == 'set' ? 'PUT' : 'GET';
$format = isset($data['format']) && in_array(strtolower($data['format']), array('json', 'xml')) ?
strtolower($data['format']) : 'array';
$data = is_array($data) ? ($method == 'GET' ? http_build_query($data) : json_encode($data)) : '';
$apiurl = 'https://easywebshop.jan/api/conn/' . $_REQUEST['shop_id'] . '/' . $settings->name .
($method == 'GET' && $data ? '?' . $data : ''); // HTTPS only
$opts = array(
'http' => array(
'header' => "Content-Type: application/x-www-form-urlencoded\r\n" .
'Authorization: Bearer ' .
hash('sha512', $_REQUEST['shop_id'] . $settings->name . hash('sha256', $conn_token) . $data) . "\r\n",
'method' => $method,
'ignore_errors' => true),
'ssl' => array('verify_peer' => false, 'verify_peer_name' => false)
);
if ($method == 'PUT') { $opts['http']['content'] = $data; }
$response = file_get_contents($apiurl, false, stream_context_create($opts));
$appdata = $format == 'array' ? json_decode($response, true) : $response;
// Output log - only in debug mode
if (defined('DEBUG') && DEBUG) {
echo "-- easywebshop.php " . $settings->name . "\n> Accessing API: " .
$apiurl . "\n> API response: " . $response . "--\n";
}
return $appdata; // this can be a PHP array, JSON or XML, depending on the $data['format'] value
} // easyApp()
?>
<?php
/*--------------------------------------------
EasyWebshop Productfeed example
Install link:
https://easywebshop.com/software/connections?install=https://www.webshopdata.com/app/easywebshop-productfeed
Block 1: Variables
Block 2: Generate feed
Block 3: Languages
Block 4: Productfeed form
Block X: Functions
--------------------------------------------*/
/*--------------------------------
Block 1: Variables
-------------------------------*/
define('DEBUG', true); // Debug mode for testing, set to false in production
$languages = array('cs', 'da', 'de', 'el', 'en', 'es', 'fi', 'fr', 'it', 'ja', 'ko', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh');
define('SHOP_ID', isset($_REQUEST['shop_id']) && checkId($_REQUEST['shop_id']) ? $_REQUEST['shop_id'] : 0);
define('LANG', isset($_REQUEST['lang']) && in_array($_REQUEST['lang'], $languages) ? $_REQUEST['lang'] : 'en');
$settings = new SimpleXMLElement(file_get_contents(dirname(__FILE__) . '/settings.xml'));
/*--------------------------------
Block 2: Generate feed
-------------------------------*/
if (SHOP_ID && isset($_GET['token']) &&
preg_match('/^[0-9a-f]{40}$/i', $_GET['token']) && $_GET['token'] == sha1(SHOP_ID . LANG . 'roor8weiChait0gai')) {
/*--------------------------------
Connect to the EasyWebshop App API
easyApp(
[data] Data to send to the API, optional
)
- Returns an array of requested data, view with: print_r($appdata);
-------------------------------*/
header('Content-Type: text/xml; charset=utf-8');
// Show feed in XML format
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?" . ">\n<items>\n";
if (DEBUG) {
echo '<debug><![CDATA[';
}
include 'easywebshop.php';
$appdata = easyApp(array('lang' => LANG, 'seconds' => 0, 'start' => 0, 'length' => 1000)); //, 'format' => 'xml'));
if (DEBUG) {
echo "]]></debug>\n";
}
if (isset($appdata['products'])) {
displayProducts($appdata);
// Max 5000 products
for ($i = 1; $i < 5; $i++) {
if (count($appdata['products']) >= 1000) {
$appdata = easyApp(array('lang' => LANG, 'seconds' => 0, 'start' => ($i * 1000), 'length' => 1000)); //, 'format' => 'xml'));
displayProducts($appdata);
}
}
//"<updated>" . gmdate("Ymd\THis\Z") . "</updated>\n";
}
echo '</items>';
die;
}
/*--------------------------------
Block 3: Languages
-------------------------------*/
// Danish
if (LANG == 'da') {
$l_language = 'Sprog';
$l_languages = array('cs' => 'Tjekkisk', 'da' => 'Dansk', 'de' => 'Tysk', 'el' => 'Greek', 'en' => 'Engelsk', 'es' => 'Spansk', 'fi' => 'Finsk', 'fr' => 'Fransk', 'it' => 'Italiensk', 'ja' => 'Japansk', 'ko' => 'Koreansk', 'nl' => 'Nederlandsk', 'no' => 'Norsk', 'pl' => 'Polsk', 'pt' => 'Portugisisk', 'ro' => 'Rumænsk', 'ru' => 'Russisk', 'sv' => 'Svensk', 'tr' => 'Tyrkisk', 'zh' => 'Kinesisk');
$l_generate_feed = 'Generer produktfeed';
$l_feed_url = 'Din <strong>' . $settings->name . '</strong> feedwebadresse er:';
// German
} elseif (LANG == 'de') {
$l_language = 'Sprache';
$l_languages = array('cs' => 'Tschechisch', 'da' => 'Dänisch', 'de' => 'Deutsch', 'el' => 'Griechisch', 'en' => 'Englisch', 'es' => 'Spanisch', 'fi' => 'Finnisch', 'fr' => 'Französisch', 'it' => 'Italienisch', 'ja' => 'Japanisch', 'ko' => 'Koreanisch', 'nl' => 'Niederländisch', 'no' => 'Norwegisch', 'pl' => 'Polnisch', 'pt' => 'Portugiesisch', 'ro' => 'Rumänisch', 'ru' => 'Russisch', 'sv' => 'Schwedisch', 'tr' => 'Türkisch', 'zh' => 'Chinesisch');
$l_generate_feed = 'Produktfeed generieren';
$l_feed_url = 'Ihre Feed-URL für <strong>' . $settings->name . '</strong> lautet:';
// Spanish
} elseif (LANG == 'es') {
$l_language = 'Idioma';
$l_languages = array('cs' => 'Checo', 'da' => 'Danés', 'de' => 'Alemán', 'el' => 'Griego', 'en' => 'Inglés', 'es' => 'Español', 'fi' => 'Finlandés', 'fr' => 'Francés', 'it' => 'Italiano', 'ja' => 'Japonés', 'ko' => 'Coreano', 'nl' => 'Neerlandés', 'no' => 'Noruego', 'pl' => 'Polaco', 'pt' => 'Portugués', 'ro' => 'Rumano', 'ru' => 'Ruso', 'sv' => 'Sueco', 'tr' => 'Turco', 'zh' => 'Chino');
$l_generate_feed = 'Generar feed de producto';
$l_feed_url = 'Su <strong>' . $settings->name . '</strong> URL de feed es:';
// French
} elseif (LANG == 'fr') {
$l_language = 'Langue';
$l_languages = array('cs' => 'Tchèque', 'da' => 'Danois', 'de' => 'Allemand', 'el' => 'Grecque', 'en' => 'Anglais', 'es' => 'Espagnol', 'fi' => 'Finnois', 'fr' => 'Français', 'it' => 'Italien', 'ja' => 'Japonais', 'ko' => 'Coréen', 'nl' => 'Néerlandais', 'no' => 'Norvège', 'pl' => 'Polonais', 'pt' => 'Portugais', 'ro' => 'Roumain', 'ru' => 'Russe', 'sv' => 'Suédois', 'tr' => 'Turc', 'zh' => 'Chinois');
$l_generate_feed = 'Générer le flux de produits';
$l_feed_url = 'Votre URL de flux <strong>' . $settings->name . '</strong> est la suivante:';
// Dutch
} elseif (LANG == 'nl') {
$l_language = 'Taal';
$l_languages = array('cs' => 'Tsjechisch', 'da' => 'Deens', 'de' => 'Duits', 'el' => 'Grieks', 'en' => 'Engels', 'es' => 'Spaans', 'fi' => 'Fins', 'fr' => 'Frans', 'it' => 'Italiaans', 'ja' => 'Japans', 'ko' => 'Koreaans', 'nl' => 'Nederlands', 'no' => 'Noors', 'pl' => 'Pools', 'pt' => 'Portugees', 'ro' => 'Roemeens', 'ru' => 'Russisch', 'sv' => 'Zweeds', 'tr' => 'Turks', 'zh' => 'Chinees');
$l_generate_feed = 'Productfeed genereren';
$l_feed_url = 'Uw <strong>' . $settings->name . '</strong> feed URL is:';
// Norwegian
} elseif (LANG == 'no') {
$l_language = 'Språk';
$l_languages = array('cs' => 'Tsjekkisk', 'da' => 'Danske', 'de' => 'Tysk', 'el' => 'Gresk', 'en' => 'Engelsk', 'es' => 'Spansk', 'fi' => 'Finske', 'fr' => 'Fransk', 'it' => 'Italiensk', 'ja' => 'Japansk', 'ko' => 'Koreansk', 'nl' => 'Nederlandsk', 'no' => 'Norsk', 'pl' => 'Polsk', 'pt' => 'Portugisisk', 'ro' => 'Rumensk', 'ru' => 'Russiske', 'sv' => 'Svenske', 'tr' => 'Turkish', 'zh' => 'Kinesisk');
$l_generate_feed = 'Generer produktmating';
$l_feed_url = 'Din <strong>' . $settings->name . '</strong> feed-nettadresse er:';
// Swedish
} elseif (LANG == 'sv') {
$l_language = 'Språk';
$l_languages = array('cs' => 'Tjeckisk', 'da' => 'Danska', 'de' => 'Tyska', 'el' => 'Grekiska', 'en' => 'Engelska', 'es' => 'Spanska', 'fi' => 'Finska', 'fr' => 'Franska', 'it' => 'Italienska', 'ja' => 'Japansk', 'ko' => 'koreansk', 'nl' => 'Nederländska', 'no' => 'Norska', 'pl' => 'Polska', 'pt' => 'Portugisiska', 'ro' => 'Rumänska', 'ru' => 'Ryska', 'sv' => 'Svenska', 'tr' => 'Turkiska', 'zh' => 'Kinesisk');
$l_generate_feed = 'Generera produktmatning';
$l_feed_url = 'Din <strong>' . $settings->name . '</strong> matningsadress är:';
// English by default
} else {
$l_language = 'Language';
$l_languages = array('cs' => 'Czech', 'da' => 'Danish', 'de' => 'German', 'el' => 'Greek', 'en' => 'English', 'es' => 'Spanish', 'fi' => 'Finnish', 'fr' => 'French', 'it' => 'Italian', 'ja' => 'Japanese', 'ko' => 'Korean', 'nl' => 'Dutch', 'no' => 'Norwegian', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ro' => 'Romanian', 'ru' => 'Russian', 'sv' => 'Swedish', 'tr' => 'Turkish', 'zh' => 'Chinese');
$l_generate_feed = 'Generate product feed';
$l_feed_url = 'Your <strong>' . $settings->name . '</strong> feed URL is:';
}
/*--------------------------------
Block 4: Productfeed form
-------------------------------*/
echo '<!DOCTYPE html><html lang="en"><head><title>' . $settings->name . '</title><meta charset="utf-8">' .
'<link rel="stylesheet" href="style.css"></head>' .
'<body><main><h1>' . $settings->name . '</h1>';
// Show feed URL
if (isset($_POST['shop_id']) && SHOP_ID) {
// Create a token for this feed so the URL cannot be guessed
$feedurl = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['DOCUMENT_URI'] .
'?shop_id=' . SHOP_ID . '&lang=' . LANG . '&token=' . sha1(SHOP_ID . LANG . 'roor8weiChait0gai');
echo '<p>' . $l_feed_url . '<br><a href="' . $feedurl . '" target="_blank">' . $feedurl . '</a></p>';
// Show generate feed form
} else {
echo '<form method="POST"><table>';
// Shop ID
if (SHOP_ID) {
echo '<input type="hidden" name="shop_id" value="' . SHOP_ID . '">';
} else {
echo '<tr><td>Shop ID</td><td><input type="text" name="shop_id" size="6"></td></tr>';
}
// Language
echo '<tr><td>' . $l_language . '</td><td><select name="lang">';
asort($l_languages);
foreach ($l_languages as $l => $l_name) {
echo '<option value="' . $l . '"' . ($l == $lang ? ' selected' : '') . '>' . $l_name . '</option>';
}
echo '</select></td></tr>';
// Submit form
echo '<tr><td></td><td><input type="submit" name="submit" value="' . $l_generate_feed . '"></td></tr>' .
'</table></form>';
}
echo '</main></body></html>';
/*--------------------------------
Block X: Functions
-------------------------------*/
function displayProducts($appdata) {
/* Google product feed:
https://support.google.com/merchants/answer/7052112?hl=en
*/
foreach ($appdata['products'] as $p) {
if (!isset($p['category'])) {
$p['category'] = '';
}
//echo "<item>\n";
// Image
//echo '<additional_image_link>' . $p['image'] . "</additional_image_link>\n
// ID (mandatory)
echo "<item>\n<id><![CDATA[" . $p['productID'] . "]]></id>\n<availability>" .
// Availability (Mandatory)
$p['status'] . "</availability>\n<brand><![CDATA[" .
// Brand (Mandatory)
$p['category'] . "]]></brand>\n" .
// Color
($p['colors'] ? '<color>' . $p['colors'] . "</color>\n" : '') .
// Condition (Recommended)
'<condition>' . $p['itemCondition'] . "</condition>\n<title><![CDATA[" .
// Title (Mandatory)
$p['name'] . "]]></title>\n<description><![CDATA[" .
// Description (Mandatory)
preg_replace('/[^(\x20-\x7F)]*/', '', $p['description']) . "]]></description>\n";
// EAN (Recommended)
if ($p['ean']) {
echo '<ean>' . $p['ean'] . "</ean>\n";
}
// Product code
//echo '<unique_id><![CDATA[' . $p['productID'] . "]]></unique_id>\n<size>" .
// Size (Mandatory)
echo '<size>' . $p['weight'] . "</size>\n<image_link>" .
// Image link (Mandatory)
$p['image'] . "</image_link>\n";
// Additional image links
for ($i = 2; $i <= 5; $i++) {
if (isset($p['image' . $i])) {
echo '<additional_image_link>' . $p['image' . $i] . "</additional_image_link>\n";
}
}
// Purchase price
if ($p['purchase_price']) {
echo '<cost_of_goods_sold>' . $p['purchase_price'] . "</cost_of_goods_sold>\n";
}
// Price (Mandatory)
echo '<price>' . ($p['old_price'] ? $p['old_price'] : $p['price']) . "</price>\n<sale_price>" .
// Sale price (Mandatory)
$p['price'] . "</sale_price>\n<link>" .
// Link (Mandatory)
$p['url'] . "</link>\n<product_type><![CDATA[" .
// Breadcrumb (Mandatory)
$p['category'] . "]]></product_type>\n<stock>" .
// Stock (Recommended)
$p['stock'] . "</stock>\n";
/* Shipping costs
[shipping] => Array
(
[Worldwide] => Array
(
[Pickup in the store] => 0
[Pickup at collection point] => 0
)
[BE] => Array
(
[Standard delivery] => 10
)
[NL] => Array
(
[Collect on delivery] => 5
)
)
*/
if (isset($p['shipping']) && $p['shipping']) {
$price_set = false;
foreach ($p['shipping'] as $country => $methods) {
// Try to set a shipping price
foreach ($methods as $method => $price) {
if ($price_set) {
break;
}
if ($method != 'Pickup in the store') {
echo '<shipping_price>' . $price . "</shipping_price>\n"; // ' ' . $appdata['webshop']['currency']
$price_set = true;
break;
}
}
}
}
echo "</item>\n";
}
} // displayProducts()
// Check for a valid shop id
function checkId($id) {
return filter_var($id, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'max_range' => 1000000000)));
} // checkId()
?>
body { margin: 0; font-family: Helvetica, Arial, sans-serif; color: #333; background-color: #e4e4e4; }
main { margin: 0 auto; margin-top: 30px; margin-bottom: 30px; padding: 20px; width: 760px; background-color: #fff; border-radius: 8px; border: 1px solid #ccc; box-shadow: 5px 5px 5px #888; }
#logo { float: left; margin-bottom: 10px; }
h1 { font-size: 22px; margin: 0; padding: 0; color: #06c; margin-bottom: 80px; }
hr { clear: both; border-style: solid; border-width: 1px 0 0 0; border-color: #e4e4e4; margin: 20px 0; }
/*--------------------------------
Buttons
-------------------------------*/
a.glowbutton, input[type="submit"], input[type="button"] {
white-space: nowrap; display: inline-block; min-width: 210px; margin: 0 0 10px 0; padding: 0;
text-decoration: none; text-align: center;
color: #fff; background-color: #06c; border: 0; border-radius: 3px;
line-height: 33px; height: 33px; font-weight: bold; font-size: 0.9em;
-webkit-appearance: none; -moz-appearance: none; appearance: none;
transition: background 0.4s;
}
a.glowbutton:hover, input[type="submit"]:hover {
background-color: #06f; text-decoration: none;
}
/*--------------------------------
Fancy
-------------------------------*/
a { color: #06c; text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 1.6em; }
h3 { font-size: 1.4em; }
h4 { font-size: 1.1em; color: #666; }
.blue { color: #06c; }
.orange { color: #f60; }
.code { font-family: monospace; color: #090; }
.code a { font-weight: bold; color: #090; }
.warn { background-color: #fc0; padding: 15px 5px; text-align: center; border-radius: 5px; font-size: 0.9em; box-shadow: 2px 2px 2px #888; }
/*--------------------------------
Forms
-------------------------------*/
textarea { width: 99%; height: 200px; font-size: 1.2em; color: #666; }
input, select, textarea { border: 1px solid #ccc; border-radius: 3px; margin: 0px 0 8px 0; padding: 8px; }
input:focus, textarea:focus { background-color: #eee; }
input[type="checkbox"], input[type="radio"] { border: 0;}
input[type="submit"], input[type="button"] { cursor: pointer; float: right; margin: 10px 0 0 0; }
form table { width: 100%; }
form table td:first-child { width: 50%; }
/*--------------------------------
Responsive
-------------------------------*/
@media all and (max-width: 790px) {
main { max-width: calc(100vw - 20px); margin: 0; padding: 20px 10px; border: none; border-radius: 0; }
textarea { width: 97%; }
}
Πάροχος υπηρεσιών πληρωμών
Αυτός είναι ο τρόπος σύνδεσης ενός παρόχου υπηρεσιών πληρωμών (PSP) με το EasyWebshop.
Η σύνδεση πρέπει να εγκατασταθεί από τον έμπορο και οι μέθοδοι πληρωμής πρέπει να συνδεθούν επιλέγοντάς τους.
Αφού ο πελάτης κάνει μια παραγγελία στο ηλεκτρονικό κατάστημα, εμφανίζεται η σελίδα με το κουμπί Πληρώστε τώρα Αυτό το κουμπί υποβάλλει μια φόρμα HTML.
- Η σύνδεσή σας λαμβάνει τα δεδομένα POST από αυτή τη φόρμα, τα οποία περιλαμβάνουν τον κωδικό παραγγελίας Με το API Connection Token μπορείτε να ανακτήσετε με ασφάλεια τα δεδομένα της παραγγελίας, τα οποία είναι απαραίτητα για τη διεκπεραίωση της πληρωμής.
- Συνδεθείτε στο API του PSP και στείλτε τα δεδομένα της παραγγελίας.
- Εάν η πληρωμή εκτελεστεί με επιτυχία, ο πάροχος υπηρεσιών πληρωμών ζητά το αρχείο report.php το οποίο ενημερώνει την κατάσταση της παραγγελίας στο ηλεκτρονικό κατάστημα σε Πληρωμή ελήφθη
- Ο πελάτης ανακατευθύνεται στη διεύθυνση URL payment ok ή στη διεύθυνση URL payment failed, ανάλογα με την επιτυχία ή την αποτυχία της πληρωμής.
- Εάν έχουν οριστεί πολλαπλές μέθοδοι πληρωμής, ο πελάτης μπορεί να επιλέξει άλλη μέθοδο πληρωμής μετά από μια αποτυχημένη πληρωμή.
- settings.xml
- easywebshop.php
- index.php
- report.php
- style.css
<?xml version="1.0" encoding="UTF-8" ?>
<settings>
<name>DemoPSP</name>
<logo>demo-psp.png</logo>
<type>psp</type>
<url>https://www.webshopdata.com/app/easywebshop-psp/index.php</url>
<parameter name="PSP API key">123456789</parameter>
</settings>
<?php
/*
EasyWebshop API Connector
Documentation: https://easywebshop.com/doc/api
*/
function easyApp($data = '') {
// Set your API Connection Token (not API Token!) here
$conn_token = 'YOUR_API_TOKEN';
// No need to change anything below. You can watch, but you can't touch!
if (!isset($_REQUEST['shop_id']) || !$_REQUEST['shop_id'] ||
!filter_var($_REQUEST['shop_id'], FILTER_VALIDATE_INT,
array('options' => array('min_range' => 1, 'max_range' => 1000000000)))) {
die('Error: $_REQUEST[\'shop_id\'] not set');
}
$settings = new SimpleXMLElement(file_get_contents(dirname(__FILE__) . '/settings.xml'));
$method = isset($data['function']) && substr($data['function'], 0, 3) == 'set' ? 'PUT' : 'GET';
$format = isset($data['format']) && in_array(strtolower($data['format']), array('json', 'xml')) ?
strtolower($data['format']) : 'array';
$data = is_array($data) ? ($method == 'GET' ? http_build_query($data) : json_encode($data)) : '';
$apiurl = 'https://easywebshop.jan/api/conn/' . $_REQUEST['shop_id'] . '/' . $settings->name .
($method == 'GET' && $data ? '?' . $data : ''); // HTTPS only
$opts = array(
'http' => array(
'header' => "Content-Type: application/x-www-form-urlencoded\r\n" .
'Authorization: Bearer ' .
hash('sha512', $_REQUEST['shop_id'] . $settings->name . hash('sha256', $conn_token) . $data) . "\r\n",
'method' => $method,
'ignore_errors' => true),
'ssl' => array('verify_peer' => false, 'verify_peer_name' => false)
);
if ($method == 'PUT') { $opts['http']['content'] = $data; }
$response = file_get_contents($apiurl, false, stream_context_create($opts));
$appdata = $format == 'array' ? json_decode($response, true) : $response;
// Output log - only in debug mode
if (defined('DEBUG') && DEBUG) {
echo "<pre>-- easywebshop.php " . $settings->name . "\n> Accessing API: " .
$apiurl . "\n> API response: " . $response . "--\n</pre>";
}
return $appdata; // this can be a PHP array, JSON or XML, depending on the $data['format'] value
} // easyApp()
?>
<?php
/*--------------------------------------------
* This page redirects a customer to the PSP
Install link:
https://easywebshop.com/software/connections?install=https://www.webshopdata.com/app/easywebshop-psp
Block 1: Variables
Block 2: Languages
Block 3: PSP API code
Block 4: Start page
Block X: Functions
--------------------------------------------*/
/*--------------------------------
Block 1: Variables
-------------------------------*/
// Debug mode for testing, set to false in production
define('DEBUG', true);
// Use test data
define('TEST', true);
// Use for testing without POST vars from payment form
if (TEST) {
$_REQUEST = array('shop_id' => 71911, 'ordercode' => '20250-71911-19417-18497', 'lang' => 'en');
}
define('SHOP_ID', isset($_REQUEST['shop_id']) && checkId($_REQUEST['shop_id']) ? $_REQUEST['shop_id'] : 0);
define('ORDERCODE', isset($_REQUEST['ordercode']) && checkOrderCode($_REQUEST['ordercode']) ? $_REQUEST['ordercode'] : '');
$error = '';
if (!ORDERCODE) {
$error = 'Invalid Order code';
}
// Easywebshop API connector
require 'easywebshop.php';
$appdata = easyApp(array('ordercode' => ORDERCODE));
$settings = (array)simplexml_load_file('settings.xml');
$log = "REQUEST variables:\n\n" . print_r($_REQUEST, true) .
"\n\nAppdata: \n\n" . print_r($appdata, true) . "\n\nSettings: \n\n" . print_r($settings, true);
// URL requested by PSP on payment status update
$reporturl = 'https://' . $_SERVER['HTTP_HOST'] .
substr($_SERVER['DOCUMENT_URI'], 0, strrpos($_SERVER['DOCUMENT_URI'], '/')) .
'/report.php?shop_id=' . SHOP_ID;
/*--------------------------------
Block 2: Languages
-------------------------------*/
// Dutch
if ($_REQUEST['lang'] == 'nl') {
$l_paymentok = 'Betaling geslaagd';
$l_paymentfail = 'Betaling mislukt';
// German
} elseif ($_REQUEST['lang'] == 'de') {
$l_paymentok = 'Zahlung erfolgreich';
$l_paymentfail = 'Zahlung fehlgeschlagen';
// Spanish
} elseif ($_REQUEST['lang'] == 'es') {
$l_paymentok = 'Pago efectuado';
$l_paymentfail = 'Pago fallido';
// French
} elseif ($_REQUEST['lang'] == 'fr') {
$l_paymentok = 'Paiement réussi';
$l_paymentfail = 'Échec du paiement';
// Default to English
} else {
$l_paymentok = 'Payment successful';
$l_paymentfail = 'Payment failed';
}
/*--------------------------------
Block 3: PSP API code
-------------------------------*/
/*--------------------------------
Block 4: Start page
-------------------------------*/
echo '<!DOCTYPE html><html lang="en"><head><title>' . $settings['name'] .
'</title><meta charset="utf-8"><link rel="stylesheet" href="style.css"></head>' .
'<body><main><p><img src="' . $settings['logo'] . '" style="margin: 5px"></p>';
// Error message
if ($error) {
echo '<p class="warn">' . $error . '</p>';
}
// Action buttons
if (isset($appdata['order']['code'])) {
echo '<p class="leftbuttons"><a href="' . $reporturl . '&ordercode=' . $appdata['order']['code'] .
'" class="glowbutton" style="background: #5fc331">' . $l_paymentok . '</a><a href="' .
$appdata['webshop']['paymentfailed'] . '" class="glowbutton" style="background: #c00">' .
$l_paymentfail . '</a></p>';
// Back to webshop
echo '<hr><p><a href="' . $appdata['webshop']['url'] . '/payment/' . $appdata['order']['code'] .
'" class="glowbutton">' . $appdata['webshop']['name'] . '</a></p>';
}
// Debug output -- you can find all $_POST, $appdata and $settings variables here
if (DEBUG) {
echo '<h2>Debug log</h2><pre>' . $log . '</pre>';
}
echo '</main></body></html>';
/*--------------------------------
Block X: Functions
-------------------------------*/
// Check for a valid shop id
function checkId($id) {
return filter_var($id, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'max_range' => 1000000000)));
} // checkId()
function checkOrderCode($code) {
return strlen($code) == 23 && preg_match('/\d\d\d\d\d-\d\d\d\d\d-\d\d\d\d\d-\d\d\d\d\d/', $code);
} // checkOrderCode()
?>
<?php
/*--------------------------------------------
* This page is usually requested "under water" by the PSP and updates the payment status
Block 1: Variables for EasyWebshop API
Block 2: PSP API code
Block 3: Set order paid
Block X: Functions
--------------------------------------------*/
header("Content-Type: text/plain; charset=utf-8");
/*--------------------------------
Block 1: Variables
-------------------------------*/
define('DEBUG', true); // Debug mode for testing, set to false in production
define('DEBUG_EMAIL', 'test@ew.ms'); // Send an email with debug log
$error = '';
// Easywebshop API connector
require 'easywebshop.php';
$appdata = easyApp(); // PSP must send shop_id in GET or POST
$settings = (array)simplexml_load_file('settings.xml');
$log = $settings['name'] . " report.php\n\n" .
'X forwarded: ' . (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
$_SERVER['HTTP_X_FORWARDED_FOR'] : '') .
', IP: ' . $_SERVER['REMOTE_ADDR'] .
"\n\nGET variables:\n\n" . print_r($_GET, true) .
"\n\nPOST variables:\n\n" . print_r($_POST, true) .
"\n\nAppdata: \n\n" . print_r($appdata, true) .
"\n\nSettings: \n\n" . print_r($settings, true);
// report.php needed variables
$order_code = ''; // PSP must send order_code in GET or POST
$order_paid = false; // Set to TRUE if payment is successful
/*--------------------------------
Block 2: PSP API code
-------------------------------*/
// Check if ordercode is correct
if (isset($_REQUEST['ordercode']) && strlen($_REQUEST['ordercode']) == 23 &&
preg_match('/\d\d\d\d\d-\d\d\d\d\d-\d\d\d\d\d-\d\d\d\d\d/', $_REQUEST['ordercode'])) {
$order_code = $_REQUEST['ordercode']; // this variable is safe now
} else {
$error = 'Invalid order code';
}
// Check if correct GET or POST variables are received
if (!$error) {
/* Here you can check if the payment status update request is valid:
- Calculate a hash
- Make a request to the PSP API
*/
// Calculate hash
if (true) {
$order_paid = true;
}
/* Check payment status with PSP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'api_key: ' . $appdata['parameter1'],
'Accept: application/json',
'Content-Type: application/json'
)
);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if (DEBUG) {
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, $verbose = fopen('php://temp', 'rw+'));
curl_setopt($ch, CURLOPT_FILETIME, true);
}
$response = curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
}
curl_close($ch);
if (DEBUG) {
$log .= (isset($error_msg) ? "\n\nHTTP Log:\n" . print_r($error_msg, true) . "\n\n" : '') .
"Verbose information:\n" . !rewind($verbose) . stream_get_contents($verbose) . "\n\n" .
print_r($response, true);
}
$response = json_decode($response, true);
if ($response && isset($response['success']) && $response['success'] &&
isset($response['data']['financial_status']) && $response['data']['financial_status'] == 'completed') {
$order_paid = true;
$order_code = $response['data']['var2'];
}
*/
// Error found
} elseif (DEBUG) {
mailLog($log . "\n\nErrors:\n\n" . $error);
} // no errors
/*--------------------------------
Block 3: Set order paid
-------------------------------*/
if ($order_paid) {
// The connector needs $_REQUEST['shop_id'] and $_REQUEST['ordercode'] for changing the order status
$pmdata = easyApp(array('function' => 'setOrderPaid', 'ordercode' => $order_code));
$log .= "\n\nOrder update result:\n\n" . print_r($pmdata, true);
}
if (DEBUG) {
echo $log;
mailLog($log);
}
// Optional: redirect if customer comes on this page directly
header('Location: ' . $appdata['webshop']['paymentok']);
// Acknowledge we have successfully received a valid notification by returning OK
echo 'OK';
/*--------------------------------
Block X: Functions
-------------------------------*/
// Send mail
function mailLog($log) {
$subject = preg_split('#\r?\n#', ltrim($log), 2)[0]; // get first line
mail(DEBUG_EMAIL, $subject, $log . "\n\n" .
// Username
(isset($_SERVER['PHP_AUTH_USER']) ? 'User: ' . $_SERVER['PHP_AUTH_USER'] . "\n" : '') .
// IP Address
(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] . "\n" : '') .
$_SERVER['REMOTE_ADDR']);
} // mailLog()
die;
?>
body { margin: 0; font-family: Helvetica, Arial, sans-serif; color: #333; background-color: #E4E4E4; }
main {
margin: 0 auto; margin-top: 30px; margin-bottom: 30px; padding: 20px; width: 760px;
background-color: #FFF; border-radius: 8px; border: 1px solid #CCC; box-shadow: 5px 5px 5px #888;
}
h1 { font-size: 22px; margin: 0; padding: 0; color: #06C; margin-bottom: 80px; }
hr { clear: both; border-style: solid; border-width: 1px 0 0 0; border-color: #E4E4E4; margin: 20px 0; }
/*--------------------------------
Navigation
-------------------------------*/
nav { margin: 40px 0; clear: both; }
nav a {
display: block; width: 70%; margin: 30px auto; padding: 20px; vertical-align: top;
border: 1px solid #E4E4E4; box-shadow: 2px 2px 2px #888;
/*border-style: solid; border-width: 0 0 1px 0; border-color: #CCC;*/
text-decoration: none; color: #06C; font-size: 20px; font-weight: bold;
transition: background 0.4s;
}
nav a:hover { background: #EEE; }
nav img { display: inline-block; float: left; width: 100px; height: 100px; vertical-align: top; }
nav span{ display: inline-block; line-height: 100px; text-indent: 30px; }
.langselect { font-size: 0.8em; font-weight: bold; }
/*--------------------------------
Buttons
-------------------------------*/
a.glowbutton, input[type="submit"], input[type="button"] {
white-space: nowrap; display: inline-block; min-width: 210px; margin: 0 0 10px 0; padding: 0;
text-decoration: none; text-align: center;
color: #FFF; background-color: #00abee; border: 0; border-radius: 6px;
line-height: 33px; height: 33px; font-weight: bold; font-size: 0.9em;
-webkit-appearance: none; -moz-appearance: none; appearance: none;
transition: background 0.4s;
}
a.glowbutton:hover, input[type="submit"]:hover {
background-color: #0085c4; text-decoration: none;
}
.leftbuttons a { margin-right: 10px !important; }
/*--------------------------------
Fancy
-------------------------------*/
a { color: #06C; text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 1.6em; }
h3 { font-size: 1.4em; }
h4 { font-size: 1.1em; color: #666; }
.blue { color: #06C; }
.orange { color: #F60; }
.code { font-family: monospace; color: #090; }
.code a { font-weight: bold; color: #090; }
.warn {
background-color: #FC0; padding: 15px 5px; text-align: center;
border-radius: 5px; font-size: 0.9em; box-shadow: 2px 2px 2px #888;
}
/*--------------------------------
Forms
-------------------------------*/
textarea { width: 99%; height: 200px; font-size: 1.2em; color: #666; }
input, select, textarea { border: 1px solid #CCC; border-radius: 3px; padding: 3px; }
input:focus, textarea:focus { background-color: #EEE; }
input[type="checkbox"], input[type="radio"] { border: 0;}
input[type="submit"], input[type="button"] { cursor: pointer; float: right; margin: 10px 0 0 0; }
form table { width: 100%; }
form table td:first-child { width: 50%; }
/*--------------------------------
Responsive
-------------------------------*/
@media all and (max-width: 790px) {
main { width: 100%; margin: 0; padding: 20px 0; border: none; border-radius: 0; }
nav a { margin: 0 auto; margin-top: 20px; margin-bottom: 20px; }
textarea { width: 97%; }
}
Εγκατάσταση συνδέσεων
Αλλάξτε το URL στο παράδειγμα με το URL της σύνδεσής σας. Το back-end μας διαβάζει αυτόματα το αρχείο settings.xml και ζητά από τον χρήστη να εισάγει τα απαραίτητα δεδομένα.
<a href="https://easywebshop.com/software/connections/?install=https://www.webshopdata.com/app/easywebshop-psp">Install</a>
Μπορείτε να προσθέσετε το λογότυπο EasyWebshop στον ιστότοπό σας όταν η σύνδεση είναι έτοιμη.
Αντιμετώπιση προβλημάτων
Βελτιώσαμε το API του EasyWebshop για να το κάνουμε όσο το δυνατόν πιο εύκολο γίνεται. Προσφέρουμε επίσης μια υψηλής ποιότητας υπηρεσία help desk με προαιρετική βοήθεια από έναν προγραμματιστή για πιο τεχνικές ερωτήσεις. Ο σκοπός του API είναι να μπορείτε να συνδεθείτε με άλλες πλατφόρμες και εφαρμογές. Μπορεί να μην έχουν ένα εύκολο στη χρήση API ούτε το επίπεδο υποστήριξης που προσφέρουμε εμείς. Να θυμάστε ότι όταν επικοινωνείτε μαζί μας, μπορούμε να παρέχουμε βοήθεια μόνο για το EasyWebshop και όχι για εξωτερικές εφαρμογές.
Αν χρειάζεστε βοήθεια με γλώσσες προγραμματισμού, είναι καλύτερο να διαβάσετε τις σελίδες τεκμηρίωσής τους. Οι περισσότερες είναι πολύ καλά τεκμηριωμένες. Ενδεχομένως μπορείτε να χρησιμοποιήσετε το AI για να δημιουργήσετε τον κώδικα για τη σύνδεσή σας, αλλά μην περιμένετε ότι η υποστήριξή μας θα διορθώσει σφάλματα στον κώδικά σας.
Κατά τη διάρκεια του Καλοκαιριού του web design αναπτύσσουμε προσαρμοσμένες συνδέσεις για τους χρήστες μας. Αυτές οι συνδέσεις γίνονται από έμπειρους προγραμματιστές. Αν χρειάζεστε μια πολύπλοκη σύνδεση ή λειτουργία, αυτός είναι ο τρόπος για να προχωρήσετε.
- Λαμβάνω το σφάλμα: "Μη έγκυρος κατακερματισμός ακεραιότητας δεδομένων"
- Ελέγξτε ότι το Token σύνδεσης API (όχι ένα κανονικό Token API) έχει οριστεί στο αρχείο easywebshop.php
- Ελέγξτε ότι η διεύθυνση URL έχει οριστεί σωστά
- Ελέγξτε ότι η σύνδεση έχει εγκατασταθεί από ένα webshop
Χρήσιμοι σύνδεσμοι
- REST (Representational State Transfer)
- JSON-LD (JavaScript Object Notation Linked Data)
- curl
- HTTP Status Codes
- W3Schools JSON Tutorial
- JSON online validator
- PHP.net
Οι τεχνολογίες που χρησιμοποιεί το API μας επιλέχθηκαν για τους ακόλουθους λόγους:
- Εύκολη υλοποίηση
- Ασφαλής μεταφορά δεδομένων μέσω HTTPS (όχι άλλες ανασφαλείς συνδέσεις FTP)
- Επικοινωνία σε πραγματικό χρόνο
- Δεν απαιτούνται πρόσθετοι διακομιστές ή επιπλέον βάσεις δεδομένων
- Επεκτάσιμη σε μεγαλύτερους όγκους δεδομένων
- Μπορεί να χρησιμοποιηθεί με οποιαδήποτε πλατφόρμα, πλαίσιο και γλώσσα προγραμματισμού
- Δεν υπάρχουν προβλήματα με τείχη προστασίας
- Χρησιμοποιεί τα πρότυπα και τις γενικές πρακτικές REST, JSON, JSON-LD, XML και HTTPS
- Έλεγχος ταυτότητας φορέα με προσαρμοσμένα δικαιώματα
- Κωδικοποίηση UTF-8
Αν θέλετε να χρησιμοποιήσετε το curl στην PHP, πρέπει να εγκαταστήσετε την επέκταση php-curl. Στα συστήματα που βασίζονται στο Debian (συμπεριλαμβανομένου του Ubuntu), χρησιμοποιήστε την ακόλουθη εντολή:
sudo apt-get install php-curl