Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
  #1  
Old 05-31-2009, 09:23 PM
JamesGunner JamesGunner is offline
 
Join Date: Sep 2008
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Payment API custom modification

Hello,

Basically I made a custom profile field within vbulletin. My Game Servers update the data within the database once they earn something on the servers. I want them to be able to get a paid subscription with these points basically the z-points are the currency and the database is the API processor. Those points are saved within custom profile "field6".

Here is the code I have so far:

product_zpoints.xml

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="zpoints" active="1">
	<title>Z-Points</title>
	<description>Add Z-Points to the payment gateway</description>
	<version>0.0.2</version>
	<codes>
		<code version="1.0.0">
			<installcode><![CDATA[// Fill the settings array
// add the z-points record to the paymentapi table
$db->hide_errors();
$db->query_write("
	INSERT INTO " . TABLE_PREFIX . "paymentapi
	(title, currency, recurring, classname, active, settings)
	VALUES
	('Z-Points', 'z-points', 0, 'zpoints', 0, '" . $db->escape_string(serialize($settings)) . "')
");
$db->show_errors();]]></installcode>
			<uninstallcode><![CDATA[$db->hide_errors();
$db->query_write("DELETE FROM " . TABLE_PREFIX . "paymentapi WHERE title = 'Z-Points'");
$db->show_errors();]]></uninstallcode>
		</code>
	</codes>
	<templates>
		<template name="subscription_payment_zpoints" templatetype="template" date="0" username="JamesGunner" version="3.6.0">
			<![CDATA[
				<input type="hidden" name="amount" value="$cost">
				<input type="hidden" name="test_mode" value="$settings[test_mode]">
				<input type="hidden" name="product_name" value="$subinfo[title] Subscription">
				<input type="hidden" name="description" value="$subinfo[description]">
				<input type="hidden" name="unit_price" value="$cost">
				<input type="hidden" name="require_IPN" value="0">
				<input type="hidden" name="return_URL" value="$vboptions[bburl]/payment_gateway.php?method=zpoints">
			]]>
		</template>
	</templates>
	<plugins>	
		<plugin active="1" executionorder="5">
			<title><![CDATA[Z-Points - add 'order using']]></title>
			<hookname>paidsub_order_start</hookname>
			<phpcode><![CDATA[$vbphrase += array( 'zpoints' => 'Z-Points' );]]></phpcode>
		</plugin>
	</plugins>
	<phrases>
		<phrasetype name="GLOBAL" fieldname="global">
			<phrase name="setting_zpoints_test_mode_desc" date="1156824632" username="Hambil" version="1.0.0"><![CDATA[Enable Test Mode. Transactions in test mode are 'fake' and not charged to an account.]]></phrase>
			<phrase name="setting_zpoints_test_mode_title" date="1156824659" username="Hambil" version="1.0.0"><![CDATA[Test Mode]]></phrase>
			<phrase name="zpoints_order_instructions" date="1156875116" username="Hambil" version="1.0.0"><![CDATA[To pay for your subscription via Z-Points click the button below and follow the onscreen instructions.]]></phrase>
		</phrasetype>
		<phrasetype name="Error Messages" fieldname="error">
			<phrase name="zpoints_cancel"><![CDATA[[ZOW] Im sorry! You do not seem to have enough zpoints to get admin or an error occured!]]></phrase>
		</phrasetype>
	</phrases>
</product>
Which works perfectly fine and Z-points can also be activated as an Payment API.

Now I think my problem is the heart of the Payment API, the class file. I really think that I need help with this one.

This is what i got so far:

class_zpoints.php

PHP Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin                                   # ||    
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000-2006 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

if (!isset($GLOBALS['vbulletin']->db))
{
    exit;
}

/**
* Class that provides payment verification and form generation functions
*
* @package    vBulletin
* @version    $Revision: 1.6 $
* @date        $Date: 2006/05/11 21:21:00 $
*/
class vB_PaidSubscriptionMethod_zpoints extends vB_PaidSubscriptionMethod
{
    
/**
    * The currencies that are supported by this payment provider
    *
    * @var    array
    */
    
var $supported_currency = array('zpoints' => true);

    
/**
    * The variable indicating if this payment provider supports recurring transactions
    *
    * @var    bool
    */
    
var $supports_recurring false;

    
/**
    * The variable indicating that this payment provider gives immediate feedback that
    * should be displayed
    *
    * @var    bool
    */
    
var $display_feedback false;

    
/**
    * Perform verification of the payment, this is called from the payment gateway
    *
    * @return    bool    Whether the payment is valid
    */
    
function verify_payment()
    {      
        
$this->registry->input->clean_array_gpc('r', array(
            
'product_name'        => TYPE_STR,
            
'status'            => TYPE_STR,
            
'unit_price'        => TYPE_STR,
            
'transaction_id'    => TYPE_NUM,
            
'transaction_date'    => TYPE_STR,
            
'user_id'            => TYPE_STR
        
));
        
        
$this->product_name $this->registry->GPC['product_name'];
        
$this->status $this->registry->GPC['status'];
        
$this->unit_price $this->registry->GPC['unit_price'];
        
$this->transaction_id $this->registry->GPC['transaction_id'];
        
$this->transaction_date $this->registry->GPC['transaction_date'];
        
$this->user_id $this->registry->GPC['user_id'];
 
            
// lets check the values
            
if (!empty($this->paymentinfo))
            {
                
$zpoints $db->query_read("SELECT field6 FROM userfield WHERE userid = ".$this->user_id);
                
                if ((
$zpoints-$this->unit_price) => 0)
                {
                    
$zpointstotal $zpoints-$this->unit_price
                    
                    $db
->query_write("
                           UPDATE 'userfield'
                        SET `field6` = 
$zpointstotal
                        WHERE `userid` = "
.$this->user_id);
                    
                    
$this->type 1;
                    return 
true;
                }
                else
                {
                      
$this->error fetch_error('zpoints_cancel');
                }            
            }
        }
        return 
false;
    }

    
/**
    * Test that required settings are available, and if we can communicate with the server (if required)
    *
    * @return    bool    If the vBulletin has all the information required to accept payments
    */
    
function test()
    {
        return (!empty(
$this->settings['secret_code']) AND !empty($this->settings['email']));
        
//return true;
    
}

    
/**
    * Generates HTML for the subscription form page
    *
    * @param    string        Hash used to indicate the transaction within vBulletin
    * @param    string        The cost of this payment
    * @param    string        The currency of this payment
    * @param    array        Information regarding the subscription that is being purchased
    * @param    array        Information about the user who is purchasing this subscription
    * @param    array        Array containing specific data about the cost and time for the specific subscription period
    *
    * @return    array        Compiled form information
    */
    
function generate_form_html($cost$currency$subinfo$userinfo$timeinfo)
    {      
        
$currency strtoupper($currency);
        
        
// load settings into array so the template system can access them
        
$settings =& $this->settings;

        
$settings['email'] = htmlspecialchars_uni($settings['email']);
        
$settings['product_name'] = htmlspecialchars_uni($this->registry->subinfo['title']);
        
        eval(
'$form[\'hiddenfields\'] .= "' fetch_template('subscription_payment_zpoints') . '";');
        return 
$form;
    }
}

?>
Im not sure what I did wrong since I dont know much about php neither about vbulletin. I really need this Payment API so any help is really appreciated!

Thanks for the reply ahead...
Reply With Quote
  #2  
Old 06-03-2009, 03:21 PM
JamesGunner JamesGunner is offline
 
Join Date: Sep 2008
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nobody can help me?
Reply With Quote
  #3  
Old 07-10-2009, 07:32 PM
imported_silkroad imported_silkroad is offline
 
Join Date: Dec 2003
Posts: 563
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi James,

Do you have this working yet?

Question, in this install code:

Quote:
<installcode><![CDATA[// Fill the settings array
// add the z-points record to the paymentapi table
$db->hide_errors();
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "paymentapi
(title, currency, recurring, classname, active, settings)
VALUES
('Z-Points', 'z-points', 0, 'zpoints', 0, '" . $db->escape_string(serialize($settings)) . "')
");
$db->show_errors();]]></installcode>
Where do you input the settings into the database?
Reply With Quote
  #4  
Old 07-10-2009, 07:46 PM
JamesGunner JamesGunner is offline
 
Join Date: Sep 2008
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hey thanks for you trying to help. We already implemented this after a long time of trying and trying. We ended up making our own currency and whatnot but it seems to work now.
Reply With Quote
  #5  
Old 07-10-2009, 08:47 PM
imported_silkroad imported_silkroad is offline
 
Join Date: Dec 2003
Posts: 563
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi James,

I am working on a similar problem. Can you post your final code?

Thanks!
Reply With Quote
  #6  
Old 09-27-2009, 06:29 PM
jskoh jskoh is offline
 
Join Date: Dec 2008
Posts: 125
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anybody have successfully add a local currency?
Reply With Quote
  #7  
Old 09-27-2009, 06:38 PM
imported_silkroad imported_silkroad is offline
 
Join Date: Dec 2003
Posts: 563
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, but it is a lot of template work.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:06 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04006 seconds
  • Memory Usage 2,264KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete