Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author myCred

    (@designbymerovingi)

    Hey!

    That particular code was written for PayPal but you can change it to work with Strip (or any other buyCRED gateway for that matter) by changing:

    buy_creds_with_paypal_standard

    to:

    buy_creds_with_stripe

    on the 6th line.

    Let me know if you require further assistance.

    Thread Starter PaulMRivera

    (@paulmrivera)

    I have tried replacing that line of code already and it doesn’t appear to work. Any other suggestions?

    Plugin Author myCred

    (@designbymerovingi)

    does the code work with PayPal?

    Thread Starter PaulMRivera

    (@paulmrivera)

    I have not tried it with paypal because I do not have the account setup for that.

    I have been trying to mess with the code and still nothing seems to work.

    Thread Starter PaulMRivera

    (@paulmrivera)

    Is there something I could add to the actual “mycred-stripe.php” in the stripe plugin folder that would award 2 credits to users if they purchase 10 credits, and award 5 credits to users if the purchase 20 credits since the code above isn’t working?

    Thanks for the help.

    Plugin Author myCred

    (@designbymerovingi)

    Hey.

    A quick question:

    You are using the code from the support forum and I assume you made the change I suggested earlier. Did you remove the minimum 100 points check in the code?

    In the forum topic the user requested that only users who buy more then 100 points get this bonus. So if you try that code with less then 100 points purchases, it will not award points.

    Thread Starter PaulMRivera

    (@paulmrivera)

    Yes I changed it to 9 instead of 100 to see if when i purchase 10, it will award 2.

    Plugin Author myCred

    (@designbymerovingi)

    Could you paste the code you are using in a pastebin so I can have a look?

    Thread Starter PaulMRivera

    (@paulmrivera)

    add_filter( 'mycred_add', 'add_bonus_points_for_purchase', 10, 3 );
    function add_bonus_points_for_purchase( $reply, $request, $mycred )
    {
    	if ( $reply === false ) return $reply;
    	// For Stripe Payments
    	if ( $request['ref'] != 'buy_creds_with_stripe' ) {
    		$amount = $request['amount'];
    		// Award bonus for purchases over 9 points
    		if ( $amount == 10 ) {
    			// Give extra 2 points
    			// Remember not to use $mycred->add_creds() here or you will
    			// create an endless loop. Instead use update_users_balance()
    			$mycred->update_users_balance( $request['user_id'], 2 );
    			// Log the good news
    			$mycred->add_to_log(
    				'bonus_points',
    				$request['user_id'],
    				2,
    				'Bonus points for %plural% purchase!'
    			);
    		}
    	}
    
    	return $reply;
    }

    I also tried this (switching “==9” to “> 9”:

    add_filter( 'mycred_add', 'add_bonus_points_for_purchase', 10, 3 );
    function add_bonus_points_for_purchase( $reply, $request, $mycred )
    {
    	if ( $reply === false ) return $reply;
    	// For Stripe Payments
    	if ( $request['ref'] != 'buy_creds_with_stripe' ) {
    		$amount = $request['amount'];
    		// Award bonus for purchases over 9 points
    		if ( $amount > 9 ) {
    			// Give extra 2 points
    			// Remember not to use $mycred->add_creds() here or you will
    			// create an endless loop. Instead use update_users_balance()
    			$mycred->update_users_balance( $request['user_id'], 2 );
    			// Log the good news
    			$mycred->add_to_log(
    				'bonus_points',
    				$request['user_id'],
    				2,
    				'Bonus points for %plural% purchase!'
    			);
    		}
    	}
    
    	return $reply;
    }
    Plugin Author myCred

    (@designbymerovingi)

    Change:

    $request['ref'] != 'buy_creds_with_stripe'

    to:

    $request['ref'] == 'buy_creds_with_stripe'
    Thread Starter PaulMRivera

    (@paulmrivera)

    You are a god. Works perfectly now. Thanks!

    Plugin Author myCred

    (@designbymerovingi)

    Sometimes it’s the smallest things.

    Thread Starter PaulMRivera

    (@paulmrivera)

    Couldn’t agree more. Thanks again.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Bonus Credits: Stripe Payment Add-On’ is closed to new replies.