1. 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?

Discussion in 'XenForo Development Discussions' started by lasertits, Jan 12, 2012.

  1. lasertits

    lasertits Active Member

    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})" />


    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
  2. Syndol

    Syndol Guest

    And used as follows (max 127 characters long):

    <input type="hidden" name="item_number" value="" />
    lasertits likes this.
  3. lasertits

    lasertits Active Member

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

    Tried this just for testing:
    <input type="hidden" name="item_number" value="{xen:phrase steam}: {$visitor.username}" />
    Threw it in this snippet:
    <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!
  4. Syndol

    Syndol Guest

    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':
    $myVar = $this->_input->filterSingle('item_number' => XenForo_Input::STRING);
  5. lasertits

    lasertits Active Member

    Hmm... short of that, do you think just appending the Steam ID to the end of the current "item_name" value would work?
    <input type="hidden" name="item_name" value="{xen:phrase account_upgrade}: {$upgrade.title} ({$visitor.username})" />
    So this would become..
    <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:if hascontent="true">
    <xen:if is="is_array({$field.fieldValueHtml})">
    <xen:foreach loop="$field.fieldValueHtml" value="$_fieldValueHtml">
    <li>{xen:raw $_fieldValueHtml}</li>
    <xen:else />
    {xen:raw $field.fieldValueHtml}

    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.

  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yeah that should work. To reference the profile field you need to add this variable:

    lasertits likes this.
  7. lasertits

    lasertits Active Member

    Ah! I was using $user.customFields.Steam, didn't think to use $visitor - that worked thanks!

Share This Page