Table des matières
- Selling Pay-Per-Download Products - Vendre des produits à télécharger (dématérialisés)
- The buyer experience -- L'expérience client
- Setting up the product and permission structure -- Mise en oeuvre du produit et des permissions
- Payment process -- Processus de paiement
- Extension: Assigning permissions upon purchase part 1 -- Extension: assignation des droits à l'achat (partie 1)
- Pay-per-download extension part 2 -- Extension Pay-per-download (partie 2)
- Confirmation e-mails and pages -- Mails et pages de confirmation
- Extra considerations -- Considérations complémentaires
- Paypal Sandbox : comptes de test et devises
- Modification pour eZ Publish 4.3+
Setting up the product and permission structure -- Mise en oeuvre du produit et des permissions
Date de publication: le vendredi 28 janvier 2011 à 00h52
Dernière modification: par Pascal BOYER le jeudi 17 février 2011 à 20h33
Versions: 4.x
Our example site will sell PDF books, giving buyers the advantage of getting the book cheaper and faster, and removing the need for us to ship the books.
Notre exemple de site, qui vendra des livres au format PDF, proposera aux acheteurs l'avantage d'acquérir ces livres rapidement et à des prix concurrentiels tout en nous déchargeant de l'envoi des livres.
In preparation for the following steps and to ease the testing process, log in to the Administration Interface as an Administrator user, and create a user under the Members user group. This article will name this user "Test User". This user will be your test buyer.
Avant d'aborder les étapes suivantes et afin de faciliter la procédure de test, connectez-vous à l'interface d'administration en tant qu'administrateur puis créez un utilisateur sous le groupe Members. Dans cet article, cet utilisateur, qui sera notre utilisateur de test, est dénommé Utilisateur De test:
Test User / L'utilisateur «Utilisateur De test»
Product class / La classe Product
A default Website Interface installation comes with a basic "Product" class, consisting of at least a name, a description, an image, and a price. The "Price" attribute is what makes the content object a recognized product in the webshop, and the other attributes are useful for descriptive purposes.
Une installation par défaut de type Website Interface propose une classe Product basique contenant au moins un nom, une description, une image et un prix. Alors que l'attribut Prix fait de l'objet de contenu un produit reconnu dans la Boutique, les autres attributs servent à décrire le produit.
For simplicity, we will assume that every product on our site represents a digital download. Therefore, we will modify the existing "Product" class in order to associate a file with each Product object.
Afin de simplifier les choses, nous supposerons que tous les produits de notre site représentent des contenus à télécharger. Nous modifierons donc la classe Product existante afin de pouvoir associer un fichier à chaque objet Product.
Sign in to the Administration Interface using the Administrator user account and go to the "Setup > Classes" page. Then, click to view the classes in the "Content" class group. In the list of classes, click the "Edit" icon for the "Product" class.
Une fois connecté à l'interface d'administration en tant qu'administrateur, cliquez sur l'onglet Administration puis sur le lien Classes dans le menu gauche puis sur le lien Content afin d'afficher les classes de ce groupe. Dans la liste qui s'affiche alors, cliquez sur l'icône Modifier la classe <Product> situé à l'opposé du nom de la classe Product:
Product Class / La classe Product
At the bottom of the "Class edit" interface for the "Product" class, add a new attribute of the "Object relation" type. Name the attribute "Download file" with an identifier "download". For our purposes, we will make this attribute required but not searchable.
Au bas de l'interface d'édition de la classe, ajoutez un nouvel attribut Relation d'objet (et non Relation d'objets). Nommez l'attribut Télécharcher le fichier et l'identifiant download. Pour nos besoins nous cochons l'option Obligatoire mais pas Interrogeable:
Download File Attribute/ L'attribut Télécharger le fichier
The reason why we are using an attribute of the "Object relation" datatype is so that we can store the actual files in a location of the content tree separate from products. The products can be viewed by everybody, but access to the download files will, by default, be prohibited to the general public and granted to buyers as needed.
La raison pour laquelle nous utilisons un attribut de type Relation d'objet est qu'ainsi nous pouvons stocker les fichiers dans notre arborescence séparément des produits. Alors que les produits doivent être vus par quiconque, l'accès aux téléchargement des fichiers sera interdit par défaut mais accordé à l'acheteur.
Location for download files / Emplacement des fichiers à télécharger
A good place to put the download files is in the media library, as the general public cannot browse that section through the front-end of the site, and the fact that it is separate from the rest of the content makes for better organization. Therefore, create a "Folder" object called "Downloads" in the media library.
La médiathèque constitue un bon emplacement pour entreposer les fichiers à télécharger puisque les visiteurs ne peuvent parcourir cette section depuis le site public. Par ailleurs, la médiathèque étant séparée du reste de l'arborescence de contenus, l'organisation n'en sera que meilleure. Créez donc un objet Folder nommé Téléchargements dans la médiathèque.
Under the "Downloads" folder, create a "File" object, uploading the file for a book you are selling.
Puis créez, sous votre dossier Téléchargements, un objet File contenant le livre que vous souhaitez vendre:
Media Library Downloads Folder/ Le dossier Téléchargements dans la Médiathèque
Create a product object / Créer un produit
Since we are using a Website Interface install we can use the existing products location and templates. Browse to the "Content structure" tab in the Administration Interface, click to the "Products" folder, then create a sub-item folder called "Books". Under the "Books" folder, create a "Product" object. Give it whatever name, description, price, and image you want. When it comes to the "Download file" attribute, add the "File" object you created above as the related object.
Puisque nous disposons d'une installation par défaut de type Website Interface, nous pouvons utiliser les templates et emplacement des produits déjà existants. Placez-vous dans l'onglet Contenus de l'interface d'administration puis cliquez sur le dossier Products et créez alors un sous-dossier Folder nommé Livres. Dans ce nouveau dossier créez un objet Product nommé comme bon vous semblera, contenant une description, un prix et associez-lui éventuellement une image. Dans l'attribut Télécharger le fichier, ajoutez l'objet File que vous venez de créer dans Médiathèque:
Download File Related Object/L'attribut Relation d'objet «Télécharger le fichier»
Once you have published your book product, view it on the front-end of the site, noting that the download file is not used by the template and thus not publicly displayed.
Après avoir publié votre produit livre, visualisez-le sur votre site public. Vous pouvez alors observer que le fichier à télécharger n'étant pas utilisé par le template il n'est pas affiché sur le site public.
Book Product/ Le produit sur le site public
Now, log in to the front-end of the site using the Test User account you previously created. If you try to access the file directly on the front end (through a URL such as "yoursite.com/Media/Downloads/eZ-Publish-Advanced-Content-Management-PDF"), you should get an "Access denied" error.
Connectez-vous à présent à l'interface public en utilisant le compte Utilisateur De test précédemment créé. Si vous tentez alors d'accéder directement au fichier (par le biais d'un URI de type votresite.com/Media/Telechargements/Constitution-de-1791") vous obtiendrez un message «Accès refusé - Vous n'avez pas le droit d'accéder à cette zone»
Pay-per-download role / Le rôle Paiement-au-telechargement
Now, let's create create a role that will provide access to the files associated with purchased products. Under the "User accounts" tab in the Administration Interface, click the "Roles and policies" link in the left menu. Then, create a new role called "Pay-per-download" that has a policy giving permission to the "read" function of the "content" module under the "Media" section.
Nous allons maintenant créer un rôle ayant accès aux fichiers associés aux produits achetés. Dans l'onglet Comptes utilisateurs de l'interface d'administration cliquez sur le lien Rôles et droits du menu gauche. Créez alors un nouveau rôle nommé Paiement-au-telechargement et octroyez-lui, pour la section Media, les droits sur la fonction read du module content :
Pay Per Download Role/Le rôle Paiement-au-Telechargement
This is a broad role that we will assign per-user, per-product using the subtree limitation. This assignment will be done automatically at the end of the checkout process. However, you can test this by assigning the role to the "Test User" account, with a subtree limitation of the "File" object you created.
Il s'agit là d'un rôle générique que nous assignerons à chaque utilisateur pour chaque produit en utilisant la limitation Sous-arborescence. L'assignation sera effectuée automatiquement à la fin du processus de commande. Vous pouvez cependant tester cela en assignant le rôle à l'utilisateur Utilisateur De test avec l'objet File que vous avez créé (dans le dossier Téléchargements de l'onglet Médiathèque) comme limitation Sous-arborescence.
Role Assignment/ Assignation du rôle
Then, see whether that Test User user can access "yoursite.com/Media/Downloads/eZ-Publish-Advanced-Content-Management-PDF". When you have confirmed this, remove the role assignment.
Vérifiez alors que l'utilisateur Utilisateur De test peut accéder à l'URI votresite.com/Media/Telechargements/Constitution-de-1791. Après avoir validé cette étape n'oubliez pas de supprimer l'assignation du rôle.
Now that we've set up the content and permission structure for our pay-per-download functionality, we can move on to the next step, which is installing a payment gateway.
A présent que nous avons défini le contenu et les permissions de notre fonction paiement-au-telechargement nous pouvons passer à l'étape suivante, à savoir l'installation de la passerelle de paiement.
Table des matières
- Selling Pay-Per-Download Products - Vendre des produits à télécharger (dématérialisés)
- The buyer experience -- L'expérience client
- Setting up the product and permission structure -- Mise en oeuvre du produit et des permissions
- Payment process -- Processus de paiement
- Extension: Assigning permissions upon purchase part 1 -- Extension: assignation des droits à l'achat (partie 1)
- Pay-per-download extension part 2 -- Extension Pay-per-download (partie 2)
- Confirmation e-mails and pages -- Mails et pages de confirmation
- Extra considerations -- Considérations complémentaires
- Paypal Sandbox : comptes de test et devises
- Modification pour eZ Publish 4.3+
Commentaires














