This technical help has been written by our development team based on the answers/directions provided to our clients who have asked for directions to modify the code. We published them hoping that they will help other clients with similar requests implement the modifications faster.

Please keep in mind that theme customization services ARE NOT included in the client standard support. Our support team cannot do code modifications for you.

Item support is a service provided directly by us through the FreshDesk ticket system. Support is limited to questions regarding the theme’s features or problems with the theme. We are not able to provide support for code customizations or third-party plugins. If you need help with anything other than minor customizations of your theme, we suggest searching for a WordPress developer on studio.envato.com.

Full Themeforest support policy is available here for further information (https://themeforest.net/page/item_support_policy).

================

There are 2 main places where you should add your code when adding a new payment gateway.

  1. The places where you put the pay now buttons and send requests to the payment processor servers
  2. 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 3 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 variable like is_membership along with the required data. The processor should also return this variable in the processor page and you would be able to know if the transaction is a membership payment or a booking payment and act accordingly.

 

1. My subscription page  –  in case you are using subscription membership

The subscription page is the page you created with the template “User Dashboard Subscriptions” and the file name is user_dashboard_packs.php.

Here you should put the “pay now” buttons for the subscription packages. The PayPal and stripe buttons are at line 66.


if($enable_paypal_status==='yes'){
print '<div id="pick_pack">'.esc_html__( 'Pay with Paypal','wpestate').'</div>';
}
if($enable_stripe_status==='yes'){
wpestate_show_stripe_form_membership();
}

 

2. Property unit in the 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 204.  As you can see in the code, first we check if the payment is in membership mode

if($paid_submission_status=='per listing'){

and then we add the checkbox for “featured” property case. The featured checkbox add the feature price to the total value of the purchase. This is made via javascript in control.js file at line 1775

$('.extra_featured').change(function(){
var parent= $(this).parent();......

……

….

the actual buttons are around line 247

if($enable_paypal_status==='yes'){
print'<span class="listing_upgrade label label-danger" data-listingid="'.$post_id.'">'.esc_html__( 'Set as Featured','wpestate').'</span>';
}
if($enable_stripe_status==='yes'){
wpestate_show_stripe_form_upgrade($stripe_class,$post_id,$price_submission,$price_featured_submission);
}

3. Invoice unit in the dashboard – when users can pay the invoice generated for their booking.

The invoice form is generated via ajax and the php code part is in ajax_functions_booking.php, function wpestate_create_pay_user_invoice_form()  – line 168. The actual pay buttons are at line 302 for stripe and 320 for paypal.

 

 

The “processor” page.

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

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

So, for your new processor do the following

  1. create a template new_processor.php
  2. add in the header  the following

    // Template Name: New Processor Charge Page
    // Wp Estate Pack
  3. 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 to check this answers and you should start from their code.

In case the transaction is a booking payment – the code is at line 162

Important points in this case :

validate the booking:   update_post_meta($booking_id, 'booking_status', 'confirmed');

update the booking_dates array (we store here the reserved dates ) – update_post_meta($curent_listng_id, 'booking_dates', $reservation_array);

update the invoice with the status and deposit paid

  • update_post_meta($invoice_id, 'invoice_status', 'confirmed');
  • update_post_meta($invoice_id, 'depozit_paid', ($depozit/100) );
  • send confirmation email

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

Important points in this case :

insert the invoice with wpestate_insert_invoice .

update the invoice status with   update_post_meta($invoice_id, 'invoice_status', 'confirmed');

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 280

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->ID,$pack_id,2,'');

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

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->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.