### Install league/oauth2-client with Composer Source: https://github.com/helloasso/helloasso-php/blob/main/README.md This command installs the necessary league/oauth2-client package using Composer, which is a prerequisite for using OAuth2 authentication with the HelloAsso PHP SDK. ```bash composer require league/oauth2-client ``` -------------------------------- ### Manual Installation and Autoloader Inclusion Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Demonstrates manual installation by requiring the autoloader file. This method is an alternative if Composer is not used, but requires manual path management. ```php ordersOrderIdGet('yourOrderId'); ?> ``` -------------------------------- ### Get Partner Information (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/docs/Api/PartenairesApi.md Retrieves public information for the authenticated partner. Requires the 'AccessPublicData' privilege. The example shows how to configure the API client with an OAuth2 access token and make the `partnersMeGet` call. ```php setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPI\Client\Api\PartenairesApi( // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`. // This is optional, `GuzzleHttpClient` will be used as default. new GuzzleHttpClient(), $config ); try { $result = $apiInstance->partnersMeGet(); print_r($result); } catch (Exception $e) { echo 'Exception when calling PartenairesApi->partnersMeGet: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Order Details - PHP Source: https://github.com/helloasso/helloasso-php/blob/main/docs/Api/CommandesApi.md This example shows how to retrieve detailed information about a specific order using the HelloAsso PHP SDK. It requires the order ID and an OAuth2 access token. The `ordersOrderIdGet` method fetches the order details, which are then printed. ```PHP setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPIClientApiCommandesApi( // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`. // This is optional, `GuzzleHttpClient` will be used as default. new GuzzleHttpClient(), $config ); $order_id = 56; // int try { $result = $apiInstance->ordersOrderIdGet($order_id); print_r($result); } catch (Exception $e) { echo 'Exception when calling CommandesApi->ordersOrderIdGet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Get Orders by Organization and Form Type (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/docs/Api/CommandesApi.md This example shows how to retrieve a list of orders for a given organization and form type using the HelloAsso PHP SDK. It configures the API client with an access token and makes a call to the `organizationsOrganizationSlugFormsFormTypeFormSlugOrdersGet` method, handling potential exceptions. ```php setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPIClientApiCommandesApi( // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`. // This is optional, `GuzzleHttpClient` will be used as default. new GuzzleHttpClient(), $config ); $organization_slug = 'organization_slug_example'; // string | The organization slug $form_slug = 'form_slug_example'; // string | The form slug $form_type = new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsFormType(); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsEnumsFormType | The form type CrowdFunding, Membership, Event, Donation, PaymentForm, Checkout, Shop $from = new DateTime('2013-10-20T19:20:30+01:00'); // \DateTime | First Date Filter $to = new DateTime('2013-10-20T19:20:30+01:00'); // \DateTime | End Date Filter (exclusive) $user_search_key = 'user_search_key_example'; // string | Filter results on user or payer first name, last name or email $page_index = 1; // int | The page of results to retrieve $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 $with_details = false; // bool | Set to true to return CustomFields $sort_order = new OpenAPIClientModel\OpenAPI\Client\ModelHelloAssoApiV5ModelsEnumsSortOrder(); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsEnumsSortOrder | Sort forms orders by ascending or descending order. Default is descending $with_count = false; // bool | Whether the pagination should include totalCount and totalPages. try { $result = $apiInstance->organizationsOrganizationSlugFormsFormTypeFormSlugOrdersGet($organization_slug, $form_slug, $form_type, $from, $to, $user_search_key, $page_index, $page_size, $continuation_token, $with_details, $sort_order, $with_count); print_r($result); } catch (Exception $e) { echo 'Exception when calling CommandesApi->organizationsOrganizationSlugFormsFormTypeFormSlugOrdersGet: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Public Tags List (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Retrieves the list of public tags using the ListeDeValeursApi. This is a simple GET request. ```PHP valuesTagsGet(); ?> ``` -------------------------------- ### Get Organization Categories List (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Retrieves the list of organization categories from the official journal using the ListeDeValeursApi. This is a simple GET request. ```PHP valuesOrganizationCategoriesGet(); ?> ``` -------------------------------- ### PHP Model: Form Quick Create Model Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Represents the data structure for creating a quick form in the HelloAsso API. It includes details necessary for form configuration and setup. ```PHP setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPIClientApiAnnuaireApi( // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`. // This is optional, `GuzzleHttpClient` will be used as default. new GuzzleHttpClient(), $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 OpenAPIClientModelHelloAssoApiV5ModelsDirectoryListFormsRequest(); // OpenAPIClientModelHelloAssoApiV5ModelsDirectoryListFormsRequest | Body which contains the filters to apply try { $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; } ``` -------------------------------- ### Get Company Legal Status List (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Retrieves the list of company legal statuses using the ListeDeValeursApi. This is a simple GET request. ```PHP valuesCompanyLegalStatusGet(); ?> ``` -------------------------------- ### Initialize Checkout (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Initializes a checkout process for an organization using the CheckoutApi. This endpoint requires the organization's slug. ```PHP organizationsOrganizationSlugCheckoutIntentsPost('yourOrganizationSlug'); ?> ``` -------------------------------- ### Quick Create Form Event (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Creates a simplified event for an organization using the FormulairesApi. Requires organization slug and form type. ```PHP organizationsOrganizationSlugFormsFormTypeActionQuickCreatePost('yourOrganizationSlug', 'yourFormType'); ?> ``` -------------------------------- ### PHP Model: Form Quick Create Request Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Defines the request object for creating a quick form via the HelloAsso API. This model encapsulates all the required parameters for the API call. ```PHP '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 verifier function generateCodeVerifier() { return bin2hex(random_bytes(32)); } // Function to generate a code challenge from the code verifier function generateCodeChallenge($codeVerifier) { return rtrim(strtr(base64_encode(hash('sha256', $codeVerifier, true)), '+/', '-_'), '='); } // Step 1: Generate the authorization URL function GetAuthorizationUrl($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 token function GetAccessTokenFromCode($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'); ``` -------------------------------- ### Get Tax Receipt Configuration (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/docs/Api/TaxReceiptApi.md Retrieves the tax receipt configuration for a given organization. Requires the OrganizationAdmin role. The operation uses a GET request to the /organizations/{organizationSlug}/tax-receipt/configuration endpoint. ```PHP organizationsOrganizationSlugTaxReceiptConfigurationGet($organization_slug); print_r($result); } catch (Exception $e) { echo 'Exception when calling TaxReceiptApi->organizationsOrganizationSlugTaxReceiptConfigurationGet: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Quick Create Event Form - PHP Source: https://github.com/helloasso/helloasso-php/blob/main/docs/Api/FormulairesApi.md Allows the creation of a simplified event with limited information and simple pricing. The event created this way can be modified later with other services. Requires OrganizationAdmin role and FormAdministration privilege. ```php setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPIClientApiFormulairesApi( // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`. // This is optional, `GuzzleHttpClient` will be used as default. new GuzzleHttpClient(), $config ); $organization_slug = 'organization_slug_example'; // string | The organization Slug $form_type = new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsFormType(); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsEnumsFormType | The form type to create - only Event type is supported $hello_asso_api_v5_models_forms_form_quick_create_request = new OpenAPIClientModelHelloAssoApiV5ModelsFormsFormQuickCreateRequest(); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsFormsFormQuickCreateRequest | The body of the request. try { $result = $apiInstance->organizationsOrganizationSlugFormsFormTypeActionQuickCreatePost($organization_slug, $form_type, $hello_asso_api_v5_models_forms_form_quick_create_request); print_r($result); } catch (Exception $e) { echo 'Exception when calling FormulairesApi->organizationsOrganizationSlugFormsFormTypeActionQuickCreatePost: ', $e->getMessage(), PHP_EOL; } ?> ``` -------------------------------- ### Get Form Items with HelloAsso PHP SDK Source: https://github.com/helloasso/helloasso-php/blob/main/docs/Api/CommandesApi.md This snippet shows how to retrieve form items from the HelloAsso API using the PHP SDK. It includes setting up the API client with an access token and making a GET request to fetch items, allowing for extensive filtering by date, user, item state, tier, and more, as well as sorting and pagination. ```PHP setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPIClientApiCommandesApi( // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`. // This is optional, `GuzzleHttpClient` will be used as default. new GuzzleHttpClient(), $config ); $organization_slug = 'organization_slug_example'; // string | The organization slug $form_slug = 'form_slug_example'; // string | The form slug $form_type = new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsFormType(); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsEnumsFormType | The form type CrowdFunding, Membership, Event, Donation, PaymentForm, Checkout, Shop $from = new DateTime('2013-10-20T19:20:30+01:00'); // \DateTime | First Date Filter $to = new DateTime('2013-10-20T19:20:30+01:00'); // \DateTime | End Date Filter (exclusive) $user_search_key = 'user_search_key_example'; // string | Filter results on user or payer first name, last name or email $page_index = 1; // int | The page of results to retrieve $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 $tier_types = array(new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsTierType()); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsEnumsTierType[] | The type of tiers $item_states = array(new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsItemState()); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsEnumsItemState[] | The item states Available values: * `Processed` - The item is paid and is valid * `Registered` - The item has been registered manually by the organization and is valid * `Unknown` * `Canceled` - The item has been canceled, and is no longer valid $tier_name = 'tier_name_example'; // string | The name of a tier $with_details = false; // bool | Set to true to return CustomFields and Options $sort_order = new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsSortOrder(); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsEnumsSortOrder | Sort forms items by ascending or descending order. Default is descending $sort_field = new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsSortField(); // \OpenAPI\Client\Model\HelloAssoApiV5ModelsEnumsSortField | Sort forms items by a specific field (Date or UpdateDate). Default is date $with_count = false; // bool | Whether the pagination should include totalCount and totalPages. try { $apiInstance->organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet($organization_slug, $form_slug, $form_type, $from, $to, $user_search_key, $page_index, $page_size, $continuation_token, $tier_types, $item_states, $tier_name, $with_details, $sort_order, $sort_field, $with_count); } catch (Exception $e) { echo 'Exception when calling CommandesApi->organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### PHP Model: Statistics Refund Operation Light Source: https://github.com/helloasso/helloasso-php/blob/main/README.md A lightweight model for refund operations, providing essential details for summaries. This model is optimized for displaying refund information in lists. ```PHP ``` -------------------------------- ### PHP Model: Organization Light Model Source: https://github.com/helloasso/helloasso-php/blob/main/README.md A lightweight model for organizations, providing essential details for list views or summaries. This model is optimized for performance when full details are not required. ```PHP ``` -------------------------------- ### PHP Model: Organization Fiscal Receipt Options Configuration Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Configuration settings for an organization's fiscal receipt options. This model defines how fiscal receipts are generated and managed. ```PHP ``` -------------------------------- ### Get Tag Details (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Retrieves the detailed information for a specific internal tag. This endpoint is provided by the TagsApi. ```PHP ``` -------------------------------- ### Get Organization Payments (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Fetches payment information associated with a specific organization. This endpoint is part of the PaiementsApi. ```PHP ``` -------------------------------- ### List Partner Organizations (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/docs/Api/PartenairesApi.md Fetches a list of organizations associated with the partner. Results are sorted by API visibility update date. The example demonstrates how to set pagination parameters like `page_size` and `continuation_token` for the `partnersMeOrganizationsGet` method. ```php setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPI\Client\Api\PartenairesApi( // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`. // This is optional, `GuzzleHttpClient` will be used as default. new GuzzleHttpClient(), $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 try { $result = $apiInstance->partnersMeOrganizationsGet($page_size, $continuation_token); print_r($result); } catch (Exception $e) { echo 'Exception when calling PartenairesApi->partnersMeOrganizationsGet: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Payment Details (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Retrieves detailed information for a specific payment using its ID. This endpoint is part of the PaiementsApi. ```PHP ``` -------------------------------- ### Search Payments with HelloAsso PHP SDK Source: https://github.com/helloasso/helloasso-php/blob/main/docs/Api/PaiementsApi.md This snippet shows how to configure the HelloAsso PHP SDK, instantiate the Payments API client, and perform a search for payments. It includes parameters for filtering by date, form type, payment state, user ID, search key, amount, and sorting options. ```PHP setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPIClientApiPaiementsApi( // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`. // This is optional, `GuzzleHttpClient` will be used as default. new GuzzleHttpClient(), $config ); $organization_slug = 'organization_slug_example'; // string | The organization slug $from = new DateTime('2013-10-20T19:20:30+01:00'); // \DateTime | First Date Filter $to = new DateTime('2013-10-20T19:20:30+01:00'); // \DateTime | End Date Filter (exclusive) $page_size = 20; // int | The number of items to retrieve $continuation_token = 'continuation_token_example'; // string | Continuation Token from which we wish to retrieve results $form_types = array(new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsFormType()); // \OpenAPIClientModelHelloAssoApiV5ModelsEnumsFormType[] | The form type CrowdFunding, Membership, Event, Donation, PaymentForm, Checkout, Shop $form_type = new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsFormType(); // \OpenAPIClientModelHelloAssoApiV5ModelsEnumsFormType | The form type CrowdFunding, Membership, Event, Donation, PaymentForm, Checkout, Shop. This parameter must be used with the parameter formId. $states = array(new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsPaymentState()); // \OpenAPIClientModelHelloAssoApiV5ModelsEnumsPaymentState[] | Filter results by states of payments Available values: * `Pending` - A payment scheduled at a later date, not yet processed. * `Authorized` - The payment has been authorized, validated, processed. * `Refused` - The payment has been refused by the bank. * `Unknown` * `Registered` - Represents a payment made offline. Probably for an item of type * `Refunded` - The payment has been refunded. * `Refunding` - The payment is being refunded. * `Contested` - Payment has been contested by the contributor $user_id = 56; // int | The User identifier $search_key = 'search_key_example'; // string | Filter results on user or payer first name, last name or email. $amount = 56; // int | Amount of the payment in cents. Filter payments with exact amount with or without the contribution. $sort_order = new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsSortOrder(); // \OpenAPIClientModelHelloAssoApiV5ModelsEnumsSortOrder | Sort payments by ascending or descending order. Default is descending $sort_field = new OpenAPIClientModel\OpenAPIClientModelHelloAssoApiV5ModelsEnumsSortField(); // \OpenAPIClientModelHelloAssoApiV5ModelsEnumsSortField | Sort payments by a specific field (Date or UpdateDate). Default is date try { $result = $apiInstance->organizationsOrganizationSlugPaymentsSearchGet($organization_slug, $from, $to, $page_size, $continuation_token, $form_types, $form_type, $states, $user_id, $search_key, $amount, $sort_order, $sort_field); print_r($result); } catch (Exception $e) { echo 'Exception when calling PaiementsApi->organizationsOrganizationSlugPaymentsSearchGet: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Organization Forms (PHP) Source: https://github.com/helloasso/helloasso-php/blob/main/README.md Retrieves forms for a specific organization using the FormulairesApi. Requires the organization's slug. ```PHP organizationsOrganizationSlugFormsGet('yourOrganizationSlug'); ?> ``` -------------------------------- ### Refund a Payment using HelloAsso PHP SDK Source: https://github.com/helloasso/helloasso-php/blob/main/docs/Api/PaiementsApi.md This snippet demonstrates how to refund a payment using the `paymentsPaymentIdRefundPost` method of the HelloAsso PHP SDK. It includes setting up the OAuth2 configuration, instantiating the API client, and making the refund call with various parameters like payment ID, comment, cancellation options, and amount. Error handling is also included. ```php setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new OpenAPIClientApiPaiementsApi( // If you want use custom http client, pass your client which implements `GuzzleHttpClientInterface`. // This is optional, `GuzzleHttpClient` will be used as default. new GuzzleHttpClient(), $config ); $payment_id = 56; // int | The payment identifier. $comment = 'comment_example'; // string | The comment about this refund. $cancel_order = false; // bool | Whether the future payments and linked items of this order must be canceled (possible only if the payment is fully refunded) $send_refund_mail = true; // bool | Whether a refund mail must be sent or not. $amount = 0; // int | The amount in cents to refund. Enter this amount only for a partial refund for stripe. If not filled in then the entire payment is refunded try { $result = $apiInstance->paymentsPaymentIdRefundPost($payment_id, $comment, $cancel_order, $send_refund_mail, $amount); print_r($result); } catch (Exception $e) { echo 'Exception when calling PaiementsApi->paymentsPaymentIdRefundPost: ', $e->getMessage(), PHP_EOL; } ```