Home » Support » Help Articles » Integrating Chargify Payment Gateway in your PHP Application

Integrating Chargify Payment Gateway in your PHP Application

Back to Help Articles Home


This guide will walk you through integrating online billing software Chargify in your PHP application.

  1. Create a test account with Chargify at http://chargify.com.
  2. Log in to your account by using your 'Username' and 'Password'.
  3. Create a site by clicking the 'Create a Site button' as shown below.
  4. Figure One

    Note: Sites are containers for your products, subscriptions and customers. When a new site is created it is not shown to the customers. Your sub domain identifies the site uniquely in Chargify.

  5. Fill in the necessary details in the 'Create New Site' page as shown below and click the 'Create Site' button.
  6. Figure Two

    Note: Please find the detailed explanation of different fields in the page below.
    a. Site Name: It is not seen by your customers, hence you can use a descriptive name of yourself.
    b. Subdomain: The subdomain you select may be seen by your customers (i.e in the hosted payment pages). So use something that identifies your company.
    c. Test Mode: For sites in test mode, only development or test gateways (i.e. an Authorize.Net or the Chargify Test Gateway) are supported. Live gateways are supported only in live sites.
    d. Date/Time Format: Selecting date/time formats will change the way dates and times are shown throughout Chargify, including statements, invoices and Admin UI.

  7. For ex. if you create a new site called 'test' and a subdomain 'testbk' as shown below, the url of your sub domain will be 'https://testbk.chargify.com/'
  8. Once your new site is created, you shall be automatically redirected to the dashboard of your site. From there click on the 'Settings' menu as shown below.
  9. Figure Three

  10. From the 'Settings' menu select the 'Public Page Default Settings' and the following screen shall appear as shown below.
  11. Figure Four

  12. Fill in the necessary details in the 'Public Page Default Settings' page and click the 'Save Public Page Default Settings' button.
  13. Note:Please find the detailed explanation of different fields in the page below.
    a. Page Title: The title will be displayed at the top of the page and in the title of the browser window.
    b. Logo: The logo will be resized to a maximum width of 650px x 100px. Only JPEG, GIF, PNG file formats are accepted.
    c. Home Link URL: Your logo or company name will link to this URL.
    d. Privacy Policy URL: A link to the Privacy Policy will appear in the footer.
    e. Terms and Conditions: If a link to terms is a provided the customer will be required to agree to the terms before subscribing. A link to the terms will also appear in the footer.
    f. Custom CSS: Custom styles will be included at the top of the page within a style tag.
    g. Enable Security Question (CAPTCHA): If enabled, a reCAPTCHA style input form to your page will be provided.
    h. Accepted card types to display: Select which card logos will appear on the form.
    i. Enable SSL Certificate Badge: If checked, a SSL Badge will be shown on your Public Pages.
    j. Enable 'Powered By Chargify' Badge: If checked, a logo showing that Chargify powers your payments will be shown on your Public Pages.

  14. Then on the dashboard screen of your site click on the 'Setup' menu. Upon doing so you shall land on a page similar to the one as shown below, asking you to create a 'Product Family'.
  15. Figure Five

    Note: A 'Product Family', is a group under which similar products are organized. Product families are typically brands or categories. There is no limit on the number of product families you can create.

  16. To create a new product family click the Create a New Product Family button and you shall land on a page as shown below.
  17. Figure Six

  18. Enter the 'Name' and the 'Description' as shown above. For ex. if you create a Product Family called 'test' and click the 'Create Product Family' button.
  19. Upon doing so you will land on a page that is similar to the one as shown below. Now you need to create a Product by clicking the Add New product button.
  20. Note: Products define 'how much' and 'how often' you will bill your subscribers.

    Figure Seven

  21. Fill in the necessary details about the product as shown below and click the 'Create Product' button.

    Figure Eight

  22. Upon doing so you will land on a page that is similar to the one as shown below. Next step is to set up the Billing and your return URL..
  23. Figure Nine

  24. To set-up the 'Billing & Return URL',click on the 'Edit' button besides the 'Product' created by you. This will take you to the 'Edit Product' screen and below you can find more options related to 'Product Price' and 'Billing' and to set-up the 'Return URL'. Make the changes as per your requirement and click the 'Save Changes' button to save your changes.
  25. Next you need to create a Component'.
  26. Note: Components are the add-ons and features customers can add to their subscriptions. Components can be of three types:
    a. Metered Component: Allows you to track usage in a metered manner i.e minutes used per month.
    b. Quantity Based Component: Allows you to charge per unit of something.
    c. On/Off Component: Allows you to add components that can be toggled either on or off.

  27. Let's say we select and create a 'Quantity Based Component'. Fill in the necessary details as per your requirement.
  28. Now you get two separate ids both for the 'Products' and for 'Components'.
  29. Now in your application after registration of new user redirect the user to your subdomain in Chargify with the following code as shown below.

  30. $sPath = 'https://testbk.chargify.com/subscribe/bmyfkbg54xzt/books?components[][component_id]=136021&components[][allocated_quantity]='.$_POST['selUserNum'].'&first_name='.$_POST['txtFirstName'].'&last_name='.$_POST['txtLastName'].'&email='.$_POST['txtEmail'].'&reference='.$iUserId;
    header("Location: $sPath");
    exit();
    ?>

  31. The first part of the redirection URL "https://testbk.chargify.com/subscribe/bmyfkbg54xzt/books" is obtained from the 'View this product's Public Signup Pages' in the 'Products' menu.
  32. The next part contains the information of the 'Component': components[][component_id]=136021&components[][allocated_quantity]='.$_POST['selUserNum']. This part contains the component id and total number of component required by user.
  33. Last part contains the information of user. Information include 'First Name', 'Last Name', 'Email' and a 'Unique Reference ID'.
  34. The application will then redirect the user to the credit card page for payment.
  35. In test mode enter '1' in credit card number to get successful transaction, '2' for unsuccessful transaction. If transaction is completed successfully user will be redirected to the Return URL as specified in the product menu.

You are done with.



Updated on Nov 11, 2015

The techReview is an online magazine by Batoi and publishes articles on current trends in technologies across different industry verticals and areas of research. The objective of the online magazine to provide an insight into cutting-edge technologies in their evolution from labs to market.

Visit techReview


English - IN (USD)
New Users? Signup.     Existing Users? Login.