Skip to Content Skip to Menu

[SOLVED] PAP integration long after first registration

  • activha
  • activha
  • OFFLINE
  • Posts: 2327
  • Thanks: 117
  • Karma: 13
10 years 2 weeks ago #251468 by activha
Replied by activha on topic PAP integration long after first registration
I am coming back on this subject:

Would you think that this code would work both for non registered user and registered ?
<code>
public function onCPayBeforeStorePaymentBasketUpdated( $paymentBasket, /** @noinspection PhpUnusedParameterInspection */ $paymentItems, /** @noinspection PhpUnusedParameterInspection */ $paymentTotalizers ) {
$integrationParams =& $paymentBasket->getParams( 'integrations' );
if ('[post_cb_codeparrainpartenaire]') {
cbimport( 'cb.session' );
CBCookie::setcookie( 'PAPVisitorId', '[post_cb_codeparrainpartenaire]' );
}
$user = CBuser::getMyUserDataInstance();
if ( $user->get( 'cb_codeparrainpartenaire' ) ) {
$affiliateID = $user->get( 'cb_codeparrainpartenaire' );
CBCookie::setcookie( 'PAPVisitorId', '[cb_codeparrainpartenaire]' );
} else {
$affiliateID = stripslashes( cbGetParam( $_COOKIE, 'PAPVisitorId', null ) );
}
// fins
//$affiliateID = stripslashes( cbGetParam( $_COOKIE, 'PAPVisitorId', null ) );

if ( $affiliateID ) {
$integrationParams->set( 'postafpro_affiliateid', $affiliateID );
}

$paymentBasket->storeParams( 'integrations' );
}
</code>

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48482
  • Thanks: 8283
  • Karma: 1443
10 years 2 weeks ago #251473 by krileon
Replied by krileon on topic PAP integration long after first registration
There's no guarantee a user will exist for onCPayBeforeStorePaymentBasketUpdated. Sorry, don't understand what you're trying to do. Act on the onCPayAfterPaymentStatusUpdateEvent trigger and you'll have a user object, but you're going to have to develop a plugin for the behavior you're wanting as the postafpro_affiliateid is stored in the integration params, which you can't get from CB Auto Actions.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • activha
  • activha
  • OFFLINE
  • Posts: 2327
  • Thanks: 117
  • Karma: 13
10 years 2 weeks ago #251496 by activha
Replied by activha on topic PAP integration long after first registration
In fact we use PAP heavily on all website and related websites and profil pages of our users

When a new user tries to register to our website, a PAP code could have already be inserted in the PAP cookie, but if the user has a known other affiliate code, he has the ability to insert it in a field cb_codeparrainpartenaire and this insertion should overrite PAP cookie and be used for registration and all sales process.

This works well for registration and new users are correctly registered as sub affiliates in PAP if they manually enter the cb_codeparrainpartenaire code.

We just make a test to check if cb_codeparrainpartenaire exists and in this case we overwrite the cb_parrain code retrieved from PAP cookie when registering the user both to joomla/CB and PAP.

But this does not work for PAP integration when payment is made for a CBSUBS plan and this is why we tried to modify it this way, without success until now.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48482
  • Thanks: 8283
  • Karma: 1443
10 years 1 week ago #251602 by krileon
Replied by krileon on topic PAP integration long after first registration
We store the affiliate id with the basket, because the IPN that pays the basket could come hours later, days even, which would cause problems as the user won't exist. If you used onCPayAfterPaymentStatusUpdateEvent then it's not an issue as you've access to the user object. You'd basically modify the plugins usage of onCPayAfterPaymentStatusUpdateEvent and check if the have that field completed. Example as follows.

IN: components/com_comprofiler/plugin/user/plug_cbpaidsubscriptions/plugin/cbsubspostafpro/cbsubs.postafpro.php
ON: Line 90
FROM:
Code:
$affiliateID = $integrationParams->get( 'postafpro_affiliateid', null );
TO:
Code:
if ( $user->get( 'FIELD_NAME' ) ) { $affiliateID = $user->get( 'FIELD_NAME' ); } else { $affiliateID = $integrationParams->get( 'postafpro_affiliateid', null ); }

You can replace FIELD_NAME with whatever field you'd like to use. It'll check if it has a value and if it does it'll use it as the affiliate id otherwise it'll fallback to the basket stored affiliate id, which came from the cookie. Since this is done when the basket is actually paid and the subscription is becoming active it'd be completely reliable where as onCPayBeforeStorePaymentBasketUpdated may or may not have an empty user object.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum