Skip to content

Repository files navigation

helloasso-php

The HelloAsso PHP library offers a straightforward way to interact with the HelloAsso API in PHP applications. It features a collection of pre-built classes for API resources that automatically adapt to API responses, ensuring flexibility across different versions of the HelloAsso API.

Installation & Usage

Requirements

PHP 7.4 and later. Should also work with PHP 8.0.

Composer

You can install the bindings via Composer. Run the following command:

composer require helloasso/helloasso-php

To use the bindings, use Composer's autoload:

require_once 'vendor/autoload.php';

Manual Installation

Download the files and include autoload.php:

<?phprequire_once('/path/to/helloasso-php/vendor/autoload.php');

Getting Started

Please follow the installation procedure and then run the following:

<?phprequire_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: OAuth2$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = newOpenAPI\Client\Api\AnnuaireApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.// This is optional, `GuzzleHttp\Client` will be used as default.newGuzzleHttp\Client(),
$config
);
$page_size = 20; // int | The number of items per page$continuation_token = 'continuation_token_example'; // string | Continuation Token from which we wish to retrieve results$hello_asso_api_v5_models_directory_list_forms_request = new \OpenAPI\Client\Model\HelloAssoApiV5ModelsDirectoryListFormsRequest(); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsDirectoryListFormsRequest | Body which contains the filters to applytry {
$result = $apiInstance->directoryFormsPost($page_size, $continuation_token, $hello_asso_api_v5_models_directory_list_forms_request);
print_r($result);
} catch (Exception$e) {
echo'Exception when calling AnnuaireApi->directoryFormsPost: ', $e->getMessage(), PHP_EOL;
}

API Endpoints

All URIs are relative to https://api.helloasso.com/v5

ClassMethodHTTP requestDescription
AnnuaireApidirectoryFormsPostPOST /directory/formsRécupérer les formulaires
AnnuaireApidirectoryOrganizationsPostPOST /directory/organizationsRécupérer les organisations
CheckoutApiorganizationsOrganizationSlugCheckoutIntentsCheckoutIntentIdGetGET /organizations/{organizationSlug}/checkout-intents/{checkoutIntentId}Récupérer une intention de paiement
CheckoutApiorganizationsOrganizationSlugCheckoutIntentsPostPOST /organizations/{organizationSlug}/checkout-intentsInitialisation d'un Checkout
CommandesApiitemsItemIdGetGET /items/{itemId}Obtenir le détail d'un article contenu dans une commande
CommandesApiordersOrderIdCancelPostPOST /orders/{orderId}/cancelAnnuler les paiements futurs pour une commande (pas de remboursement).
CommandesApiordersOrderIdGetGET /orders/{orderId}Obtenir des informations détaillées sur une commande
CommandesApiorganizationsOrganizationSlugFormsFormTypeFormSlugItemsGetGET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/itemsObtenir une liste d'articles vendus dans un formulaire
CommandesApiorganizationsOrganizationSlugFormsFormTypeFormSlugOrdersGetGET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/ordersObtenir les commandes d'un formulaire
CommandesApiorganizationsOrganizationSlugItemsGetGET /organizations/{organizationSlug}/itemsObtenir une liste d'articles vendus par une organisation
CommandesApiorganizationsOrganizationSlugOrdersGetGET /organizations/{organizationSlug}/ordersObtenir les commandes d'une organisation
FormulairesApiorganizationsOrganizationSlugFormTypesGetGET /organizations/{organizationSlug}/formTypesObtenir une liste des types de formulaires pour une organisation
FormulairesApiorganizationsOrganizationSlugFormsFormTypeActionQuickCreatePostPOST /organizations/{organizationSlug}/forms/{formType}/action/quick-createCréer un événement simplifié pour un organisme
FormulairesApiorganizationsOrganizationSlugFormsFormTypeFormSlugPublicGetGET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/publicObtenir des données publiques détaillées sur un formulaire
FormulairesApiorganizationsOrganizationSlugFormsGetGET /organizations/{organizationSlug}/formsObtenir les formulaires d'une organisation
ListeDeValeursApivaluesCompanyLegalStatusGetGET /values/company-legal-statusObtenir la liste des statuts juridiques
ListeDeValeursApivaluesOrganizationCategoriesGetGET /values/organization/categoriesObtenir la liste des catégories du JO
ListeDeValeursApivaluesTagsGetGET /values/tagsObtenir la liste des tags publiques
OrganisationApiorganizationsLegalInformationsLegalStructuresGetGET /organizations/legal-informations/legal-structuresObtenir la structure juridique d'une organisation visible.
OrganisationApiorganizationsLegalInformationsOrganizationSlugConfigurationGetGET /organizations/legal-informations/{organizationSlug}/configurationObtenir la configuration des informations juridiques de l'organisation.
OrganisationApiorganizationsLegalInformationsOrganizationSlugConfigurationPutPUT /organizations/legal-informations/{organizationSlug}/configurationMettre à jour la configuration des informations juridiques de l'organisation.
OrganisationApiorganizationsLegalInformationsTaxInformationTextsGetGET /organizations/legal-informations/tax-information-textsObtenir les textes d'information fiscale de l'organisation.
OrganisationApiorganizationsOrganizationSlugGetGET /organizations/{organizationSlug}Obtenir le détail d'une organisation
PaiementsApiorganizationsOrganizationSlugFormsFormTypeFormSlugPaymentsGetGET /organizations/{organizationSlug}/forms/{formType}/{formSlug}/paymentsObtenir les informations des paiements effectués sur un formulaire
PaiementsApiorganizationsOrganizationSlugPaymentsGetGET /organizations/{organizationSlug}/paymentsObtenir les informations des paiements effectués sur une organisation
PaiementsApiorganizationsOrganizationSlugPaymentsSearchGetGET /organizations/{organizationSlug}/payments/searchRechercher des paiements.
PaiementsApipaymentsPaymentIdGetGET /payments/{paymentId}Obtenir les informations détaillées d'un paiement.
PaiementsApipaymentsPaymentIdRefundPostPOST /payments/{paymentId}/refundRembourser un paiement.
PartenairesApipartnersMeApiClientsPutPUT /partners/me/api-clientsMise à jour du domaine
PartenairesApipartnersMeApiNotificationsDeleteDELETE /partners/me/api-notificationsSuppression de l'URL de notification principale
PartenairesApipartnersMeApiNotificationsOrganizationsOrganizationSlugDeleteDELETE /partners/me/api-notifications/organizations/{organizationSlug}Suppression d'une URL de notification liée à une organisation
PartenairesApipartnersMeApiNotificationsOrganizationsOrganizationSlugPutPUT /partners/me/api-notifications/organizations/{organizationSlug}Mise à jour d'une URL de notification liée à une organisation
PartenairesApipartnersMeApiNotificationsPutPUT /partners/me/api-notificationsMise à jour de l'URL de notification principale
PartenairesApipartnersMeGetGET /partners/meRécupération des informations
PartenairesApipartnersMeOrganizationsGetGET /partners/me/organizationsObtenir toutes les organisations
ReusFiscauxApiorganizationsOrganizationSlugTaxReceiptConfigurationGetGET /organizations/{organizationSlug}/tax-receipt/configurationObtenir la configuration des reçus fiscaux
ReusFiscauxApiorganizationsOrganizationSlugTaxReceiptConfigurationPutPUT /organizations/{organizationSlug}/tax-receipt/configurationMettre à jour la configuration des reçus fiscaux
ReusFiscauxApiorganizationsOrganizationSlugTaxReceiptFiscalReceiptTransmitterPutPUT /organizations/{organizationSlug}/tax-receipt/fiscal-receipt-transmitterMettre à jour l'émetteur des reçus fiscaux
ReusFiscauxApiorganizationsOrganizationSlugTaxReceiptPreviewPostPOST /organizations/{organizationSlug}/tax-receipt/previewPrévisualiser les reçus fiscaux
TagsApitagsTagNameGetGET /tags/{tagName}Obtenir le détail d'un tag interne
UtilisateursApiusersMeOrganizationsGetGET /users/me/organizationsObtenir mes organisations

Models

Authorization

We use OAuth2 for authentication, so to avoid reinventing the wheel, we recommend using the league/oauth2-client package

Prerequisite

Install the league/oauth2-client package:

composer require league/oauth2-client

Client Credentials Flow

require'vendor/autoload.php';
useLeague\OAuth2\Client\Provider\GenericProvider;
$provider = newGenericProvider([
'clientId' => 'your_client_id',
'clientSecret' => 'your_client_secret',
'urlAccessToken' => 'https://api.helloasso.com/oauth2/token',
'urlAuthorize' => '',
'urlResourceOwnerDetails' => ''
]);
try {
// Get access token using client credentials$accessToken = $provider->getAccessToken('client_credentials');
echo'Access Token: ' . $accessToken->getToken();
echo'Expires in: ' . $accessToken->getExpires();
echo'Refresh Token: ' . $accessToken->getRefreshToken();
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException$e) {
echo'Error: ' . $e->getMessage();
}

Refresh Token Flow

require'vendor/autoload.php';
useLeague\OAuth2\Client\Provider\GenericProvider;
$provider = newGenericProvider([
'clientId' => 'your_client_id',
'clientSecret' => 'your_client_secret',
'urlAccessToken' => 'https://api.helloasso.com/oauth2/token',
'urlAuthorize' => '',
'urlResourceOwnerDetails' => ''
]);
$refreshToken = 'your_refresh_token';
try {
// Refresh the access token$newAccessToken = $provider->getAccessToken('refresh_token', [
'refresh_token' => $refreshToken,
]);
echo'New Access Token: ' . $newAccessToken->getToken();
echo'Expires in: ' . $newAccessToken->getExpires();
echo'New Refresh Token: ' . $accessToken->getRefreshToken();
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException$e) {
echo'Error: ' . $e->getMessage();
}

Authorization Code Flow

require'vendor/autoload.php';
useLeague\OAuth2\Client\Provider\GenericProvider;
$provider = newGenericProvider([
'clientId' => 'your_client_id',
'clientSecret' => 'your_client_secret',
'redirectUri' => 'https://your-app.com/callback',
'urlAuthorize' => 'https://auth.helloasso.com/authorize',
'urlAccessToken' => 'https://api.helloasso.com/oauth2/token',
'urlResourceOwnerDetails' => ''
]);
// Function to generate a random code verifierfunctiongenerateCodeVerifier() {
returnbin2hex(random_bytes(32));
}
// Function to generate a code challenge from the code verifierfunctiongenerateCodeChallenge($codeVerifier) {
returnrtrim(strtr(base64_encode(hash('sha256', $codeVerifier, true)), '+/', '-_'), '=');
}
// Step 1: Generate the authorization URLfunctionGetAuthorizationUrl($provider) {
$codeVerifier = generateCodeVerifier();
$codeChallenge = generateCodeChallenge($codeVerifier);
$authorizationUrl = $provider->getAuthorizationUrl([
'state' => 'random_state_string',
'code_challenge' => $codeChallenge,
'code_challenge_method' => 'S256',
]);
echo'Authorization URL: ' . $authorizationUrl . "\n";
echo'Code verifier: ' . $codeVerifier . "\n";
}
// Step 2: Handle the callback and exchange the authorization code for an access tokenfunctionGetAccessTokenFromCode($provider, $authorizationCode, $codeVerifier) {
try {
// Get access token$accessToken = $provider->getAccessToken('authorization_code', [
'code' => $authorizationCode,
'code_verifier' => $codeVerifier
]);
echo'Access Token: ' . $accessToken->getToken() . "\n";
echo'Expires in: ' . $accessToken->getExpires() . "\n";
echo'New Refresh Token: ' . $accessToken->getRefreshToken() . "\n";
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException$e) {
echo'Error: ' . $e->getMessage();
}
}
GetAuthorizationUrl($provider);
// After user authorizes, exchange the code (passed in the redirect URL callback)//GetAccessTokenFromCode($provider, 'your_authorization_code', 'your_code_verifier');

Tests

To run the tests, use:

composer install
vendor/bin/phpunit

About this package

This PHP package is automatically generated by the OpenAPI Generator project:

  • API version: public
    • Generator version: 7.10.0
  • Build package: org.openapitools.codegen.languages.PhpClientCodegen

About

SDK PHP pour l'API HelloAsso

Resources

Stars

7 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages