WP Residence Help WP Residence Help

  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API
Home / Technical how to | Custom Code Required / Technical how to : Integrate new payment gateway

Technical how to : Integrate new payment gateway

3589 views 0

There are 2 main places where you should add your code when adding a new payment gateway:
The places where you put the pay now buttons and send requests to the payment processor servers.
A new page where the processor server will send the response to your transaction (accepted, rejected etc).

Where to add the payment buttons

Depending on the payment type you chose the “pay now” buttons can be put in 2 places.

Important : when sending the request to the payment server you also need to send what type of transaction you are doing.  For example if you are doing a membership payment you need to send a a variable like is_membership along with the required data. The processor should also return this variable in the processor page and yu would be able to know if the transaction is a membership payment or a booking payment and act accordingly.

1. User Dashboard Page Sidebar 

In this case the file is user_membership_profile.php  and you should add your code around line 64 . Here is the code where paypal, stripe or pay by wire buttons are added.

if($enable_paypal_status==='yes'){
print '<div id="pick_pack"></div>';
}
if($enable_stripe_status==='yes'){
wpestate_show_stripe_form_membership();
}

if($enable_direct_status==='yes'){
print '<div id="direct_pay" class="wpb_button wpb_btn-info wpb_btn-large">'.__('Wire Transfer','wpestate').'</div>';
}

2. Property unit in dashboard – in case you are using  per submission payments

In this case the buy now buttons should be placed in dashboard_listing_unit.php around line 181.  As you can see in the code , first we check if the payment is in membership mode

the actual buttons are around line 195 or line 219 ( there is a if to check if a the listing is already published but not featured)

if($enable_paypal_status==='yes'){
$stripe_class=' stripe_paypal ';
print '

'.__('Pay with Paypal','wpestate').'

';
}

if($enable_stripe_status==='yes'){
wpestate_show_stripe_form_per_listing($stripe_class,$post_id,$price_submission,$price_featured_submission);
}
if($enable_direct_status=='yes'){
print '

'.__('Wire Transfer','wpestate').'

';
}

The “processor” page.

For each new payment processor you should create a new page template and in there  you should check the the transaction response.

For example , for stripe we have the stripecharge.php page template. When we setup Stripe, beside adding a api keys a user must also create a new page with the template “Stripe Charge Pay”. The he will use this link as the return page for the Stripe setup.

So, for your new processor do the following

create a template new_processor.php
add in header  the following
// Template Name: New Processor Charge Page
// Wp Estate Pack

Create a page with the new template and use that as the “return url” for the new merchant.

In the actual processor page

Here you should check if the transaction is valid and if yes – validate the transaction.  All the merchants have sample code for check this answers and you should start from their code.

In case the transaction is a submission payment the code is at line 157


if ( isset ($_POST['submission_pay'])  && $_POST['submission_pay']==1  )

Important points in this case :

insert the invoice with wpestate_insert_invoice .

$invoice_id = wpestate_insert_invoice('Upgrade to Featured','One Time',$listing_id,$date,$current_user->ID,0,1,'' );

update the invoice status with 

update_post_meta($invoice_id, 'pay_status', 1);

publish the new listing if is the case –

$post = array(
'ID' => $listing_id,
'post_status' => 'publish'
);
$post_id = wp_update_post($post );

In case the transaction is a recurring payment for membership the code is at line 247

Important points in this case :

check if the new package has fewer listings that the current pack with wpestate_check_downgrade_situation. If yes – use
wpestate_downgrade_to_pack()

Upgrade the membership with
 wpestate_upgrade_user_membership($current_user-&gt;ID,$pack_id,2,'');

 In case the transaction is a payment for membership the code is at line 309

Important points in this case :

check if the new package has fewer listings that the current pack with wpestate_check_downgrade_situation. If yes – use
wpestate_downgrade_to_pack()

Upgrade the membership with  
wpestate_upgrade_user_membership($current_user-&gt;ID,$pack_id,2,'');

If you need additional explanations about how to implement the merchant please post a ticket at support.wpestate.org and will update this document.

Technical how to | Custom Code Required

Related Articles

  • Introduction to WPResidence Header Customization
  • Understanding WPResidence Header Types: An Overview
  • Customizing the WPResidence Logo Display
  • Configuring the Primary Navigation Menu in WPResidence

WP Residence Documentation

  • 1. General
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 2. Installation
  • 3. Installation FAQ
  • 4. Advanced Search
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 5. Agent, Agency & Developers
  • 6. Property Page
  • 7. Properties List
  • 8. Property Taxonomies
  • 9. Property Custom Template
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • Theme Options
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • Translation
  • FAQ
  • Pages
  • Header
  • Footer
  • Google or Open Street Maps
  • Payment Options
  • Plugins
    • Included Plugins
    • Third Party Plugins – IDX Compatibility
    • Third Party Plugins – Multi Languages
    • Third party Plugins – Other
  • Technical
    • Technical how to | Custom Code Required
    • Technical: Child Theme
  • Theme Updates

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • How to Build Your Website
  • Video Tutorials
  • Client Support
  • API