UPDATES EasyBlog 6.0.11 Released! Update to the latest version now!

Helpdesk

Your Time
Our Time
Response Time
24 — 48 hours
We strive to provide the fastest ever response possible. However, we are not super beings.

Allow at least 24 — 48 hours
  Support is offline
It is currently off working hours and most of us aren't around

Rest assured that we will get back to you as soon as the day starts tomorrow!
It is currently a public holiday for us from where we are at.

There may be a delay in our responses but rest assured that we will be back at full speed when we are back to the office.
  Support is offline

Payplans API still working?

Jason McMahon · ·
11:53 PM Wednesday, 29 June 2022
Normal
On my client old site.. soon. to be retetiured were are using the PayPLans API to create 'child accounts'

Basically, when someone subscribes to a 'team membership' field appear in their joomlas profile to list email, and name of teanm members. Wen they save their account a plugin fires the following code snippet which

1) creates the child account
2) uses the payplans API to assign them the child account
3) Creates the invoice, transaction and activates the account.

It works nicely.. however this was Version 3. I am concerned that you no longer have API docs and I will have this functionality removed which will be a MASSIVE show stopper

Here is the code with PayPlans old API calls which I HOPE will still work.. if you could confirm this is the case. Yiour code starts about half way down. Will these API calls still work?


if ($data['team_member_name_'.$x] && $data['team_member_id_'.$x] < 1) {
$model = new UsersModelRegistration();
$type = 0;
$username = $data['team_member_email_' . $x];
$password = 'abcd1234';
$name = $data['team_member_name_' . $x];
$email = $data['team_member_email_' . $x];
$sendEmail = 0;
$activation = 0;

$userdata = array('username' => $username,
'name' => $name,
'email1' => $email,
'password1' => $password, // First password field
'password2' => $password, // Confirm password field
'sendEmail' => $sendEmail,
'activation' => $activation,
'block' => "0",
'groups' => array("2", "19"));

$response = $model->register($userdata);

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id');
$query->from($db->quoteName('#__users'));
$query->where($db->quoteName('username')." = ".$db->quote($email));

// Reset the query using our newly populated query object.
$db->setQuery($query);
$newId = $db->loadResult();

$data['team_member_id_'. $x] = $newId;

$plan = PayplansPlan::getInstance(10);
$order = $plan->subscribe($newId)
->save();

$invoice = $order->createInvoice();

//apply 100% discount
$modifier = PayplansModifier::getInstance();
$modifier->set('message', 'Free team membership for corporate team member')
->set('invoice_id', $invoice->getId())
->set('user_id', $invoice->getBuyer())
->set('type', 'assign_plan')
->set('amount', -100) // 100 percent Discount, discount must be negative
->set('percentage', true)
->set('frequency', PayplansModifier::FREQUENCY_ONE_TIME)
->set('serial', PayplansModifier::FIXED_DISCOUNT)
->save();

$invoice->refresh()->save();

// create a transaction with 0 amount
$transaction = PayplansTransaction::getInstance();
$transaction->set('user_id', $invoice->getBuyer())
->set('invoice_id', $invoice->getId())
->set('message', 'COM_PAYPLANS_TRANSACTION_CREATED_FOR_ASSIGN_PLAN_TO_USER')
->save();
}
The replies under this section are restricted to logged in users or users with an active subscription with us