diff --git a/packages/join-block/readme.txt b/packages/join-block/readme.txt index 32a623f..e605749 100644 --- a/packages/join-block/readme.txt +++ b/packages/join-block/readme.txt @@ -30,6 +30,26 @@ Features: 2. Mailchimp 3. Action Network +== ChargeBee setup == + +To use ChargeBee, you must configure the payment plan names in the Join Flow settings +to match the price IDs in the ChargeBee back-end. + +Currently, this requires logging in to the ChargeBee dashboard, creating a +subscription, and setting a price for the desired currency. The price details +for the selected currency will have an ID. Copy and paste this ID into the +name of the membership plan in the Join Flow backend. + +To support an additional donation in ChargeBee, create two more products: +- an addon called "Additional Donation", with a price in the desired + currency called "additional_donation_monthly". +- a charge called "Additional Donation", with a price in the desired + currency called "additional_donation_single". + +== Contact Us == + +Need help? Contact us at [hello@commonknowledge.coop](mailto:hello@commonknowledge.coop). + == Changelog == = 1.0 = diff --git a/packages/join-block/src/Services/JoinService.php b/packages/join-block/src/Services/JoinService.php index 0ae60f6..7929951 100644 --- a/packages/join-block/src/Services/JoinService.php +++ b/packages/join-block/src/Services/JoinService.php @@ -508,7 +508,8 @@ private static function handleChargebeeSubscription($data, $customer) $planId = sanitize_title($data['membership']); $chargebeeSubscriptionPayload["subscription_items"] = [ [ - "item_price_id" => $planId + "item_price_id" => $planId, + "unit_price" => (int)$data['membershipPlan']['amount'] * 100 ] ]; diff --git a/packages/join-flow/src/services/rest-resource.service.ts b/packages/join-flow/src/services/rest-resource.service.ts index 7ce0f79..d1221e7 100644 --- a/packages/join-flow/src/services/rest-resource.service.ts +++ b/packages/join-flow/src/services/rest-resource.service.ts @@ -1,34 +1,11 @@ import { get as getEnv } from '../env'; -type membershipToChargebeePlanMap = { - [key: string]: string; -}; - -/* - All membership types map exactly to one Chargebee plan, except for suggested. - - Suggested is a combination of a membership_monthly_individual plan and a £7 donation. - - See packages/join-block/lib/services/join_service.php for details. -*/ -const membershipToChargebeePlanMap: membershipToChargebeePlanMap = { - suggested: "suggested", - standard: "membership_monthly_individual", - lowWaged: "membership_annual_individual_low_waged", - student: "membership_annual_student", - unwaged: "membership_annual_unwaged" -}; - -function membershipToPlan(membership: string): string { - return membershipToChargebeePlanMap[membership]; -} - export const usePostResource = (resource: string) => { return async (data: Params): Promise => { const endpoint = "join/v1" + resource; // @ts-ignore - data.planId = membershipToPlan(data.membership); + data.planId = data.membership; const baseUrl = getEnv('WP_REST_API').replace(/\/$/, ''); // trim trailing slash const res = await fetch(`${baseUrl}/${endpoint}`, {