Skip to content

Commit

Permalink
feat: remove lingering green party code, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimds committed Nov 11, 2024
1 parent b56e971 commit 1d3dd6f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
20 changes: 20 additions & 0 deletions packages/join-block/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 [[email protected]](mailto:[email protected]).

== Changelog ==

= 1.0 =
Expand Down
3 changes: 2 additions & 1 deletion packages/join-block/src/Services/JoinService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
];

Expand Down
25 changes: 1 addition & 24 deletions packages/join-flow/src/services/rest-resource.service.ts
Original file line number Diff line number Diff line change
@@ -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 = <Params, Result = {}>(resource: string) => {
return async (data: Params): Promise<Result> => {
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}`, {
Expand Down

0 comments on commit 1d3dd6f

Please sign in to comment.