The Chargify Webhook integration sends any events related to Charges or Subscriptions. PartnerStack can then keep your customers in sync with Chargify, however this integration requires customer signup to be recorded using PartnerStackJS.
Get your Webhook URL
Navigate to Settings
> Integrations
> Webhooks
and select Chargify
from the Supported integrations.
Click the copy
button to copy the URL to your clipboard.
Create the Webhook on the Chargify Dashboard
Go to Settings
in the topbar, then Webhooks
on the left pannel. Click the enable webhooks
checkbox then the Add New Webhook
button. Paste the chargify webhook URL into the wehbook endpoints input field, then select Payment Success
, Signup Success
, Subscription State Change
, Component Allocation Change
, and Refund Success
from the webhook subscriptions list.
Set customer key as customer reference
Whenever you interact with Chargify to create a customer you need to let PartnerStack know which customer you are referring to.
To do this, include customer_key
that was used on PartnerStackJS as the customer reference
in Chargify. Make sure that the reference you use with Charigify has been used with PartnerStackJS when creating the signup as growsumo.data.customer_key
.
In your code, it should look something like below:
ADD `reference` to `customer_attributes`
MAKE SURE it matches the `customer_key` used with GrowSumoJS
# import requests
# import json
# import base64
# headers = {
# 'Authorization': 'Basic {}'.format(base64.b64encode('chargify_api_key')),
# 'Content-Type': 'application/json'
# }
# request_url = 'https://<your_subdomain>.chargify.com/subscriptions.json'
# subscription = {
# "subscription": {
# "product_handle": "pro-plan",
# "customer_attributes": {
# "first_name": "John",
# "last_name": "Doe",
# "email": "john@test.com",
"reference": <YOUR_CUSTOMER_KEY>
# },
# "credit_card_attributes": {
# "full_number": "1",
# "expiration_month": "10",
# "expiration_year": "2020"
# },
# }
# }
# create_subscription = requests.post(request_url, headers=headers, data=json.dumps(subscription))
# example for https://github.com/chargify/chargify_api_ares
ADD `reference` to `customer_attributes`
MAKE SURE it matches the `customer_key` used with GrowSumoJS
#require 'chargify_api_ares'
#Chargify.configure do |c|
# c.api_key = "chargify_api_key"
# c.subdomain = "yoursubdomain.chargify.com"
#end
# Chargify::Subscription.create(
# :customer_attributes => {
# :first_name => "John",
# :last_name => "Doe",
# :email => 'john@test.com',
:reference => <YOUR_CUSTOMER_KEY>
# }
# :product_handle => 'test',
# payment profile attributes
# :credit_card_attributes => {
# :first_name => "John",
# :last_name => "Doe",
# :expiration_month => 1,
# :expiration_year => 2010,
# :full_number => "1234-1234-1234-1234"
# }
# )
<!-- https://github.com/chargely/chargify-sdk-php -->
ADD `reference` to `customer_attributes`
MAKE SURE it matches the `customer_key` used with GrowSumoJS
<?php
// use Crucial\Service\Chargify;
//
// $chargify = new Chargify([
// 'hostname' => 'yoursubdomain.chargify.com',
// 'api_key' => '{{API_KEY}}',
// 'shared_key' => '{{SHARED_KEY}}'
// ]);
// $subscription = $chargify->subscription()
// ->setProductHandle('my_product')
// ->setCustomerAttributes([
// 'first_name' => '{{John}}',
// 'last_name' => '{{Doe}}',
// 'email' => '{{john@test.com}}',
'reference' => '{{<YOUR_CUSTOMER_KEY>}}',
// ])
// payment profile attributes
// ->setPaymentProfileAttributes([
// 'first_name' => '{{FIRST_NAME}}',
// 'last_name' => '{{LAST_NAME}}',
// 'full_number' => '{{CC_NUMBER}}',
// 'expiration_month' => '{{EXPIRY_MONTH}}',
// 'expiration_year' => '{{EXPIRY_YEAR}}',
// 'cvv' => '{{CVV}}',
// 'billing_address' => '{{ADDRESS}}',
// 'billing_city' => '{{CITY}}',
// 'billing_state' => '{{STATE}}',
// 'billing_zip' => '{{ZIP}}',
// 'billing_country' => '{{COUNTRY}}'
// ])
// -> create();
?>
// example for https://github.com/natevw/node-chargify
ADD `reference` to `customer_attributes`
MAKE SURE it matches the `customer_key` used with GrowSumoJS
// var chargify = require('chargify')
// var chargify_site = chargify('chargify_subdomain', 'chargify_api_key')
//
//
// chargify_site.post({
// uri: 'subscriptions.json',
// json: {
// "subscription": {
// "product_handle": "basic",
"customer_reference": <YOUR_CUSTOMER_KEY>,
// "credit_card_attributes": {
// "full_number": "1",
// "expiration_month": "10",
// "expiration_year": "2020"
// }
// }
// }, function (err, res, body) {
// if (err) throw err;
// console.log(res.statusCode);
// console.log(body);
// }
// });
Setup Subscription Plans
Now is the time to set your Chargify product plans on PartnerStack.
You need to make sure that the plan key on PartnerStack matches the product id on Chargify. You can find your plans on Chargify by going to your dashboard and changing the path to https://<yoursubdomain>.chargify.com/products
.
Create all your plans in PartnerStack and you are good to go!