[TH] Credits [Deleted]

Because the User Upgrades system in XenForo isn't really an easy thing to change to use anything other than PayPal :p
Im wondering though if we might be able to use Paygates though.
I'd like to see an alert bubble on the Credits tab in admin panel when a withdrawal is pending, that'd be great. Also a field for user to input paypal address, right now we don't know who to pay.
Nice update btw.
Thanks a lot, Jake was just talking about this the other day. Its something we are debating creating as a separate add-on (free).
he withdrawal option is awesome, but have to make sure that i set the ratio correct and people aren't trying to take $1000 out of me!

suggestion - let admin set a minimum amount of points that user must have before they're able to withdrawal.
You get to approve them though. I think a minimum does make sense and a maximum as well, will add to feature list.
I have points and credits appearing on my site. How can I disable the points? I want to use only the AD Credits.
I think you'd want this add-on to remove trophies from being viewed: https://xenforo.com/community/resources/remove-trophy.2435
 
More wish list items:
  • Currency Conversion between Currencies as well as defining the value of conversion both up or down.

We decided against this short term just because there isn't a huge use for it. But its something we can do at some point if more people want it.
I too desperately want this. My use case is to have two separate currencies, one that can be bought and another that must be earned through community involvement, and have the community involvement one redeemable to the bought currency. This way the members feel they are being rewarded for their activity. The moment this is out I can additionally purchase and implement the Shop plugin, because I can't only offer a pay2win option.
 
I too desperately want this. My use case is to have two separate currencies, one that can be bought and another that must be earned through community involvement, and have the community involvement one redeemable to the bought currency. This way the members feel they are being rewarded for their activity. The moment this is out I can additionally purchase and implement the Shop plugin, because I can't only offer a pay2win option.
If I understand you this was why we built multiple currencies. This is built. There is no conversion only because you don't need to.

I can charge 5 dollars for star coins and let people earn moon points. Stars can only be purchased with cash. If you let people earn stars with a conversion then there is no difference other than denomination. Like the difference between a dime and a nickel. They are both the same currency.
 
If I understand you this was why we built multiple currencies. This is built. There is no conversion only because you don't need to.

I can charge 5 dollars for star coins and let people earn moon points. Stars can only be purchased with cash. If you let people earn stars with a conversion then there is no difference other than denomination. Like the difference between a dime and a nickel. They are both the same currency.
The difference is more emotional than technical. The act of converting or "redeeming" a currency that is bought (with money) using a currency that is earned (through time) is a rewarding experience. If we let them simply "earn" the buyable currency it would be too passive for them to ever notice.
 
class Audentio_Credit_Core_DataWriter_Transaction extends XenForo_DataWriter
Code:
protected function _preSave()
{
if ($this->get('credits') < 1)

Wouldn't it be more appropriate for that to be < 0, since one could very well want to send an amount between 0 and 1 via transfer/purchase/etc.?
 
Last edited:
I've played around a bit with the Credits and the Shop System and i've found a couple of bugs and also i've some wishes for the future! :)

- When creating a new "item" product and when i select upload image the error "product not found" appears after saving
- User1 buys a product / virtual gift. After buying he sends the gift to User2. The gift appears in his profile but User2 didn't get a notification about it (or it seems there is a new notification but it's empty). Also, it should appear in the transaction log of User1.
Btw.: It would be MUCH better, if i could send a gift straight from the shop to a user.
- If there is only 1 currency, please get rid of the Dropdown and just show the text instead, at least in the frontend
- Please make it possible that a usergroup upgrade will be recurring, so a user stays in the premium member group as long as he has the money for it (or until he cancels the subscription)

I guess that's it for the beginning. Looks really promising so far, i'm excited how it'll develop in the future! :) Keep up the good work
 
so users can withdrawal, but there's no place for them to withdrawal to?

i kinda assumed that the user put their paypal address in, and that's where we send to - no?

user should definitely have a spot for their paypal adddress, as that goes hand in hand with the withdrawal process.
 
Upon trying to use the Purchase system all my packages received the following error upon trying to follow the navigation to the Paypal portal:
f22737e4d7.png


Turns out the issue was due to float precision on the "amount" post parameter:
710e1f29f0.png


Found the problematic line in the adcredit_packages template:
a3554d421a.png


Fixed it by replacing it with:
Code:
<input type="hidden" name="amount" value="{xen:helper currency, $package.price, 0}" />

Hopefully this fix can be implemented (or improved on) for the official build. Would save me the hassle of having to modify it each upgrade. :p

---

Here's another revision I had to make for my use case.

class Audentio_Credit_Core_DataWriter_Transaction

Old:
Code:
  protected function _preSave()
   {
     if ($this->get('credits') < 1)
     {
       $this->error(new XenForo_Phrase('adcredit_invalid_amount'), 'amount');
     }
     $currencyModel = $this->getModelFromCache('Audentio_Credit_Core_Model_Currency');
     $currency = $currencyModel->getCurrencyById($this->get('currency_id'));
     $sender = $this->getOption('sender');
     if ($sender)
     {
       if ($this->get('credits') > $sender[$currency['currency_id']] && !$currency['allow_negative'])
       {
         $this->error(new XenForo_Phrase('adcredit_not_enough_X_you_need_Y',array('creditName' => $currency['name'], 'amount'=>Audentio_Credit_Core_Template_Helper_Credit::formatCredit($this->get('credits'), $this->get('currency_id')))), 'amount');
       }
     }
   }

New:
Code:
    protected function _preSave()
    {
        $currencyModel = $this->getModelFromCache('Audentio_Credit_Core_Model_Currency');
        $currency = $currencyModel->getCurrencyById($this->get('currency_id'));

        $min = 1 / pow(10, $currency['decimal_points']) - 1 / pow(10, $currency['decimal_points'] + 1);
        if ($this->get('credits') <= $min)
        {
            $this->error(new XenForo_Phrase('adcredit_invalid_amount'), 'amount');
        }

        $sender = $this->getOption('sender');
        if ($sender && $this->isInsert() && $this->get('credits') > $sender[$currency['currency_id']] && !$currency['allow_negative'])
        {
            $this->error(new XenForo_Phrase('adcredit_not_enough_X_you_need_Y',array('creditName' => $currency['name'], 'amount'=>Audentio_Credit_Core_Template_Helper_Credit::formatCredit($this->get('credits'), $this->get('currency_id')))), 'amount');
        }
    }

The first notable change are that it now supports transfers of the smallest precision allowed by the currency (as configured). Apologies for the second hacky part of calculating the min, but it was necessary because I believe there is some precision loss going through the AJAX layer and I'm sure you can come up with a more elegant fix. The second is the addition of "$this->isInsert()" condition to the insufficient funds error, because for my use, and presumably anyone building on top of this, there may be a need to edit transactions after it is created and that error state makes no sense then.

Lastly, please let me know if you would like me to continue posting my mods/thoughts/etc., PM you instead, or just leave you alone. Each dev has their own style and I'll respect it.

---

Edit:

More tweaks I made that I thought I should share. I really wanted to a display like this (yes I'm using the AD theme Intrepid; it's awesome :D)

ce283fd4c08606d841eb2327a2e94dbd.png


To achieve this I modified the beginning of template adcredit_navigation_visitor_tabs_end as such:

Code:
<li class="navTab credits Popup PopupControl PopupClosed {xen:if $adcredit_selectedTab, 'selected'}">
   <a href="{xen:link adcredits}" rel="Menu" class="navLink NoPopupGadget">
     {xen:if '{$xenOptions.adcreidt_visitorTabDisplayMethod} == 2 OR {$xenOptions.adcreidt_visitorTabDisplayMethod} == 1', '<i class="{$xenOptions.adcreidt_visitorTabIconClass}"></i> '}{xen:if '{$xenOptions.adcreidt_visitorTabDisplayMethod} == 0 OR {$xenOptions.adcreidt_visitorTabDisplayMethod} == 1', '{xen:phrase adcredit_wallet}'}
     <strong class="itemCount alert" id="PrimaryCurrency_Counter">
       <span class="Total">{xen:helper credit, '{$visitor.adcredit}', 'adcredit'}</span>
       <span class="arrow"></span>
     </strong>
   </a>

Obviously this is horrible since I hard-coded the currency_id, but I'm sure it can be improved on to provide such a display option out-of-box.

Edit x2:

Couple more notes.

1) I would like to have a space between the end of my currency and the suffix. I managed to do this by manually modifying the currency table, but trying to do some through admincp trims the leading space.
2) I want only one currency withdrawable and the other not. I tried to turn off "Can Withdraw" through the Currency page in admincp:
b9fe8daf988a21c5da46004029559251.png

However, the currency still shows up in the Withdraw template and refreshing the admincp page shows that the option has been checked again.
0940e8aad25dea5e8ba3e368b3eb5580.png

I'm assuming this is undesired behavior. I also didn't notice a can_withdraw flag in the MySQL table, so I'm not sure how the setting is retained.

Edit x3:

Fixed* #2 above by replacing the following line in template adcredit_withdraw
Code:
          <xen:if is="{$currency.withdraw_conversion_rate}">

with
Code:
          <xen:if is="{$currency.withdraw_conversion_rate} > 0">

* While this fixes the front-end I fear that the back-end will still allow a withdrawal to be made on a currency that has withdrawal disabled (or conversion_rate == 0).

Edit x4:

Gifting is also susceptible to the same double precision bug documented at the beginning. The fix involves modifying template adcredit_package_purchase_do in a similar fashion. Also the lower case "submit" button using the submit phrase looks a little improper. I replaced it with the go phrase, which is properly capitalized.

Code:
<form action="{$payPalUrl}" method="post" class="xenForm formOverlay">
   <input type="hidden" name="cmd" value="_xclick" />
   <input type="hidden" name="amount" value="{xen:helper currency, $package.price, 0}" />
  
   <dl class="ctrlUnit submitUnit">
     <dt></dt>
     <dd style="text-align: center;">
       {xen:phrase adcredit_click_here_if_redirect_takes_longer_than_X_seconds, 'seconds=<span id="numSeconds">5</span>'}<br>
       <input type="submit" value="{xen:phrase go}" class="button primary">
     </dd>
   </dl>
 
Last edited:
@Jake B. couple users reported the same issue today. Since latest update to Credits & Credits Shop, users aren't earning correctly.
When someone posts a thread, they earn the amount for a post and no alert is sent (I have alerts on for threads).
 
Not working for me, enabled all correct permissions but the currency doesn't increase when someone posts or creates a new thread and when I tried to run the reset (/admin.php?adcredits/reset) I was sent to a blank white page & no users were reset.
 
When I tested the withdrawal, I had 200 points. I typed in 175 to be withdrawal, the addon rounded up to 200.

I was like, WOAH WOAH WOAH I DON'T THINK SO!

We should make sure that it absolutely doesn't round up. Well, if it says 175.0003, then sure, round it to 175.

But I don't think we should round 175 up to 200 - that's a 25 point gain by the user and a 25 point shaft in our arse!
 
When I upgraded to 1.0.8, it no longer respects the actions I had set.
For example, I had 0.50 credits given for every rating made. Instead, they get 0.02.
I also didn't have any actions for downloading attachments, and suddenly people are being rewarded with 0.02 credit for downloading.
Something broke. There's no server errors or bugs reported.

For now I've disabled the add-on until it respects the actions I have set up as intended. Your speedy response would be great. :)
 
Here:


Also it seems that the credit rewards for login resource bought suddenly stops at 1400 credits for no reason. Changed nothing on the system.

We've already gotten that fixed for the next release - I must have just forgotten to reply to the post. :)

When I upgraded to 1.0.8, it no longer respects the actions I had set.
For example, I had 0.50 credits given for every rating made. Instead, they get 0.02.
I also didn't have any actions for downloading attachments, and suddenly people are being rewarded with 0.02 credit for downloading.
Something broke. There's no server errors or bugs reported.

For now I've disabled the add-on until it respects the actions I have set up as intended. Your speedy response would be great. :)

This issue was fixed in one of the recent patches

- Jake
 
Top Bottom