Skip to content

Commit

Permalink
Set sandbox at product level in addition to global settings, ref #204
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Mar 10, 2017
1 parent 84e231b commit f7317cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion angelleye-includes/angelleye-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,9 @@ public function angelleye_paypal_for_woocommerce_billing_agreement_details($orde

public static function angelleye_paypal_for_woocommerce_is_set_sandbox_product() {
$is_sandbox_set = false;
if (sizeof(WC()->cart->get_cart()) != 0) {
global $woocommerce;

if (isset(WC()->cart) && sizeof(WC()->cart->get_cart()) > 0) {
foreach (WC()->cart->get_cart() as $key => $value) {
$_product = $value['data'];
if (isset($_product->id) && !empty($_product->id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public function __construct($gateway) {
$this->disable_term = 'yes' === $this->gateway->get_option('disable_term', 'no');
$this->save_abandoned_checkout = 'yes' == $this->gateway->get_option('save_abandoned_checkout', 'no');
$this->softdescriptor = $this->gateway->get_option('softdescriptor', '');
$this->testmode = 'yes' === $this->gateway->get_option('testmode', 'yes');
if( $this->testmode == false ) {
$this->testmode = AngellEYE_Utility::angelleye_paypal_for_woocommerce_is_set_sandbox_product();
}
$this->credentials = array(
'Sandbox' => $this->gateway->testmode == 'yes' ? TRUE : FALSE,
'Sandbox' => $this->testmode,
'APIUsername' => $this->gateway->api_username,
'APIPassword' => $this->gateway->api_password,
'APISignature' => $this->gateway->api_signature,
Expand Down Expand Up @@ -147,8 +151,7 @@ public function angelleye_do_express_checkout_payment() {
if ($this->response_helper->ec_is_response_success_or_successwithwarning($this->paypal_response)) {
$this->angelleye_ec_get_customer_email_address($this->confirm_order_id);
$this->angelleye_ec_sellerprotection_handler($this->confirm_order_id);
$is_sandbox = $this->gateway->testmode == 'yes' ? true : false;
update_post_meta($order->id, 'is_sandbox', $is_sandbox);
update_post_meta($order->id, 'is_sandbox', $this->testmode);
if ($this->paypal_response['PAYMENTINFO_0_PAYMENTSTATUS'] == 'Completed') {
$order->payment_complete($this->paypal_response['PAYMENTINFO_0_TRANSACTIONID']);
} else {
Expand Down Expand Up @@ -563,7 +566,7 @@ public function angelleye_write_paypal_request_log($paypal_action_name) {
WC_Gateway_PayPal_Express_AngellEYE::log('Redirecting to PayPal');
WC_Gateway_PayPal_Express_AngellEYE::log(sprintf(__('PayPal for WooCommerce Version: %s', 'paypal-for-woocommerce'), VERSION_PFW));
WC_Gateway_PayPal_Express_AngellEYE::log(sprintf(__('WooCommerce Version: %s', 'paypal-for-woocommerce'), WC_VERSION));
WC_Gateway_PayPal_Express_AngellEYE::log('Test Mode: ' . $this->gateway->testmode);
WC_Gateway_PayPal_Express_AngellEYE::log('Test Mode: ' . $this->testmode);
WC_Gateway_PayPal_Express_AngellEYE::log('Endpoint: ' . $this->gateway->API_Endpoint);
}
$PayPalRequest = isset($this->paypal_response['RAWREQUEST']) ? $this->paypal_response['RAWREQUEST'] : '';
Expand Down Expand Up @@ -797,7 +800,7 @@ public function DoReferenceTransaction($order_id) {
$PayPalRequestData['PaymentDetails'] = $PaymentDetails;
$this->paypal_response = $this->paypal->DoReferenceTransaction($PayPalRequestData);
AngellEYE_Gateway_Paypal::angelleye_paypal_for_woocommerce_curl_error_handler($this->paypal_response, $methos_name = 'DoExpressCheckoutPayment', $gateway = 'PayPal Express Checkout', $this->gateway->error_email_notify);
WC_Gateway_PayPal_Express_AngellEYE::log('Test Mode: ' . $this->gateway->testmode);
WC_Gateway_PayPal_Express_AngellEYE::log('Test Mode: ' . $this->testmode);
WC_Gateway_PayPal_Express_AngellEYE::log('Endpoint: ' . $this->gateway->API_Endpoint);
$PayPalRequest = isset($this->paypal_response['RAWREQUEST']) ? $this->paypal_response['RAWREQUEST'] : '';
$PayPalResponse = isset($this->paypal_response['RAWRESPONSE']) ? $this->paypal_response['RAWRESPONSE'] : '';
Expand Down

0 comments on commit f7317cb

Please sign in to comment.