Payments using Paypal System in OCS

Hi,

I am using the PayPal payment system for a Open Conference Systems installation in Spanish.
When an user makes a payment, neither the title of the conference nor the registration type are written down in the Paypal invoice. It’s only there “Register to participate in {$conferenceTitle}” and the amount.
Is there any way I can change the {$conferenceTitle} into the actual name of the conference and make clear in the invoice the registration type?

Thank you very much.

Best regards

Hi @vmarinj,

The information that OCS provides to PayPal, which PayPal can then use to create a receipt, is defined in plugins/paymethod/paypal/PayPalPlugin.inc.php in the displayPaymentForm function. Primarily you’re interested in item_name, which comes from the queued payment, and is in turn implemented in classes/payment/ocs/OCSQueuedPayment.inc.php in the getDescription function. You can adjust the item description there. If you’d like more information, let me know where you’re stuck.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Thank you very much for your answer.
I understand that I should change the item_name in the PayPalPlugin.inc.php but how can I know which is the function or string to reference the type of registration and the title of the conference? Can I find it in some other file?

Regards

Hi @vmarinj,

Actually, the payment description comes from OCSQueuedPayment; did you look at the second function described above?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

Thank you again for your answer.
I was looking at the OCSQueuedPayment, but I think it should be all fine according to the data included in the getDescription function…I do not know why it is not being shown in the Paypal invoice.

I paste here what it is there so maybe you detect where it is the problem…

function getDescription() {
switch ($this->type) {
case QUEUED_PAYMENT_TYPE_REGISTRATION:
$registrationDao =& DAORegistry::getDAO(‘RegistrationDAO’);
$registration =& $registrationDao->getRegistration($this->getAssocId());

  		$registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO');
  		$registrationType =& $registrationTypeDao->getRegistrationType(
  			$registration?$registration->getTypeId():0
  		);
  		$registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
  		$registrationOptions =& $registrationOptionDao->getRegistrationOptions($this->getAssocId());
  		$options = '';
  		foreach ($registrationOptions as $optionId) {
  			$options .= ';' . $registrationOptionDao->getRegistrationOptionName($optionId);				
  		}
  		$schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
  		$schedConf =& $schedConfDao->getSchedConf(
  			$registrationType?$registrationType->getSchedConfId():0
  		);
  		return __('payment.type.conferenceRegistration', array(
  			'schedConfTitle' => ($schedConf?$schedConf->getFullTitle():__('common.none')),
  			'registrationTypeName' => ($registrationType?$registrationType->getRegistrationTypeName():__('common.none')),
  		)) . $options;
  }

}

Thanks,
Victoria

Hi @vmarinj,

The “Register to participate in…” text you quoted above appears to be a customization; can you clarify where you made that change, so I’m sure we’re referring to the same confirmation message?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

I did not customized that text… I only can imagine that maybe has something to do with using the Spanish template instead of the English one?

Thanks,
Victoria

Hi @vmarinj,

Ah – what’s the exact Spanish text you’re seeing?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

It’s:

Registro para participar en {$conferenceTitle}

Thanks.

Hi @vmarinj,

Hmm, is that the exact text? Searching the OCS codebase for that text doesn’t show anything.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
Yes, it is.
When I go as author to pay the specific registration fee of the conference using Paypal (after pressing the button “Inscripción”-Register) that message appears in the webpage, which is the same that it is written down afterwards in the Paypal invoice. I attach a screenshot in case it is useful to find the file where I should change the text:

Thank you very much,
Victoria

Any more ideas?
I have looked at the locale .xml file in the en_US and es_ES folders and I did not find out yet where I should change this…

Thanks

Hi @vmarinj,

What is the locale key in locale/es_ES/locale.xml (I’m assuming you’re using this, not e.g. Argentinian Spanish) corresponding to the payment.type.conferenceRegistration locale key?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
This one was not in the locale.xml file on es_ES folder at first but I added it some days ago.
Now it’s:

Registro al congreso; {$schedConfTitle}; {$registrationTypeName}

Thanks.

Hi @vmarinj,

Ah, that’s why I wasn’t finding it in the stock OCS codebase. The getDescription function in classes/payment/OCSQueuedPayment.inc.php should contain…

return __('payment.type.conferenceRegistration', array(
    'schedConfTitle' => ($schedConf?$schedConf->getFullTitle():__('common.none')),
    'registrationTypeName' => ($registrationType?$registrationType->getRegistrationTypeName():__('common.none')),
)) . $options;

…which does define a variable called schedConfTitle. From your description, it sounds like `schedConfTitle is not getting properly replaced. Does your code match this?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
Yes, in the getDescription function in classes/payment/OCS/OCSQueuedPayment.inc.php the final part of the code matches that text:

function getDescription() {
switch ($this->type) {
case QUEUED_PAYMENT_TYPE_REGISTRATION:
$registrationDao =& DAORegistry::getDAO(‘RegistrationDAO’);
$registration =& $registrationDao->getRegistration($this->getAssocId());

  		$registrationTypeDao =& DAORegistry::getDAO('RegistrationTypeDAO');
  		$registrationType =& $registrationTypeDao->getRegistrationType(
  			$registration?$registration->getTypeId():0
  		);
  		$registrationOptionDao =& DAORegistry::getDAO('RegistrationOptionDAO');
  		$registrationOptions =& $registrationOptionDao->getRegistrationOptions($this->getAssocId());
  		$options = '';
  		foreach ($registrationOptions as $optionId) {
  			$options .= ';' . $registrationOptionDao->getRegistrationOptionName($optionId);				
  		}
  		$schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
  		$schedConf =& $schedConfDao->getSchedConf(
  			$registrationType?$registrationType->getSchedConfId():0
  		);
  		return __('payment.type.conferenceRegistration', array(
  			'schedConfTitle' => ($schedConf?$schedConf->getFullTitle():__('common.none')),
  			'registrationTypeName' => ($registrationType?$registrationType->getRegistrationTypeName():__('common.none')),
  		)) . $options;

Thanks

Hi @vmarinj,

Your screenshot references $conferenceTitle while the code talks about $schedConfTitle; did something change here?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
When I changed $schedConfTitle in the OCSQueuedPayment.inc.php file to $conferenceTitle happened a curious thing, it turned the {$conferenceTitle} of the screenshot into “ninguno” (none).
Here it is the code with the change and the new screenshot:

return __('payment.type.conferenceRegistration', array(
					'conferenceTitle' => ($conferenceTitle?$conferenceTitle->getFullTitle():__('common.none')),
					'registrationTypeName' => ($registrationType?$registrationType->getRegistrationTypeName():__('common.none')),
				)) . $options;

Thanks.

Hi @vmarinj,

There’s a difference here between your code and the stock code. Notice that your code contains…

 $conferenceTitle?$conferenceTitle->getFullTitle():__('common.none')

…but the stock version is…

 $schedConf?$schedConf->getFullTitle():__('common.none')

Because the $conferenceTitle PHP variable doesn’t exist, it’s defaulting to __('common.none'), which is “ninguno” in Spanish.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

I have now changed the code but it stills shows the same as the first screenshot I included in a previous post (conferenceTitle}. Now it is:

return (‘payment.type.conferenceRegistration’, array(
‘schedConf’ => ($schedConf?$schedConf->getFullTitle():
(‘common.none’)),
‘registrationType’ => ($registrationType?$registrationType->getRegistrationTypeName():__(‘common.none’)),
)) . $options;

I am lost, no idea where to find the PHP original variables or where to change the code so it shows the actual name of the conference…

Thanks