This tutorial will show you how you can add support for a PayPal hosted button ID. A PayPal hosted button ID is a feature from PayPal that allows you to setup recurring billing such as a Subscription for a Support Package; having a regular button that(buy now, pay now), when added, it could apply tax percentages that you setup through your PayPal account.
First And Foremost: Please Remember To Make A Backup Of Your Files Before Editing!!
Step 1: OK, first off, we'll need to add two(2) new Rows to your items and Member Profile sections in the MarketPlace. The member section allows your members to choose if they want to use the button id, or just use their email as normal for selling items in your MarketPlace.
Go to ACP -> Support tab -> SQL Toolbox, run the following Query to add the necessary rows:
ALTER TABLE `ibf_markets_items` ADD `buttonid` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER `price`; ALTER TABLE `ibf_markets_members` ADD `business_type` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'email' AFTER `memail`;
Step 2: File Edits. For this next step, we'll need to edit 3 files to accomplish this task.
File #1: Open FTP and find, admin -> applications_addon -> other -> markets -> modules_public -> markets -> items.php,
Find: (In function doaddItem())
//---------------------- // inputs //----------------------- $stock = intval($this->request['stock']); $unlimited = intval($this->request['unlimited']); $reqship = intval($this->request['reqship']); $price = $this->request['price'];
Add Below:
$buttonid = $this->request['buttonid'];
Find:
//---------------------- // Approval //---------------------- $approved = 0; $redirect = $this->lang->words['not_approved_redirect']; if($this->libs->IsApproved()) { $approved = 1; $redirect = $this->lang->words['approved_redirect']; } //----------------------- // Save //------------------------ $insert = array('title' => $title, 'owner' => $this->memberData[ 'member_id' ], 'owner_name' => $this->memberData[ 'members_display_name' ], 'date' => time(), 'qdesc' => ( isset( $this->request['qdesc'] ) ) ? $this->request['qdesc'] : '', 'free' => $free, 'content' => $content, 'approved' => $approved, 'price' => $price,
Add Below:
'buttonid' => $buttonid,
--------------------------------------------------------------------------------------------
Find: (In function Doeditmarket())
//---------------------- // inputs //----------------------- $stock = intval($this->request['stock']); $unlimited = intval($this->request['unlimited']); $reqship = intval($this->request['reqship']); $price = $this->request['price'];
Add Below:
$buttonid = $this->request['buttonid'];
Find:
// <!-------------- / End File ----> $this->DB->update( 'markets_items', array( 'title' => $title, 'qdesc' => ( isset( $this->request['qdesc'] ) ) ? $this->request['qdesc'] : '', 'free' => $free, 'content' => $content, 'price' => $price,
Add Below:
'buttonid' => $buttonid,
============================================================================================
============================================================================================
File #2: Open FTP and find, admin -> applications_addon -> other -> markets -> modules_public -> payment -> paypal.php,
Find:
//----------------- // Log results? //-------------------- $this->ipn_log_file = IPSLib::getAppDir( 'markets' ) . '/logs/ipn_log.txt'; $this->ipn_log = true; $this->last_error = ''; $this->ipn_response = ''; $this->add_field('rm','2'); // Return method = POST for paypal $this->add_field('cmd','_xclick');
Then Remove From The Above:
$this->add_field('cmd','_xclick');
Find:
$this->add_field( 'business' , $Owner['mpbusiness']);
Replace With:
if ( $Owner['business_type'] == 'email' ) { $this->add_field( 'cmd' , '_xclick' ); $this->add_field( 'business' , $Owner['mpbusiness']); } else { $this->add_field( 'cmd' , '_s-xclick' ); }
Find:
$this->add_field( 'amount' , $item['price']);
Replace With:
if ( $Owner['business_type'] == 'email' ) { $this->add_field( 'amount' , $item['price']); } else { $this->add_field( 'hosted_button_id' , $item['buttonid']); }
============================================================================================
============================================================================================
File #3: Open FTP and find, admin -> applications_addon -> other -> markets -> modules_public -> payment -> profile.php,
Find:
//----------------------------------------- // Check the email address //----------------------------------------- $mpbusiness = $this->request['mpbusiness']; if( !IPSText::checkEmailAddress( $mpbusiness ) ) { $this->registry->output->showError( $this->lang->words['invalid_email'] ); return; } $mname = $this->memberData['members_display_name']; if($this->settings['auth_allow_dnames'] == 0) { $mname = $this->memberData['name']; } $save = array( 'mid' => $this->memberData['member_id'], 'mname' => $mname, 'memail' => $this->memberData['email'],
Add Below:
'business_type' => $this->request['business_type'],
Step 3: Template Edits.
Template Edit #1: Go to ACP -> Look & Feel -> Select Skin -> skin_markets -> ShowForm,
Find:
<li class='field'> <label for='row'>{$this->lang->words['price']} </label> {$this->settings['markets_sign']} <input type='text' class='input_text' name='price' id='price' value='{$row[ 'price' ]}' size='50' /><span class="desc">{$this->lang->words['price_desc']}</span> </li>
Add Below:
<li class='field'> <label for='row'>PayPal Hosted Button ID </label> <input type='text' class='input_text' name='buttonid' id='buttonid' value='{$row[ 'buttonid' ]}' size='50' /><span class="desc">This is so payments are made as a "Purchase Payment" and not a "Personal Payment" which PayPal takes out fees.</span> </li>
Template Edit #2: Go to ACP -> Look & Feel -> Select Skin -> skin_markets_member -> BusinessProfile,
Find:
<tr class='{parse striping="catTable"}'> <td class="altrow" width="50%"><b>{$this->lang->words['business']}</b><br> <p class="desc"> {$this->lang->words['business_desc']} </p> </td> <td class="altrow"> <input type='text' class='input_text' name='mpbusiness' id='mpbusiness' value='{$data['mpbusiness']}' size='50' /></td> </tr>
Add Above:
<tr class='{parse striping="catTable"}'> <td class="altrow" width="50%"><b>Business Type</b><br> <p class="desc"> Please choose if you would like to use your PayPal Email address defined below or with a paypal Hosted Button ID?<br />PayPal Email address is for all items you sell.<br />PayPal Hosted Button ID is a "Per-Item" setting and must be defined individually when adding items for sell. </p> </td> <td class="altrow"><select name="business_type" id="business_type"> <option value="{$data['business_type']}">Select Business (Current = {$data['business_type']})</option> <option value="email">PayPal Email</option> <option value="button">PayPal Hosted Button</option> </select></td> </tr>
Once you have done all of the following instructions, you should now have the ability of switching from your Email Address to a PayPal Hosted Button ID.
If you have questions or concerns about this tutorial, please post your comments and I'll try to help you with this.
Regards,
Donald ^_^
0 Comments
Recommended Comments
There are no comments to display.