You are here

DEVELOPERS.txt in Stripe 7

GENERAL USAGE
-------------

The Stripe module uses Libraries API to integrate Stripe's PHP API into Drupal.

To load the Stripe PHP API from inside your module, simply do:

<?php
stripe_load_library();
?>

When the library is loaded, the configured (secret) site-wide API key is
automatically set using Stripe::setApiKey(). If needed, the API key can be
changed by calling Stripe::setApiKey() with another value or passing the
alternative kay as argument of the various Stripe statics methods.

See https://drupal.org/node/1342238 for more information.

The module define a new Form API element type to input a Stripe token. This form
element will be rendered as a field set containing the elements required to
collect the information needed to create a token. On submit, the information
will used to created a new token which will be send to the server. AJAX form
submission is supported too. A failed token creation will prevent a normal form
submission but not an AJAX submission.

This input form element support the following properties:
 - #cardholder_name: Can either be a boolean or an array. If TRUE, the field set
   will include an element to input the card holder's name. If an array is used,
   in must contains the identifier (ie. like the #parents property) of an
   existing form element to be used to input the card holder's name. In all
   other cases, the field set will not include a card holder's input element.
 - #address: Can either be a boolean or an array. If TRUE, the field set
   will include elements to input the card holder's address. If an array is
   used, in must contains the identifier (ie. like the #parents property) of an
   existing form container with the input elements to use for the the card
   holder's address. In all other cases, the field set will not include card
   holder's address input element.
 - #cvc: If TRUE, the field set will include a CVC input element.
 - #publishable_key: The publishable key to use to create the token. If empty,
   the currently active site-wide publishable key will be used.

The address field set uses a structure similar the one provided by the Address
Field module (https://drupal.org/project/addressfield):
 - 'thoroughfare' as 'address_line1'
 - 'premise' as 'address_line2'
 - 'locality' as 'address_city'
 - 'administrative_area' as 'address_state'
 - 'postal_code' as 'address_zip'
 - 'country'  as 'address_country

CONFIGURATION
-------------

The Stripe module store site-wide API keys in 4 configuration variables:
'stripe_test_secret', 'stripe_test_publishable', 'stripe_live_secret' and
'stripe_publishable_secret'. A fifth variable is used to configure the active
environment: 'stripe_key_status'. Its value should be one of 'test' or 'live'.

The stripe_get_key() function is the recommended way to retrieve the value of
these variables.

File

DEVELOPERS.txt
View source
  1. GENERAL USAGE
  2. -------------
  3. The Stripe module uses Libraries API to integrate Stripe's PHP API into Drupal.
  4. To load the Stripe PHP API from inside your module, simply do:
  5. stripe_load_library();
  6. ?>
  7. When the library is loaded, the configured (secret) site-wide API key is
  8. automatically set using Stripe::setApiKey(). If needed, the API key can be
  9. changed by calling Stripe::setApiKey() with another value or passing the
  10. alternative kay as argument of the various Stripe statics methods.
  11. See https://drupal.org/node/1342238 for more information.
  12. The module define a new Form API element type to input a Stripe token. This form
  13. element will be rendered as a field set containing the elements required to
  14. collect the information needed to create a token. On submit, the information
  15. will used to created a new token which will be send to the server. AJAX form
  16. submission is supported too. A failed token creation will prevent a normal form
  17. submission but not an AJAX submission.
  18. This input form element support the following properties:
  19. - #cardholder_name: Can either be a boolean or an array. If TRUE, the field set
  20. will include an element to input the card holder's name. If an array is used,
  21. in must contains the identifier (ie. like the #parents property) of an
  22. existing form element to be used to input the card holder's name. In all
  23. other cases, the field set will not include a card holder's input element.
  24. - #address: Can either be a boolean or an array. If TRUE, the field set
  25. will include elements to input the card holder's address. If an array is
  26. used, in must contains the identifier (ie. like the #parents property) of an
  27. existing form container with the input elements to use for the the card
  28. holder's address. In all other cases, the field set will not include card
  29. holder's address input element.
  30. - #cvc: If TRUE, the field set will include a CVC input element.
  31. - #publishable_key: The publishable key to use to create the token. If empty,
  32. the currently active site-wide publishable key will be used.
  33. The address field set uses a structure similar the one provided by the Address
  34. Field module (https://drupal.org/project/addressfield):
  35. - 'thoroughfare' as 'address_line1'
  36. - 'premise' as 'address_line2'
  37. - 'locality' as 'address_city'
  38. - 'administrative_area' as 'address_state'
  39. - 'postal_code' as 'address_zip'
  40. - 'country' as 'address_country
  41. CONFIGURATION
  42. -------------
  43. The Stripe module store site-wide API keys in 4 configuration variables:
  44. 'stripe_test_secret', 'stripe_test_publishable', 'stripe_live_secret' and
  45. 'stripe_publishable_secret'. A fifth variable is used to configure the active
  46. environment: 'stripe_key_status'. Its value should be one of 'test' or 'live'.
  47. The stripe_get_key() function is the recommended way to retrieve the value of
  48. these variables.