From f458c2a87c9b0eb60c921af66337c87dc4f91ee0 Mon Sep 17 00:00:00 2001 From: Joshua Lewis Date: Mon, 7 Dec 2020 09:27:36 -0500 Subject: [PATCH] whcms8 support --- modules/gateways/bitpaycheckout.php | 33 ++++++++++++++++--- .../bitpaycheckout/bitpaycheckout.php | 33 ++++++++++++++++--- .../bitpaycheckout_callback.php | 2 +- .../bitpaycheckout/bitpaycheckout_ipn.php | 2 +- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/modules/gateways/bitpaycheckout.php b/modules/gateways/bitpaycheckout.php index 27b4879..b987caf 100644 --- a/modules/gateways/bitpaycheckout.php +++ b/modules/gateways/bitpaycheckout.php @@ -1,6 +1,6 @@ 'BitPay_Checkout_WHMCS', - 'APIVersion' => '3.0.1.8', // Use API Version 1.1 + 'APIVersion' => '3.0.1.9', // Use API Version 1.1 'DisableLocalCreditCardInput' => false, 'TokenisedStorage' => false, ); @@ -115,6 +115,12 @@ function bitpaycheckout_config() 'Options' => 'Test,Production', 'Description' => 'Select Test for testing the plugin, Production when you are ready to go live.
', ), + 'bitpay_checkout_mode' => array( + 'FriendlyName' => 'Payment UX', + 'Type' => 'dropdown', + 'Options' => 'Modal,Redirect', + 'Description' => 'Select Modal to keep the user on the invoice page, or Redirect to have them view the invoice at BitPay.com, and be redirected after payment.
', + ), ); @@ -168,6 +174,7 @@ function bitpaycheckout_link($config_params) $moduleDisplayName = $config_params['name']; $moduleName = $config_params['paymentmethod']; + $whmcsVersion = $config_params['whmcsVersion']; $postfields = array(); $postfields['username'] = $username; @@ -194,8 +201,13 @@ function bitpaycheckout_link($config_params) #BITPAY INVOICE DETAILS $wh = new BPC_Wh(); $config_params['bitpay_checkout_endpoint'] = strtolower($config_params['bitpay_checkout_endpoint']); + $config_params['bitpay_checkout_mode'] = strtolower($config_params['bitpay_checkout_mode']); + + $bitpay_checkout_token = $wh->BPC_getBitPayToken($config_params['bitpay_checkout_endpoint'], $config_params); $bitpay_checkout_endpoint = $config_params['bitpay_checkout_endpoint']; + $bitpay_checkout_mode = $config_params['bitpay_checkout_mode']; + $config = new BPC_Configuration($bitpay_checkout_token, $config_params['bitpay_checkout_endpoint']); @@ -215,7 +227,7 @@ function bitpaycheckout_link($config_params) $params->orderId = trim($invoiceId); $params->notificationURL = $protocol . $_SERVER['SERVER_NAME'] . $dir . '/modules/gateways/bitpaycheckout/bitpaycheckout_ipn.php'; - $params->redirectURL = $params->notificationURL; + $params->redirectURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $params->extendedNotifications = true; @@ -235,9 +247,12 @@ function bitpaycheckout_link($config_params) $invoice->BPC_createInvoice(); $invoiceData = json_decode($invoice->BPC_getInvoiceData()); $invoiceID = $invoiceData->data->id; + + + error_log("=======USER LOADED BITPAY CHECKOUT INVOICE====="); error_log(date('d.m.Y H:i:s')); - error_log(print_r($invoiceData, true)); + # error_log(print_r($invoiceData, true)); error_log("=======END OF INVOICE=========================="); error_log(print_r($params,true)); @@ -267,12 +282,20 @@ function bitpaycheckout_link($config_params) error_log($e->getMessage()); $pdo->rollBack(); } - + if($bitpay_checkout_mode == 'modal'): $htmlOutput .= ''; + else: + $htmlOutput .= ''; + endif; ?> + +