Critical Issue while using wpinv_insert_invoice()
This topic contains 2 replies, has 3 voices, and was last updated by picocodes 5 years, 11 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
February 15, 2020 at 9:27 pm #4114
Hello,
I am using wpinv_insert_invoice() function to create invoice programmatically. It worked very well locally, however, when I hosted it on my web host my IP is getting blocked by https://bitninja.io/. This is a server security platform being used by web host.
Interestingly, when I create invoice from wordpress admin, it works just fine. However, when I try same thing programmatically my ip is getting blocked as this activity is being treated as some fraudulent activity by this security platform.
Please help me here. This is very critical. Following is the function which creates an invoice when a booking completes.
function create_invoice_when_booking_completes($post_id, $post, $update){ // Entertain if this is an update action on booking. if($update && $post->post_type == 'booking'){ $bookingCharges = getAllBookingCharges($post_id); $bookingInvoiceId = get_field( "booking_invoice_id", $post_id); $bookingReference = get_field( "booking_reference", $post_id); $bookingGuid = get_field( "booking_guid", $post_id); $bookingDetailsUrl = getBookingDetailsUrl($bookingGuid); $bookingState = get_field( "booking_state", $post_id); $userNotes = array(); //Create invoice if it is not created already and booking state is created. if(empty($bookingInvoiceId) && $bookingState == 'completed'){ $cartDetails = array(); if($bookingCharges){ array_push($userNotes, "Booking Details: " . "" . $bookingReference . ""); array_push($userNotes, "Booking Reference: " . $bookingReference); foreach($bookingCharges as $charge){ if($charge['itemQuantity'] > 0){ array_push($cartDetails, array( 'id' => $charge['invoiceItemId'], 'quantity' => $charge['itemQuantity'], 'custom_price' => $charge['unitPrice'] )); } } } $data = array( 'status' => 'wpi-pending', 'user_id' => get_post_field( 'post_author', $post_id ), 'cart_details' => $cartDetails, 'currency' => 'AUD', 'user_note' => implode("<br>", $userNotes) ); if (function_exists('wpinv_insert_invoice')) { $invoice = wpinv_insert_invoice( $data, true ); if ( is_wp_error( $invoice ) ) { log_server_side_error('Invoice', 'Failed to CREATE Invoice', $invoice->get_error_message()); } else{ update_field('booking_invoice_id', $invoice->ID, $post_id); } } else{ log_server_side_error('Invoice', 'Failed to CREATE Invoice as wpinv_insert_invoice function from the plugin is not available.', ""); } } } return; }Warm regards,
Arshad.February 15, 2020 at 10:04 pm #4116The developers will take a look at your topic when they get back to the office, probably after the weekend.
February 17, 2020 at 7:06 am #4122Hi Arshad,
Is the above function adding any errors in your error log?
If not, contact your web host and ask them to stop blocking your IP address.
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket