• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Getting custom user field value through paypal via account upgrade?

lasertits

Active member
#1
I noticed this in the account_upgrade template, which appears to take care of sending Paypal the user's username and what account upgrade they bought:

<input type="hidden" name="item_name" value="{xen:phrase account_upgrade}: {$upgrade.title} ({$visitor.username})" />

Ex:


Would it be possible to include another hidden custom input, whose value is a custom user field value?

Would it be as easy as duplicating that input and changing the value? Or do I need to edit some php code elsewhere too, perhaps in the payment callback?

I've setup my account upgrades to where people can't purchase unless they have their Steam ID tied to their account. Because of this I was hoping I could also get their Steam ID sent through the paypal payment, and it would show up in Paypal and the email notifications I receive about new upgrades, as seen in the screenshot above which currently only displays the account upgrade name, and their username.

If anyone has any idea on if this is possible and how I might go about it I'd appreciate it immensely. Thanks
 
S

Syndol

Guest
#2
https://cms.paypal.com/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_formbasics
Record Keeping with Passthrough Variables
Some variables are exclusively for your own use, such as order management. PayPal returns the values that you send through Instant Payment Notification exactly as you sent them. For this reason, they are called passthrough variables. Their values are not recorded or used by PayPal.

The following are passthrough variables:

custom
item_number or item_number_ x
invoice
And used as follows (max 127 characters long):

<input type="hidden" name="item_number" value="" />
 

lasertits

Active member
#3
haha, you again? Top of the mornin' to ya David, you insanely helpful ******* you. :p

Tried this just for testing:
Code:
<input type="hidden" name="item_number" value="{xen:phrase steam}: {$visitor.username}" />
Threw it in this snippet:
Code:
<input type="hidden" name="item_name" value="{xen:phrase account_upgrade}: {$upgrade.title} ({$visitor.username})" />
<input type="hidden" name="item_number" value="{xen:phrase steam}: {$visitor.username}" />
<input type="hidden" name="quantity" value="1" />
Did a test purchase but the data isn't showing anywhere. Not in paypal or in the emails. Not sure what I'm missing here or what else needs to happen to make it send the info through. Going to continue to look into it but figured I'd post just in case I come up short. Thanks!
 
S

Syndol

Guest
#4
Well I'm not sure at what point you want to retrieve that variable but if you can/should be able to fetch it from within library/UserUpgradeProcessor/PayPal.php
in function processTransaction() inside case 'subscr_payment':
add
$myVar = $this->_input->filterSingle('item_number' => XenForo_Input::STRING);
 

lasertits

Active member
#5
Hmm... short of that, do you think just appending the Steam ID to the end of the current "item_name" value would work?
Code:
<input type="hidden" name="item_name" value="{xen:phrase account_upgrade}: {$upgrade.title} ({$visitor.username})" />
So this would become..
Code:
<input type="hidden" name="item_name" value="{xen:phrase account_upgrade}: {$upgrade.title} ({$visitor.username} / {$SteamIDhere})" />
Presuming that works, I need to just figure out what $SteamIDhere should be... {$user.customFields.Steam} ?

Seems like this would be the way to go, would save me from having to edit any PHP files perhaps.

Found this chunk in member_view:

<xen:if is="{$customFieldsGrouped.contact}">
<xen:foreach loop="$customFieldsGrouped.contact" value="$field">
<xen:include template="custom_field_view" />
</xen:foreach>
</xen:if>

custom_field_view:

<xen:if hascontent="true">
<dl>
<dt>{$field.title}:</dt>
<dd><xen:contentcheck>
<xen:if is="is_array({$field.fieldValueHtml})">
<ul>
<xen:foreach loop="$field.fieldValueHtml" value="$_fieldValueHtml">
<li>{xen:raw $_fieldValueHtml}</li>
</xen:foreach>
</ul>
<xen:else />
{xen:raw $field.fieldValueHtml}
</xen:if>
</xen:contentcheck></dd>
</dl>
</xen:if>

So this is what takes care of displaying custom fields in member profiles, but I'm not sure how I'd get the Steam ID value only into the account_upgrades template for paypal, or if I'm even looking in the right place for example code that already spits out the Steam ID value.