Ejemplo n.º 1
0
function gateway_function_to_process_payment($purchase_data)
{
    // payment processing happens here
    // if (edd_is_test_mode()) {
    //
    // } else {
    //
    // }
    $purchase_summary = edd_get_purchase_summary($purchase_data);
    // var_dump($purchase_data);
    $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'cart_details' => $purchase_data['cart_details'], 'user_info' => $purchase_data['user_info'], 'status' => 'pending');
    // echo $purchase_data['purchase_key'];
    // Record the pending payment
    $payment = edd_insert_payment($payment_data);
    // Setup Yandex.Kassa arguments
    $yandex_args = array('ShopID' => edd_get_option('ya_shop_id', false), 'scid' => edd_get_option('ya_scid', false), 'cps_email' => $purchase_data['user_email'], 'Sum' => $purchase_data['price'], 'orderNumber' => $purchase_data['purchase_key'], 'orderDetails' => $purchase_data['cart_details'], 'CustName' => $purchase_data['user_info']['first_name'], 'paymentType' => 'AC');
    // Build query
    $yandex_redirect = 'https://money.yandex.ru/eshop.xml?';
    $yandex_redirect .= http_build_query($yandex_args);
    // Redirect
    // wp_redirect( $yandex_redirect );
    // if the merchant payment is complete, set a flag
    $merchant_payment_confirmed = false;
    if ($merchant_payment_confirmed) {
        // this is used when processing credit cards on site
        // once a transaction is successful, set the purchase to complete
        edd_update_payment_status($payment, 'complete');
        // go to the success page
        edd_send_to_success_page();
    } else {
        $fail = true;
        // payment wasn't recorded
    }
}
Ejemplo n.º 2
0
/**
 * Processes the purchase data and uses the Manual Payment gateway to record
 * the transaction in the Purchase History
 *
 * @since 1.0
 * @param array $purchase_data Purchase Data
 * @return void
*/
function edd_manual_payment($purchase_data)
{
    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'edd-gateway')) {
        wp_die(__('Nonce verification has failed', 'edd'), __('Error', 'edd'), array('response' => 403));
    }
    /*
    * Purchase data comes in like this
    *
    $purchase_data = array(
    	'downloads' => array of download IDs,
    	'price' => total price of cart contents,
    	'purchase_key' =>  // Random key
    	'user_email' => $user_email,
    	'date' => date('Y-m-d H:i:s'),
    	'user_id' => $user_id,
    	'post_data' => $_POST,
    	'user_info' => array of user's information and used discount code
    	'cart_details' => array of cart details,
    );
    */
    $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'status' => 'pending');
    // Record the pending payment
    $payment = edd_insert_payment($payment_data);
    if ($payment) {
        edd_update_payment_status($payment, 'publish');
        // Empty the shopping cart
        edd_empty_cart();
        edd_send_to_success_page();
    } else {
        edd_record_gateway_error(__('Payment Error', 'edd'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'edd'), json_encode($payment_data)), $payment);
        // If errors are present, send the user back to the purchase page so they can be corrected
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    }
}
Ejemplo n.º 3
0
function edd_process_paymentwall_purchase($purchase_data)
{
    global $edd_options;
    // Collect payment data
    $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => 'paymentwall', 'status' => 'pending');
    // Record the pending payment
    $payment = edd_insert_payment($payment_data);
    // Check payment
    if (!$payment) {
        // Record the error
        edd_record_gateway_error(__('Payment Error', 'edd'), sprintf(__('Payment creation failed before sending buyer to Paymentwall. Payment data: %s', 'edd'), json_encode($payment_data)), $payment);
        // Problems? send back
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    } else {
        edd_initialize_paymentwall_lib();
        $widget = new Paymentwall_Widget($purchase_data['user_email'], $edd_options['paymentwall_widget_code'], array(new Paymentwall_Product($payment, $purchase_data['price'], edd_get_currency(), stripslashes(html_entity_decode(wp_strip_all_tags(edd_get_purchase_summary($purchase_data, false)), ENT_COMPAT, 'UTF-8')))), array('success_url' => add_query_arg('payment-confirmation', 'paymentwall', get_permalink($edd_options['success_page'])), 'email' => $purchase_data['user_email'], 'sign_version' => Paymentwall_Signature_Abstract::VERSION_THREE, 'integration_module' => 'easy_digital_downloads'));
        // Get rid of cart contents
        edd_empty_cart();
        if (!empty($edd_options['paymentwall_widget_mode']) && $edd_options['paymentwall_widget_mode'] == 'iframe') {
            echo $htmlCode = $widget->getHtmlCode(array('width' => '100%', 'allowtransparency' => 'true'));
        } else {
            wp_redirect($widget->getUrl());
        }
        exit;
    }
}
Ejemplo n.º 4
0
 private function pay_vendors($vendors)
 {
     if (empty($vendors)) {
         $return = array('status' => 'error', 'msg' => __('No vendors found to pay. Maybe they haven\'t set a PayPal address?', 'eddc'));
         $this->mail_results($return);
         return $return;
     }
     $this->include_paypal_sdk();
     $logger = new PPLoggingManager('MassPay');
     $massPayRequest = new MassPayRequestType();
     $massPayRequest->MassPayItem = array();
     $total_pay = 0;
     foreach ($vendors as $user_paypal => $user) {
         // Don't attempt to process payments for users that owe the admin money
         if ($user['total_due'] <= 0) {
             continue;
         }
         $total_pay += $user['total_due'];
         $masspayItem = new MassPayRequestItemType();
         $masspayItem->Amount = new BasicAmountType(edd_get_currency(), $user['total_due']);
         $masspayItem->ReceiverEmail = $user_paypal;
         $massPayRequest->MassPayItem[] = $masspayItem;
     }
     $massPayReq = new MassPayReq();
     $massPayReq->MassPayRequest = $massPayRequest;
     $paypalService = new PayPalAPIInterfaceServiceService();
     // Wrap API method calls on the service object with a try catch
     try {
         $massPayResponse = $paypalService->MassPay($massPayReq);
     } catch (Exception $ex) {
         $return = array('status' => 'error', 'msg' => sprintf(__('Error: %s', 'eddc'), $ex->getMessage()), 'total' => $total_pay);
         return $return;
     }
     $return = array();
     if (isset($massPayResponse)) {
         if ($massPayResponse->Ack === 'Success') {
             if ($this->purge_user_meta($vendors)) {
                 $return = array('status' => 'updated', 'msg' => __('All due commission has been paid for.', 'eddc'), 'total' => $total_pay);
             } else {
                 $return = array('status' => 'error', 'msg' => __('All due commission has been paid for, but I could not clear it from their profiles due to an internal error. Commission will still be listed as due. Please manually mark the commission as paid from the Commissions page.', 'eddc'), 'total' => $total_pay);
             }
         } else {
             $return = array('status' => 'error', 'msg' => sprintf('%s. %s (%s): %s.', $massPayResponse->Ack, $massPayResponse->Errors->ShortMessage, $massPayResponse->Errors->ErrorCode, $massPayResponse->Errors->LongMessage), 'total' => $total_pay);
         }
     }
     $this->mail_results($return);
     return $return;
 }
 /**
  * Process the purchase data and send to Payeezy
  *
  * @since 1.0
  * @return void
  */
 public function process_payment($purchase_data)
 {
     global $edd_options;
     $url = edd_is_test_mode() ? 'https://api-cert.payeezy.com/v1/transactions' : 'https://api.payeezy.com/v1/transactions';
     $payeezy = new Payeezy();
     $payeezy::setApiKey(edd_get_option('payeezy_api_key'));
     $payeezy::setApiSecret(edd_get_option('payeezy_api_secret'));
     $payeezy::setMerchantToken(edd_get_option('payeezy_token'));
     $payeezy::setUrl($url);
     $month = $purchase_data['card_info']['card_exp_month'];
     $month = $month > 9 ? $month : '0' . $month;
     // Payeezy requires two digits
     $year = substr($purchase_data['card_info']['card_exp_year'], -2);
     $card_type = edd_detect_cc_type($purchase_data['card_info']['card_number']);
     switch ($card_type) {
         case 'amex':
             $card_type = 'American Express';
             break;
     }
     $response = json_decode($payeezy->purchase(array('amount' => $purchase_data['price'], 'card_number' => $purchase_data['card_info']['card_number'], 'card_type' => $card_type, 'card_holder_name' => $purchase_data['card_info']['card_name'], 'card_cvv' => $purchase_data['card_info']['card_cvc'], 'card_expiry' => $month . $year, 'currency_code' => 'USD')));
     if ('failed' === $response->validation_status) {
         foreach ($response->Error->messages as $error) {
             edd_set_error($error->code, $error->description);
         }
         edd_send_back_to_checkout('?payment-mode=payeezy');
     } elseif ('success' === $response->validation_status) {
         if ('approved' === $response->transaction_status) {
             $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['post_data']['edd_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'cart_details' => $purchase_data['cart_details'], 'user_info' => $purchase_data['user_info'], 'status' => 'pending');
             // record the pending payment
             $payment_id = edd_insert_payment($payment_data);
             edd_update_payment_status($payment_id, 'publish');
             edd_set_payment_transaction_id($payment_id, $response->transaction_id);
             // Empty the shopping cart
             edd_empty_cart();
             edd_send_to_success_page();
         } else {
             edd_set_error('payeezy_error', sprintf(__('Transaction not approved. Status: %s', 'edd-payeezy'), $response->transaction_status));
             edd_send_back_to_checkout('?payment-mode=payeezy');
         }
     }
 }
function edd_fd_process_payment($purchase_data)
{
    global $edd_options;
    // setup gateway appropriately for test mode
    if (edd_is_test_mode()) {
        $endpoint = 'https://api.demo.globalgatewaye4.firstdata.com/transaction/v11/wsdl';
    } else {
        $endpoint = 'https://api.globalgatewaye4.firstdata.com/transaction/v11/wsdl';
    }
    // check the posted cc deails
    $cc = edd_fd_check_cc_details($purchase_data);
    // fcheck for errors before we continue to processing
    if (!edd_get_errors()) {
        $purchase_summary = edd_get_purchase_summary($purchase_data);
        $payment = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'cart_details' => $purchase_data['cart_details'], 'user_info' => $purchase_data['user_info'], 'status' => 'pending');
        // record the pending payment
        $payment = edd_insert_payment($payment);
        $address = esc_textarea($_POST['card_address'] . ' ' . $_POST['card_address_2'] . '|' . $_POST['card_zip'] . '|' . $_POST['card_city'] . '|' . $_POST['card_state'] . '|' . $_POST['billing_country']);
        $firstdata['Transaction'] = array('ExactID' => $edd_options['firstdata_gateway_id'], 'Password' => $edd_options['firstdata_gateway_password'], 'Transaction_Type' => $edd_options['firstdata_transaction_type'], 'DollarAmount' => $purchase_data['price'], 'Card_Number' => $cc['card_number'], 'Expiry_Date' => $cc['card_exp_month'] . $cc['card_exp_year'], 'CardHoldersName' => $cc['card_name'], 'VerificationStr1' => $address, 'VerificationStr2' => $cc['card_cvc'], 'CVD_Presence_Ind' => 1, 'Reference_No' => $payment, 'ZipCode' => $cc['card_zip'], 'Customer_Ref' => $purchase_data['user_info']['id'], 'Client_IP' => $_SERVER['REMOTE_ADDR'], 'Client_Email' => $purchase_data['user_email'], 'Currency' => $edd_options['currency'], 'Ecommerce_Flag' => is_ssl() ? 8 : 7);
        try {
            $api = @new SoapClient($endpoint);
            $result = $api->__soapCall('SendAndCommit', $firstdata);
        } catch (Exception $e) {
            edd_set_error('firstdata_api_error', sprintf(__('FirstData System Error: %s', 'edd_firstdata'), $e->getMessage()));
            edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
            $fail = true;
        }
        if (isset($result) && $result->Transaction_Approved) {
            edd_update_payment_status($payment, 'complete');
            edd_send_to_success_page();
        } elseif ($result->Transaction_Error) {
            edd_set_error('firstdata_decline', sprintf(__('Transaction Declined: %s', 'edd_firstdata'), $result->EXact_Message));
            edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
            $fail = true;
        }
    } else {
        $fail = true;
    }
}
Ejemplo n.º 7
0
function amt_product_data_jsonld_schemaorg_edd($metatags, $post)
{
    // Price
    $metatags['price'] = edd_get_download_price($post->ID);
    // Currency
    $metatags['priceCurrency'] = edd_get_currency();
    $metatags = apply_filters('amt_product_data_edd_jsonld_schemaorg', $metatags);
    return $metatags;
}
/**
 * Given a currency determine the symbol to use. If no currency given, site default is used.
 * If no symbol is determine, the currency string is returned.
 *
 * @since  2.2
 * @param  string $currency The currency string
 * @return string           The symbol to use for the currency
 */
function edd_currency_symbol($currency = '')
{
    if (empty($currency)) {
        $currency = edd_get_currency();
    }
    switch ($currency) {
        case "GBP":
            $symbol = '&pound;';
            break;
        case "BRL":
            $symbol = 'R&#36;';
            break;
        case "EUR":
            $symbol = '&euro;';
            break;
        case "USD":
        case "AUD":
        case "NZD":
        case "CAD":
        case "HKD":
        case "MXN":
        case "SGD":
            $symbol = '&#36;';
            break;
        case "JPY":
            $symbol = '&yen;';
            break;
        default:
            $symbol = $currency;
            break;
    }
    return apply_filters('edd_currency_symbol', $symbol, $currency);
}
				<th scope="row" valign="top">
					<label for="edd-amount"><?php 
_e('Amount', 'edd');
?>
</label>
				</th>
				<td>
					<input type="text" id="edd-amount" name="amount" value="<?php 
echo esc_attr(edd_get_discount_amount($discount_id));
?>
" style="width: 40px;"/>
					<p class="description edd-amount-description"<?php 
echo $flat_display;
?>
><?php 
printf(__('Enter the discount amount in %s', 'edd'), edd_get_currency());
?>
</p>
					<p class="description edd-amount-description"<?php 
echo $percent_display;
?>
><?php 
_e('Enter the discount percentage. 10 = 10%', 'edd');
?>
</p>
				</td>
			</tr>
			<?php 
do_action('edd_edit_discount_form_before_products', $discount_id, $discount);
?>
			<tr>
/**
 * Return EDD Currency Base Currency 
 *
 * Handles to return edd currency base currency
 * chosen in edd currrency converter options
 * 
 * @package Easy Digital Downloads - Currency Converter
 * @since 1.0.1
 **/
function edd_currency_get_base_currency()
{
    global $edd_options;
    $base_currency = edd_get_currency();
    //check base currency is set and not empty in currency converter plugin
    if (isset($edd_options['curr_base_currency']) && !empty($edd_options['curr_base_currency'])) {
        $base_currency = $edd_options['curr_base_currency'];
    }
    //end if
    //return base currency
    return $base_currency;
}
 /**
  * Process the purchase and create the charge in Amazon
  *
  * @access public
  * @since  2.4
  * @param  $purchase_data array Cart details
  * @return void
  */
 public function process_purchase($purchase_data)
 {
     if (empty($purchase_data['post_data']['edd_amazon_reference_id'])) {
         edd_set_error('missing_reference_id', __('Missing Reference ID, please try again', 'edd'));
     }
     $errors = edd_get_errors();
     if ($errors) {
         edd_send_back_to_checkout('?payment-mode=amazon');
     }
     $args = apply_filters('edd_amazon_charge_args', array('merchant_id' => edd_get_option('amazon_seller_id', ''), 'amazon_reference_id' => $purchase_data['post_data']['edd_amazon_reference_id'], 'authorization_reference_id' => $purchase_data['purchase_key'], 'charge_amount' => $purchase_data['price'], 'currency_code' => edd_get_currency(), 'charge_note' => html_entity_decode(edd_get_purchase_summary($purchase_data, false)), 'charge_order_id' => $purchase_data['purchase_key'], 'store_name' => remove_accents(wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)), 'transaction_timeout' => 0), $purchase_data);
     $args['platform_id'] = 'A3JST9YM1SX7LB';
     $charge = $this->client->charge($args);
     if (200 == $charge->response['Status']) {
         $charge = new ResponseParser($charge->response);
         $charge = $charge->toArray();
         $status = $charge['AuthorizeResult']['AuthorizationDetails']['AuthorizationStatus']['State'];
         if ('Declined' === $status) {
             $reason = $charge['AuthorizeResult']['AuthorizationDetails']['AuthorizationStatus']['ReasonCode'];
             edd_set_error('payment_declined', sprintf(__('Your payment could not be authorized, please try a different payment method. Reason: %s', 'edd'), $reason));
             edd_send_back_to_checkout('?payment-mode=amazon&amazon_reference_id=' . $purchase_data['post_data']['edd_amazon_reference_id']);
         }
         // Setup payment data to be recorded
         $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => $this->gateway_id, 'status' => 'pending');
         $payment_id = edd_insert_payment($payment_data);
         $authorization_id = $charge['AuthorizeResult']['AuthorizationDetails']['AmazonAuthorizationId'];
         $capture_id = str_replace('-A', '-C', $authorization_id);
         $reference_id = sanitize_text_field($_POST['edd_amazon_reference_id']);
         // Confirm the capture was completed
         $capture = $this->client->getCaptureDetails(array('merchant_id' => edd_get_option('amazon_seller_id', ''), 'amazon_capture_id' => $capture_id));
         $capture = new ResponseParser($capture->response);
         $capture = $capture->toArray();
         // Check capture status
         edd_update_payment_meta($payment_id, '_edd_amazon_authorization_id', $authorization_id);
         edd_update_payment_meta($payment_id, '_edd_amazon_capture_id', $capture_id);
         edd_set_payment_transaction_id($payment_id, $reference_id);
         edd_update_payment_status($payment_id, 'publish');
         // Empty the shopping cart
         edd_empty_cart();
         edd_send_to_success_page();
     } else {
         // Set an error
         edd_set_error('amazon_error', sprintf(__('There was an issue processing your payment. Amazon error: %s', 'edd'), print_r($charge, true)));
         edd_send_back_to_checkout('?payment-mode=amazon&amazon_reference_id=' . $purchase_data['post_data']['edd_amazon_reference_id']);
     }
 }
/**
 * Process PayPal Purchase
 *
 * @since 1.0
 * @param array   $purchase_data Purchase Data
 * @return void
 */
function edd_process_paypal_purchase($purchase_data)
{
    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'edd-gateway')) {
        wp_die(__('Nonce verification has failed', 'edd'), __('Error', 'edd'), array('response' => 403));
    }
    // Collect payment data
    $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => 'paypal', 'status' => !empty($purchase_data['buy_now']) ? 'private' : 'pending');
    // Record the pending payment
    $payment = edd_insert_payment($payment_data);
    // Check payment
    if (!$payment) {
        // Record the error
        edd_record_gateway_error(__('Payment Error', 'edd'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'edd'), json_encode($payment_data)), $payment);
        // Problems? send back
        edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
    } else {
        // Only send to PayPal if the pending payment is created successfully
        $listener_url = add_query_arg('edd-listener', 'IPN', home_url('index.php'));
        // Get the success url
        $return_url = add_query_arg(array('payment-confirmation' => 'paypal', 'payment-id' => $payment), get_permalink(edd_get_option('success_page', false)));
        // Get the PayPal redirect uri
        $paypal_redirect = trailingslashit(edd_get_paypal_redirect()) . '?';
        // Setup PayPal arguments
        $paypal_args = array('business' => edd_get_option('paypal_email', false), 'email' => $purchase_data['user_email'], 'first_name' => $purchase_data['user_info']['first_name'], 'last_name' => $purchase_data['user_info']['last_name'], 'invoice' => $purchase_data['purchase_key'], 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => edd_get_currency(), 'charset' => get_bloginfo('charset'), 'custom' => $payment, 'rm' => '2', 'return' => $return_url, 'cancel_return' => edd_get_failed_transaction_uri('?payment-id=' . $payment), 'notify_url' => $listener_url, 'page_style' => edd_get_paypal_page_style(), 'cbt' => get_bloginfo('name'), 'bn' => 'EasyDigitalDownloads_SP');
        if (!empty($purchase_data['user_info']['address'])) {
            $paypal_args['address1'] = $purchase_data['user_info']['address']['line1'];
            $paypal_args['address2'] = $purchase_data['user_info']['address']['line2'];
            $paypal_args['city'] = $purchase_data['user_info']['address']['city'];
            $paypal_args['country'] = $purchase_data['user_info']['address']['country'];
        }
        $paypal_extra_args = array('cmd' => '_cart', 'upload' => '1');
        $paypal_args = array_merge($paypal_extra_args, $paypal_args);
        // Add cart items
        $i = 1;
        foreach ($purchase_data['cart_details'] as $item) {
            $item_amount = round($item['subtotal'] / $item['quantity'] - $item['discount'] / $item['quantity'], 2);
            if ($item_amount <= 0) {
                $item_amount = 0;
            }
            $paypal_args['item_name_' . $i] = stripslashes_deep(html_entity_decode(edd_get_cart_item_name($item), ENT_COMPAT, 'UTF-8'));
            $paypal_args['quantity_' . $i] = $item['quantity'];
            $paypal_args['amount_' . $i] = $item_amount;
            if (edd_use_skus()) {
                $paypal_args['item_number_' . $i] = edd_get_download_sku($item['id']);
            }
            $i++;
        }
        // Calculate discount
        $discounted_amount = 0.0;
        if (!empty($purchase_data['fees'])) {
            $i = empty($i) ? 1 : $i;
            foreach ($purchase_data['fees'] as $fee) {
                if (floatval($fee['amount']) > '0') {
                    // this is a positive fee
                    $paypal_args['item_name_' . $i] = stripslashes_deep(html_entity_decode(wp_strip_all_tags($fee['label']), ENT_COMPAT, 'UTF-8'));
                    $paypal_args['quantity_' . $i] = '1';
                    $paypal_args['amount_' . $i] = edd_sanitize_amount($fee['amount']);
                    $i++;
                } else {
                    // This is a negative fee (discount)
                    $discounted_amount += abs($fee['amount']);
                }
            }
        }
        if ($discounted_amount > '0') {
            $paypal_args['discount_amount_cart'] = edd_sanitize_amount($discounted_amount);
        }
        // Add taxes to the cart
        if (edd_use_taxes()) {
            $paypal_args['tax_cart'] = edd_sanitize_amount($purchase_data['tax']);
        }
        $paypal_args = apply_filters('edd_paypal_redirect_args', $paypal_args, $purchase_data);
        // Build query
        $paypal_redirect .= http_build_query($paypal_args);
        // Fix for some sites that encode the entities
        $paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
        // Get rid of cart contents
        edd_empty_cart();
        // Redirect to PayPal
        wp_redirect($paypal_redirect);
        exit;
    }
}
Ejemplo n.º 13
0
 /**
  * Process voguepay Purchase
  * @global $edd_options Array of all the EDD Options
  * @param array   $purchase_data Purchase Data
  * @return void
  */
 function process_voguepay_purchase($purchase_data)
 {
     global $edd_options;
     if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'edd-gateway')) {
         wp_die(__('Nonce verification has failed', 'edd-voguepay'), __('Error', 'edd-voguepay'), array('response' => 403));
     }
     // Collect payment data
     $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => 'voguepay', 'status' => 'pending');
     // Add contact number if user is logged in.
     // if( is_user_logged_in() ) {
     // $user_ID = get_current_user_id();
     // Add contact number in user meta.
     // update_user_meta( $user_ID, '_edd_user_contact_info', $purchase_data[ 'post_data' ][ 'contact_number' ] );
     // }
     // Record the pending payment
     $payment = edd_insert_payment($payment_data);
     // Check payment
     if (!$payment) {
         // Record the error
         edd_record_gateway_error(__('Payment Error', 'edd-voguepay'), sprintf(__('Payment creation failed before sending buyer to Voguepay. Payment data: %s', 'edd-voguepay'), json_encode($payment_data)), $payment);
         // Problems? send back
         edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
     } else {
         // Only send to voguepay if the pending payment is created successfully
         //$listener_url = add_query_arg( 'edd-listener', 'VOGUEPAY_RESPONSE', home_url( 'index.php' ) );
         // Get the success url
         $listener_url = add_query_arg(array('edd-listener' => 'VOGUEPAY_RESPONSE', 'payment-id' => $payment), home_url('index.php'));
         // Get the voguepay redirect uri
         $voguepay_redirect = trailingslashit($this->get_voguepay_redirect());
         // Merchant ID.
         $merchant_id = $edd_options['v_merchant_id'];
         // Merchant ID.
         $store_id = $edd_options['store_id'];
         // Generate merchant ref ID.
         $merchant_ref = $this->generate_merchant_refID();
         // Checksum Method.
         $checksum_method = 'MD5';
         /* Do currency conversion. */
         // $amount = $this->do_currency_conversion( $purchase_data[ 'price' ] );
         // Round up final amount and convert amount into paisa.
         $amount = $purchase_data['price'];
         //Get server IP address.
         $ip_address = gethostbyname($_SERVER['SERVER_NAME']);
         // String to generate checksum.
         $checksum_string = $edd_options['voguepay_secret_key'] . $merchant_id . '|' . $edd_options['voguepay_apikey'] . '|' . $ip_address . '|' . $merchant_ref . '|' . 'INR' . '|' . $amount . '|' . $checksum_method . '|' . 1;
         // Generate checksum.
         $checksum = md5($checksum_string);
         // Setup voguepay arguments
         $voguepay_args = array('cur' => 'NGN', 'memo' => 'Secure Payment with VoguePay', 'total' => $amount, 'merchant_ref' => $merchant_ref, 'v_merchant_id' => $merchant_id, 'store_id' => $store_id, 'success_url' => get_permalink($edd_options['success_page']), 'fail_url' => edd_get_failed_transaction_uri('?payment-id=' . $payment), 'notify_url' => $listener_url);
         $voguepay_args = apply_filters('edd_voguepay_redirect_args', $voguepay_args, $purchase_data);
         echo '<div align="center"><br /><br /><br />';
         echo "<h3>...Redirecting. Click the image below if not automatically redirected</h3><br /><br /><br />";
         echo '<form action="' . $voguepay_redirect . '" method="POST" name="voguepayForm">';
         foreach ($voguepay_args as $arg => $arg_value) {
             echo '<input type="hidden" name="' . $arg . '" value="' . $arg_value . '">';
         }
         $seyeurl = plugins_url('assets/pay-via-voguepay.png', __FILE__);
         echo '<input type="image" src="' . $seyeurl . '" />';
         echo '</form></div>
               <script language="JavaScript">
                  //  document.voguepayForm.submit();
               </script>';
         die;
     }
 }
 /**
  * Process Shmart Purchase
  * @global $edd_options Array of all the EDD Options
  * @param array   $purchase_data Purchase Data
  * @return void
  */
 function process_shmart_purchase($purchase_data)
 {
     global $edd_options;
     if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'edd-gateway')) {
         wp_die(__('Nonce verification has failed', 'edd-shmart'), __('Error', 'edd-shmart'), array('response' => 403));
     }
     // Collect payment data
     $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => 'shmart', 'status' => 'pending');
     // Add contact number if user is logged in.
     if (is_user_logged_in()) {
         $user_ID = get_current_user_id();
         // Add contact number in user meta.
         update_user_meta($user_ID, '_edd_user_contact_info', $purchase_data['post_data']['contact_number']);
     }
     // Record the pending payment
     $payment = edd_insert_payment($payment_data);
     // Check payment
     if (!$payment) {
         // Record the error
         edd_record_gateway_error(__('Payment Error', 'edd-shmart'), sprintf(__('Payment creation failed before sending buyer to Shmart. Payment data: %s', 'edd-shmart'), json_encode($payment_data)), $payment);
         // Problems? send back
         edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
     } else {
         // Only send to Shmart if the pending payment is created successfully
         //$listener_url = add_query_arg( 'edd-listener', 'SHMART_RESPONSE', home_url( 'index.php' ) );
         // Get the success url
         $listener_url = add_query_arg(array('edd-listener' => 'SHMART_RESPONSE', 'payment-id' => $payment), home_url('index.php'));
         // Get the Shmart redirect uri
         $shmart_redirect = trailingslashit($this->get_shmart_redirect());
         // Merchant ID.
         $merchant_id = $edd_options['shmart_merchant_id'];
         // Generate merchant ref ID.
         $merchant_refID = $this->generate_merchant_ref_ID();
         // Checksum Method.
         $checksum_method = 'MD5';
         /* Do currency conversion. */
         $amount = $this->do_currency_conversion($purchase_data['price']);
         // Round up final amount and convert amount into paisa.
         $amount = ceil($amount) * 100;
         //Get server IP address.
         $ip_address = gethostbyname($_SERVER['SERVER_NAME']);
         // String to generate checksum.
         $checksum_string = $edd_options['shmart_secret_key'] . $merchant_id . '|' . $edd_options['shmart_apikey'] . '|' . $ip_address . '|' . $merchant_refID . '|' . 'INR' . '|' . $amount . '|' . $checksum_method . '|' . 1;
         // Generate checksum.
         $checksum = md5($checksum_string);
         // Setup Shamrt arguments
         $shamrt_args = array('apikey' => $edd_options['shmart_apikey'], 'currency_code' => 'INR', 'amount' => $amount, 'merchant_refID' => $merchant_refID, 'merchant_id' => $merchant_id, 'checksum_method' => $checksum_method, 'checksum' => $checksum, 'ip_address' => $ip_address, 'email' => $purchase_data['user_email'], 'mobileNo' => $purchase_data['post_data']['contact_number'], 'f_name' => $purchase_data['user_info']['first_name'], 'addr' => $purchase_data['user_info']['address']['line1'] . ', ' . $purchase_data['user_info']['address']['line2'], 'city' => $purchase_data['user_info']['address']['city'], 'state' => $purchase_data['user_info']['address']['state'], 'zipcode' => $purchase_data['user_info']['address']['zip'], 'country' => $purchase_data['user_info']['address']['country'], 'show_shipping_addr' => 0, 'rurl' => get_permalink($edd_options['success_page']), 'furl' => edd_get_failed_transaction_uri('?payment-id=' . $payment), 'surl' => $listener_url, 'authorize_user' => 1);
         $shamrt_args = apply_filters('edd_shmart_redirect_args', $shamrt_args, $purchase_data);
         echo '<form action="' . $shmart_redirect . '" method="POST" name="shmartForm">';
         foreach ($shamrt_args as $arg => $arg_value) {
             echo '<input type="hidden" name="' . $arg . '" value="' . $arg_value . '">';
         }
         echo '</form>
               <script language="JavaScript">
                    document.shmartForm.submit();
               </script>';
         die;
     }
 }
 /**
  * Process the credit card form
  *
  * @param array $purchaseDatas
  */
 public function processPayboxPurchase($purchaseDatas)
 {
     $this->purchaseDatas = $purchaseDatas;
     $this->gateway = $purchaseDatas['post_data']['edd-gateway'];
     $paymentDatas = array('price' => $purchaseDatas['price'], 'date' => $purchaseDatas['date'], 'user_email' => $purchaseDatas['user_email'], 'purchase_key' => $purchaseDatas['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchaseDatas['downloads'], 'user_info' => $purchaseDatas['user_info'], 'cart_details' => $purchaseDatas['cart_details'], 'gateway' => 'paybox', 'status' => 'pending');
     // Record the pending payment
     $this->payment = edd_insert_payment($paymentDatas);
     $orderTotal = $purchaseDatas['price'];
     $id = $purchaseDatas['user_info']['id'] . intval($purchaseDatas['subtotal']);
     $cardNumber = $purchaseDatas['card_info']['card_number'];
     $cvv = $purchaseDatas['card_info']['card_cvc'];
     $monthExpire = $purchaseDatas['card_info']['card_exp_month'];
     $yearExpire = $purchaseDatas['card_info']['card_exp_year'];
     $settings = $this->getSettings();
     $url = $settings['preprod'] ? $settings['url_preprod'] : $settings['url_prod'];
     $fields = array('DATEQ' => date('Ydm'), 'TYPE' => '00001', 'NUMQUESTION' => time(), 'MONTANT' => intval($orderTotal), 'SITE' => $settings['site'], 'RANG' => $settings['rang'], 'REFERENCE' => 'test', 'VERSION' => $settings['version'], 'CLE' => $settings['key'], 'IDENTIFIANT' => $settings['id'], 'DEVISE' => '978', 'PORTEUR' => $cardNumber, 'DATEVAL' => str_pad($monthExpire, 2, '0', STR_PAD_LEFT) . substr($yearExpire, 2, 4), 'CVV' => $cvv, 'ACTIVITE' => '024', 'ARCHIVAGE' => 'AXZ130968CT2', 'DIFFERE' => '000', 'NUMAPPEL' => '', 'NUMTRANS' => '', 'AUTORISATION' => '', 'PAYS' => '');
     $this->performPayment($url, $fields);
 }
    /**
     * Show Settings Message
     * 
     * Handles to show settings message
     * 
     * @package Easy Digital Downloads - Currency Converter
     * @since 1.0.0
     **/
    public function edd_currency_admin_notice()
    {
        global $edd_options;
        $errors = array();
        // Check easy digital downlownload pages
        if (isset($_GET['post_type']) && $_GET['post_type'] == 'download') {
            if (isset($edd_options['exchange_rates_method']) && $edd_options['exchange_rates_method'] == 'open_exchange' && isset($edd_options['exchange_app_id']) && empty($edd_options['exchange_app_id'])) {
                $errors[] = '<li><p><strong>' . __('Easy Digital Download - Currency Converter can not be activated on the front-side because you have selected Exchange Rates Method as Open Exchange Rates and not added it\'s APP ID.', 'eddcurrency') . '</strong></p></li>';
            }
            if (!edd_currency_check_base_currency_has_rate()) {
                $base_currency_code = edd_get_currency();
                $errors[] = '<li><p><strong>' . __('Easy Digital Download base currency (', 'eddcurrency') . $base_currency_code . __(') must have an exchange rate.', 'eddcurrency') . '</strong></p>';
            }
            if (!empty($errors)) {
                ?>
				<div class="error" id="updated">
			        <ol>
			        	<?php 
                echo implode('', $errors);
                ?>
			        </ol>
			    </div>
			    <?php 
            }
        }
    }
Ejemplo n.º 17
0
/**
 * Confirm the Payment through IPN
 *
 */
function edds_confirm_payza_payment()
{
    global $edd_options;
    if (isset($_GET['edd-listener']) && $_GET['edd-listener'] === 'PAYZA_IPN') {
        if (isset($_POST['token'])) {
            require_once EDD_PAYZA_PLUGIN_DIR . '/payza.gateway.php';
            $ipn_handler = new wp_payza_ipn(edd_get_currency(), true);
            $transaction_id = $ipn_handler->handle_ipn($_POST['token']);
            if ($transaction_id) {
                edd_update_payment_status($transaction_id, 'publish');
            }
        }
    }
}
 /**
  * Setup the currency code
  *
  * @since  2.5
  * @param  array $payment_meta The payment meta
  * @return string              The currency for the payment
  */
 private function setup_currency()
 {
     $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : edd_get_currency();
     return $currency;
 }
function amt_product_data_schemaorg_edd($metatags, $post)
{
    // Price
    $metatags[] = '<meta itemprop="price" content="' . edd_get_download_price($post->ID) . '" />';
    // Currency
    $metatags[] = '<meta itemprop="priceCurrency" content="' . edd_get_currency() . '" />';
    $metatags = apply_filters('amt_product_data_edd_schemaorg', $metatags);
    return $metatags;
}
/**
 * Variable price output
 *
 * Outputs variable pricing options for each download or a specified downloads in a list.
 * The output generated can be overridden by the filters provided or by removing
 * the action and adding your own custom action.
 *
 * @since 1.2.3
 * @param int $download_id Download ID
 * @return void
 */
function edd_purchase_variable_pricing($download_id = 0, $args = array())
{
    global $edd_displayed_form_ids;
    // If we've already generated a form ID for this download ID, append -#
    $form_id = '';
    if ($edd_displayed_form_ids[$download_id] > 1) {
        $form_id .= '-' . $edd_displayed_form_ids[$download_id];
    }
    $variable_pricing = edd_has_variable_prices($download_id);
    if (!$variable_pricing) {
        return;
    }
    $prices = apply_filters('edd_purchase_variable_prices', edd_get_variable_prices($download_id), $download_id);
    // If the price_id passed is found in the variable prices, do not display all variable prices.
    if (false !== $args['price_id'] && isset($prices[$args['price_id']])) {
        return;
    }
    $type = edd_single_price_option_mode($download_id) ? 'checkbox' : 'radio';
    $mode = edd_single_price_option_mode($download_id) ? 'multi' : 'single';
    $schema = edd_add_schema_microdata() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '';
    // Filter the class names for the edd_price_options div
    $css_classes_array = apply_filters('edd_price_options_classes', array('edd_price_options', 'edd_' . esc_attr($mode) . '_mode'), $download_id);
    // Sanitize those class names and form them into a string
    $css_classes_string = implode(array_map('sanitize_html_class', $css_classes_array), ' ');
    if (edd_item_in_cart($download_id) && !edd_single_price_option_mode($download_id)) {
        return;
    }
    do_action('edd_before_price_options', $download_id);
    ?>
	<div class="<?php 
    echo esc_attr(rtrim($css_classes_string));
    ?>
">
		<ul>
			<?php 
    if ($prices) {
        $checked_key = isset($_GET['price_option']) ? absint($_GET['price_option']) : edd_get_default_variable_price($download_id);
        foreach ($prices as $key => $price) {
            echo '<li id="edd_price_option_' . $download_id . '_' . sanitize_key($price['name']) . $form_id . '"' . $schema . '>';
            echo '<label for="' . esc_attr('edd_price_option_' . $download_id . '_' . $key . $form_id) . '">';
            echo '<input type="' . $type . '" ' . checked(apply_filters('edd_price_option_checked', $checked_key, $download_id, $key), $key, false) . ' name="edd_options[price_id][]" id="' . esc_attr('edd_price_option_' . $download_id . '_' . $key . $form_id) . '" class="' . esc_attr('edd_price_option_' . $download_id) . '" value="' . esc_attr($key) . '" data-price="' . edd_get_price_option_amount($download_id, $key) . '"/>&nbsp;';
            $item_prop = edd_add_schema_microdata() ? ' itemprop="description"' : '';
            echo '<span class="edd_price_option_name"' . $item_prop . '>' . esc_html($price['name']) . '</span><span class="edd_price_option_sep">&nbsp;&ndash;&nbsp;</span><span class="edd_price_option_price">' . edd_currency_filter(edd_format_amount($price['amount'])) . '</span>';
            if (edd_add_schema_microdata()) {
                echo '<meta itemprop="price" content="' . esc_attr($price['amount']) . '" />';
                echo '<meta itemprop="priceCurrency" content="' . esc_attr(edd_get_currency()) . '" />';
            }
            echo '</label>';
            do_action('edd_after_price_option', $key, $price, $download_id);
            echo '</li>';
        }
    }
    do_action('edd_after_price_options_list', $download_id, $prices, $type);
    ?>
		</ul>
	</div><!--end .edd_price_options-->
<?php 
    do_action('edd_after_price_options', $download_id);
}
 /**
  * Create sample purchase data for your EDD site
  *
  * ## OPTIONS
  *
  * --number: The number of purchases to create
  * --status=<status>: The status to create purchases as
  * --id=<product_id>: A specific product to create purchase data for
  * --price_id=<price_id>: A price ID of the specified product
  *
  * ## EXAMPLES
  *
  * wp edd payments create --number=10 --status=completed
  * wp edd payments create --number=10 --id=103
  */
 public function payments($args, $assoc_args)
 {
     $error = false;
     // At some point we'll likely add another action for payments
     if (!isset($args) || count($args) == 0) {
         $error = __('No action specified, did you mean', 'easy-digital-downloads');
     } elseif (isset($args) && !in_array('create', $args)) {
         $error = __('Invalid action specified, did you mean', 'easy-digital-downloads');
     }
     if ($error) {
         foreach ($assoc_args as $key => $value) {
             $query .= ' --' . $key . '=' . $value;
         }
         WP_CLI::error(sprintf($error . ' %s?', 'wp edd payments create' . $query));
         return;
     }
     // Setup some defaults
     $number = 1;
     $status = 'complete';
     $id = false;
     $price_id = false;
     if (count($assoc_args) > 0) {
         $number = array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : $number;
         $id = array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : $id;
         $price_id = array_key_exists('price_id', $assoc_args) ? absint($assoc_args['id']) : false;
         $tax = array_key_exists('tax', $assoc_args) ? floatval($assoc_args['tax']) : 0;
         $email = array_key_exists('email', $assoc_args) ? sanitize_email($assoc_args['email']) : '*****@*****.**';
         $fname = array_key_exists('fname', $assoc_args) ? sanitize_text_field($assoc_args['fname']) : 'Pippin';
         $lname = array_key_exists('lname', $assoc_args) ? sanitize_text_field($assoc_args['lname']) : 'Williamson';
         // Status requires a bit more validation
         if (array_key_exists('status', $assoc_args)) {
             $stati = array('publish', 'complete', 'pending', 'refunded', 'revoked', 'failed', 'abandoned', 'preapproval', 'cancelled');
             if (in_array($assoc_args['status'], $stati)) {
                 $status = $assoc_args['status'] == 'complete' ? 'publish' : $assoc_args['status'];
             } else {
                 WP_CLI::warning(sprintf(__("Invalid status '%s', defaulting to 'complete'", 'easy-digital-downloads'), $assoc_args['status']));
             }
         }
     }
     // Build the user info array
     $user_info = array('id' => 0, 'email' => $email, 'first_name' => $fname, 'last_name' => $lname, 'discount' => 'none');
     for ($i = 0; $i < $number; $i++) {
         $products = array();
         $total = 0;
         // No specified product
         if (!$id) {
             $products = get_posts(array('post_type' => 'download', 'orderby' => 'rand', 'order' => 'ASC', 'posts_per_page' => 1));
         } else {
             $product = get_post($id);
             if ($product->post_type != 'download') {
                 WP_CLI::error(__('Specified ID is not a product', 'easy-digital-downloads'));
                 return;
             }
             $products[] = $product;
         }
         $cart_details = array();
         // Create the purchases
         foreach ($products as $key => $download) {
             if (!is_a($download, 'WP_Post')) {
                 continue;
             }
             $options = array();
             $final_downloads = array();
             // Deal with variable pricing
             if (edd_has_variable_prices($download->ID)) {
                 $prices = edd_get_variable_prices($download->ID);
                 if (false === $price_id || !array_key_exists($price_id, (array) $prices)) {
                     $price_id = rand(0, count($prices) - 1);
                 }
                 $item_price = $prices[$price_id]['amount'];
                 $options['price_id'] = $price_id;
             } else {
                 $item_price = edd_get_download_price($download->ID);
             }
             $item_number = array('id' => $download->ID, 'quantity' => 1, 'options' => $options);
             $cart_details[$key] = array('name' => $download->post_title, 'id' => $download->ID, 'item_number' => $item_number, 'item_price' => edd_sanitize_amount($item_price), 'subtotal' => edd_sanitize_amount($item_price), 'price' => edd_sanitize_amount($item_price), 'quantity' => 1, 'discount' => 0, 'tax' => $tax);
             $final_downloads[$key] = $item_number;
             $total += $item_price;
         }
         $purchase_data = array('price' => edd_sanitize_amount($total), 'tax' => 0, 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $email, 'user_info' => $user_info, 'currency' => edd_get_currency(), 'downloads' => $final_downloads, 'cart_details' => $cart_details, 'status' => 'pending');
         $payment_id = edd_insert_payment($purchase_data);
         remove_action('edd_complete_purchase', 'edd_trigger_purchase_receipt', 999);
         if ($status != 'pending') {
             edd_update_payment_status($payment_id, $status);
         }
     }
     WP_CLI::success(sprintf(__('Created %s payments', 'easy-digital-downloads'), $number));
     return;
 }
Ejemplo n.º 22
0
/**
 * Get system info
 *
 * @since       2.0
 * @access      public
 * @global      object $wpdb Used to query the database using the WordPress Database API
 * @global      array $edd_options Array of all EDD options
 * @return      string $return A string containing the info to output
 */
function edd_tools_sysinfo_get()
{
    global $wpdb, $edd_options;
    if (!class_exists('Browser')) {
        require_once EDD_PLUGIN_DIR . 'includes/libraries/browser.php';
    }
    $browser = new Browser();
    // Get theme info
    if (get_bloginfo('version') < '3.4') {
        $theme_data = get_theme_data(get_stylesheet_directory() . '/style.css');
        $theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
    } else {
        $theme_data = wp_get_theme();
        $theme = $theme_data->Name . ' ' . $theme_data->Version;
    }
    // Try to identify the hosting provider
    $host = edd_get_host();
    $return = '### Begin System Info ###' . "\n\n";
    // Start with the basics...
    $return .= '-- Site Info' . "\n\n";
    $return .= 'Site URL:                 ' . site_url() . "\n";
    $return .= 'Home URL:                 ' . home_url() . "\n";
    $return .= 'Multisite:                ' . (is_multisite() ? 'Yes' : 'No') . "\n";
    $return = apply_filters('edd_sysinfo_after_site_info', $return);
    // Can we determine the site's host?
    if ($host) {
        $return .= "\n" . '-- Hosting Provider' . "\n\n";
        $return .= 'Host:                     ' . $host . "\n";
        $return = apply_filters('edd_sysinfo_after_host_info', $return);
    }
    // The local users' browser information, handled by the Browser class
    $return .= "\n" . '-- User Browser' . "\n\n";
    $return .= $browser;
    $return = apply_filters('edd_sysinfo_after_user_browser', $return);
    // WordPress configuration
    $return .= "\n" . '-- WordPress Configuration' . "\n\n";
    $return .= 'Version:                  ' . get_bloginfo('version') . "\n";
    $return .= 'Language:                 ' . (defined('WPLANG') && WPLANG ? WPLANG : 'en_US') . "\n";
    $return .= 'Permalink Structure:      ' . (get_option('permalink_structure') ? get_option('permalink_structure') : 'Default') . "\n";
    $return .= 'Active Theme:             ' . $theme . "\n";
    $return .= 'Show On Front:            ' . get_option('show_on_front') . "\n";
    // Only show page specs if frontpage is set to 'page'
    if (get_option('show_on_front') == 'page') {
        $front_page_id = get_option('page_on_front');
        $blog_page_id = get_option('page_for_posts');
        $return .= 'Page On Front:            ' . ($front_page_id != 0 ? get_the_title($front_page_id) . ' (#' . $front_page_id . ')' : 'Unset') . "\n";
        $return .= 'Page For Posts:           ' . ($blog_page_id != 0 ? get_the_title($blog_page_id) . ' (#' . $blog_page_id . ')' : 'Unset') . "\n";
    }
    // Make sure wp_remote_post() is working
    $request['cmd'] = '_notify-validate';
    $params = array('sslverify' => false, 'timeout' => 60, 'user-agent' => 'EDD/' . EDD_VERSION, 'body' => $request);
    $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params);
    if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
        $WP_REMOTE_POST = 'wp_remote_post() works';
    } else {
        $WP_REMOTE_POST = 'wp_remote_post() does not work';
    }
    $return .= 'Remote Post:              ' . $WP_REMOTE_POST . "\n";
    $return .= 'Table Prefix:             ' . 'Length: ' . strlen($wpdb->prefix) . '   Status: ' . (strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable') . "\n";
    $return .= 'WP_DEBUG:                 ' . (defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set') . "\n";
    $return .= 'Memory Limit:             ' . WP_MEMORY_LIMIT . "\n";
    $return .= 'Registered Post Stati:    ' . implode(', ', get_post_stati()) . "\n";
    $return = apply_filters('edd_sysinfo_after_wordpress_config', $return);
    // EDD configuration
    $return .= "\n" . '-- EDD Configuration' . "\n\n";
    $return .= 'Version:                  ' . EDD_VERSION . "\n";
    $return .= 'Upgraded From:            ' . get_option('edd_version_upgraded_from', 'None') . "\n";
    $return .= 'Test Mode:                ' . (edd_is_test_mode() ? "Enabled\n" : "Disabled\n");
    $return .= 'Ajax:                     ' . (!edd_is_ajax_disabled() ? "Enabled\n" : "Disabled\n");
    $return .= 'Guest Checkout:           ' . (edd_no_guest_checkout() ? "Disabled\n" : "Enabled\n");
    $return .= 'Symlinks:                 ' . (apply_filters('edd_symlink_file_downloads', isset($edd_options['symlink_file_downloads'])) && function_exists('symlink') ? "Enabled\n" : "Disabled\n");
    $return .= 'Download Method:          ' . ucfirst(edd_get_file_download_method()) . "\n";
    $return .= 'Currency Code:            ' . edd_get_currency() . "\n";
    $return .= 'Currency Position:        ' . edd_get_option('currency_position', 'before') . "\n";
    $return .= 'Decimal Separator:        ' . edd_get_option('decimal_separator', '.') . "\n";
    $return .= 'Thousands Separator:      ' . edd_get_option('thousands_separator', ',') . "\n";
    $return = apply_filters('edd_sysinfo_after_edd_config', $return);
    // EDD pages
    $return .= "\n" . '-- EDD Page Configuration' . "\n\n";
    $return .= 'Checkout:                 ' . (!empty($edd_options['purchase_page']) ? "Valid\n" : "Invalid\n");
    $return .= 'Checkout Page:            ' . (!empty($edd_options['purchase_page']) ? get_permalink($edd_options['purchase_page']) . "\n" : "Unset\n");
    $return .= 'Success Page:             ' . (!empty($edd_options['success_page']) ? get_permalink($edd_options['success_page']) . "\n" : "Unset\n");
    $return .= 'Failure Page:             ' . (!empty($edd_options['failure_page']) ? get_permalink($edd_options['failure_page']) . "\n" : "Unset\n");
    $return .= 'Downloads Slug:           ' . (defined('EDD_SLUG') ? '/' . EDD_SLUG . "\n" : "/downloads\n");
    $return = apply_filters('edd_sysinfo_after_edd_pages', $return);
    // EDD gateways
    $return .= "\n" . '-- EDD Gateway Configuration' . "\n\n";
    $active_gateways = edd_get_enabled_payment_gateways();
    if ($active_gateways) {
        $default_gateway_is_active = edd_is_gateway_active(edd_get_default_gateway());
        if ($default_gateway_is_active) {
            $default_gateway = edd_get_default_gateway();
            $default_gateway = $active_gateways[$default_gateway]['admin_label'];
        } else {
            $default_gateway = 'Test Payment';
        }
        $gateways = array();
        foreach ($active_gateways as $gateway) {
            $gateways[] = $gateway['admin_label'];
        }
        $return .= 'Enabled Gateways:         ' . implode(', ', $gateways) . "\n";
        $return .= 'Default Gateway:          ' . $default_gateway . "\n";
    } else {
        $return .= 'Enabled Gateways:         None' . "\n";
    }
    $return = apply_filters('edd_sysinfo_after_edd_gateways', $return);
    // EDD Taxes
    $return .= "\n" . '-- EDD Tax Configuration' . "\n\n";
    $return .= 'Taxes:                    ' . (edd_use_taxes() ? "Enabled\n" : "Disabled\n");
    $return .= 'Tax Rate:                 ' . edd_get_tax_rate() * 100 . "\n";
    $return .= 'Display On Checkout:      ' . (!empty($edd_options['checkout_include_tax']) ? "Displayed\n" : "Not Displayed\n");
    $return .= 'Prices Include Tax:       ' . (edd_prices_include_tax() ? "Yes\n" : "No\n");
    $rates = edd_get_tax_rates();
    if (!empty($rates)) {
        $return .= 'Country / State Rates:    ' . "\n";
        foreach ($rates as $rate) {
            $return .= '                          Country: ' . $rate['country'] . ', State: ' . $rate['state'] . ', Rate: ' . $rate['rate'] . "\n";
        }
    }
    $return = apply_filters('edd_sysinfo_after_edd_taxes', $return);
    // EDD Templates
    $dir = get_stylesheet_directory() . '/edd_templates/*';
    if (is_dir($dir) && count(glob("{$dir}/*")) !== 0) {
        $return .= "\n" . '-- EDD Template Overrides' . "\n\n";
        foreach (glob($dir) as $file) {
            $return .= 'Filename:                 ' . basename($file) . "\n";
        }
        $return = apply_filters('edd_sysinfo_after_edd_templates', $return);
    }
    // WordPress active plugins
    $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
    $plugins = get_plugins();
    $active_plugins = get_option('active_plugins', array());
    foreach ($plugins as $plugin_path => $plugin) {
        if (!in_array($plugin_path, $active_plugins)) {
            continue;
        }
        $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
    }
    $return = apply_filters('edd_sysinfo_after_wordpress_plugins', $return);
    // WordPress inactive plugins
    $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
    foreach ($plugins as $plugin_path => $plugin) {
        if (in_array($plugin_path, $active_plugins)) {
            continue;
        }
        $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
    }
    $return = apply_filters('edd_sysinfo_after_wordpress_plugins_inactive', $return);
    if (is_multisite()) {
        // WordPress Multisite active plugins
        $return .= "\n" . '-- Network Active Plugins' . "\n\n";
        $plugins = wp_get_active_network_plugins();
        $active_plugins = get_site_option('active_sitewide_plugins', array());
        foreach ($plugins as $plugin_path) {
            $plugin_base = plugin_basename($plugin_path);
            if (!array_key_exists($plugin_base, $active_plugins)) {
                continue;
            }
            $plugin = get_plugin_data($plugin_path);
            $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
        }
        $return = apply_filters('edd_sysinfo_after_wordpress_ms_plugins', $return);
    }
    // Server configuration (really just versioning)
    $return .= "\n" . '-- Webserver Configuration' . "\n\n";
    $return .= 'PHP Version:              ' . PHP_VERSION . "\n";
    $return .= 'MySQL Version:            ' . $wpdb->db_version() . "\n";
    $return .= 'Webserver Info:           ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
    $return = apply_filters('edd_sysinfo_after_webserver_config', $return);
    // PHP configs... now we're getting to the important stuff
    $return .= "\n" . '-- PHP Configuration' . "\n\n";
    $return .= 'Safe Mode:                ' . (ini_get('safe_mode') ? 'Enabled' : 'Disabled' . "\n");
    $return .= 'Memory Limit:             ' . ini_get('memory_limit') . "\n";
    $return .= 'Upload Max Size:          ' . ini_get('upload_max_filesize') . "\n";
    $return .= 'Post Max Size:            ' . ini_get('post_max_size') . "\n";
    $return .= 'Upload Max Filesize:      ' . ini_get('upload_max_filesize') . "\n";
    $return .= 'Time Limit:               ' . ini_get('max_execution_time') . "\n";
    $return .= 'Max Input Vars:           ' . ini_get('max_input_vars') . "\n";
    $return .= 'Display Errors:           ' . (ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A') . "\n";
    $return = apply_filters('edd_sysinfo_after_php_config', $return);
    // PHP extensions and such
    $return .= "\n" . '-- PHP Extensions' . "\n\n";
    $return .= 'cURL:                     ' . (function_exists('curl_init') ? 'Supported' : 'Not Supported') . "\n";
    $return .= 'fsockopen:                ' . (function_exists('fsockopen') ? 'Supported' : 'Not Supported') . "\n";
    $return .= 'SOAP Client:              ' . (class_exists('SoapClient') ? 'Installed' : 'Not Installed') . "\n";
    $return .= 'Suhosin:                  ' . (extension_loaded('suhosin') ? 'Installed' : 'Not Installed') . "\n";
    $return = apply_filters('edd_sysinfo_after_php_ext', $return);
    // Session stuff
    $return .= "\n" . '-- Session Configuration' . "\n\n";
    $return .= 'EDD Use Sessions:         ' . (defined('EDD_USE_PHP_SESSIONS') && EDD_USE_PHP_SESSIONS ? 'Enforced' : (EDD()->session->use_php_sessions() ? 'Enabled' : 'Disabled')) . "\n";
    $return .= 'Session:                  ' . (isset($_SESSION) ? 'Enabled' : 'Disabled') . "\n";
    // The rest of this is only relevant is session is enabled
    if (isset($_SESSION)) {
        $return .= 'Session Name:             ' . esc_html(ini_get('session.name')) . "\n";
        $return .= 'Cookie Path:              ' . esc_html(ini_get('session.cookie_path')) . "\n";
        $return .= 'Save Path:                ' . esc_html(ini_get('session.save_path')) . "\n";
        $return .= 'Use Cookies:              ' . (ini_get('session.use_cookies') ? 'On' : 'Off') . "\n";
        $return .= 'Use Only Cookies:         ' . (ini_get('session.use_only_cookies') ? 'On' : 'Off') . "\n";
    }
    $return = apply_filters('edd_sysinfo_after_session_config', $return);
    $return .= "\n" . '### End System Info ###';
    return $return;
}
Ejemplo n.º 23
0
/**
 * Insert Payment
 *
 * @since 1.0
 * @param array $payment_data
 * @return int|bool Payment ID if payment is inserted, false otherwise
 */
function edd_insert_payment($payment_data = array())
{
    if (empty($payment_data)) {
        return false;
    }
    $payment = new EDD_Payment();
    if (is_array($payment_data['cart_details']) && !empty($payment_data['cart_details'])) {
        foreach ($payment_data['cart_details'] as $item) {
            $args = array('quantity' => $item['quantity'], 'price_id' => isset($item['item_number']['options']['price_id']) ? $item['item_number']['options']['price_id'] : null, 'tax' => $item['tax'], 'item_price' => isset($item['item_price']) ? $item['item_price'] : $item['price'], 'fees' => isset($item['fees']) ? $item['fees'] : array(), 'discount' => isset($item['discount']) ? $item['discount'] : 0);
            $options = isset($item['item_number']['options']) ? $item['item_number']['options'] : array();
            $payment->add_download($item['id'], $args, $options);
        }
    }
    $payment->increase_tax(edd_get_cart_fee_tax());
    $gateway = !empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
    $gateway = empty($gateway) && isset($_POST['edd-gateway']) ? $_POST['edd-gateway'] : $gateway;
    $payment->status = !empty($payment_data['status']) ? $payment_data['status'] : 'pending';
    $payment->currency = !empty($payment_data['currency']) ? $payment_data['currency'] : edd_get_currency();
    $payment->user_info = $payment_data['user_info'];
    $payment->gateway = $gateway;
    $payment->user_id = $payment_data['user_info']['id'];
    $payment->email = $payment_data['user_email'];
    $payment->first_name = $payment_data['user_info']['first_name'];
    $payment->last_name = $payment_data['user_info']['last_name'];
    $payment->email = $payment_data['user_info']['email'];
    $payment->ip = edd_get_ip();
    $payment->key = $payment_data['purchase_key'];
    $payment->mode = edd_is_test_mode() ? 'test' : 'live';
    $payment->parent_payment = !empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
    $payment->discounts = !empty($payment_data['user_info']['discount']) ? $payment_data['user_info']['discount'] : array();
    if (isset($payment_data['post_date'])) {
        $payment->date = $payment_data['post_date'];
    }
    if (edd_get_option('enable_sequential')) {
        $number = edd_get_next_payment_number();
        $payment->number = edd_format_payment_number($number);
        update_option('edd_last_payment_number', $number);
    }
    // Clear the user's purchased cache
    delete_transient('edd_user_' . $payment_data['user_info']['id'] . '_purchases');
    $payment->save();
    do_action('edd_insert_payment', $payment->ID, $payment_data);
    if (!empty($payment->ID)) {
        return $payment->ID;
    }
    // Return false if no payment was inserted
    return false;
}
 /**
  * Get discount details for on your EDD site
  *
  * ## OPTIONS
  *
  * --id=<discount_id>: A specific discount ID to retrieve
  *
  * ## EXAMPLES
  *
  * wp edd discounts --id=103
  */
 public function discounts($args, $assoc_args)
 {
     $discount_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
     $discounts = $this->api->get_discounts($discount_id);
     if (isset($discounts['error'])) {
         WP_CLI::error($discounts['error']);
     }
     if (empty($discounts)) {
         WP_CLI::error(__('No discounts found', 'edd'));
         return;
     }
     foreach ($discounts['discounts'] as $discount) {
         WP_CLI::line(WP_CLI::colorize('%G' . $discount['ID'] . '%N'));
         WP_CLI::line(sprintf(__('Name: %s', 'edd'), $discount['name']));
         WP_CLI::line(sprintf(__('Code: %s', 'edd'), $discount['code']));
         if ($discount['type'] == 'percent') {
             $amount = $discount['amount'] . '%';
         } else {
             $amount = edd_format_amount($discount['amount']) . ' ' . edd_get_currency();
         }
         WP_CLI::line(sprintf(__('Amount: %s', 'edd'), $amount));
         WP_CLI::line(sprintf(__('Uses: %s', 'edd'), $discount['uses']));
         WP_CLI::line(sprintf(__('Max Uses: %s', 'edd'), $discount['max_uses'] == '0' ? __('Unlimited', 'edd') : $discount['max_uses']));
         WP_CLI::line(sprintf(__('Start Date: %s', 'edd'), empty($discount['start_date']) ? __('No Start Date', 'edd') : $discount['start_date']));
         WP_CLI::line(sprintf(__('Expiration Date: %s', 'edd'), empty($discount['exp_date']) ? __('No Expiration', 'edd') : $discount['exp_date']));
         WP_CLI::line(sprintf(__('Status: %s', 'edd'), ucwords($discount['status'])));
         WP_CLI::line('');
         if (array_key_exists(0, $discount['product_requirements'])) {
             WP_CLI::line(__('Product Requirements:', 'edd'));
             foreach ($discount['product_requirements'] as $req => $req_id) {
                 WP_CLI::line(sprintf(__('  Product: %s', 'edd'), $req_id));
             }
         }
         WP_CLI::line('');
         WP_CLI::line(sprintf(__('Global Discount: %s', 'edd'), empty($discount['global_discount']) ? 'False' : 'True'));
         WP_CLI::line(sprintf(__('Single Use: %s', 'edd'), empty($discount['single_use']) ? 'False' : 'True'));
         WP_CLI::line('');
     }
 }
				</td>
			</tr>
			<?php 
do_action('edd_add_discount_form_before_amount');
?>
			<tr>
				<th scope="row" valign="top">
					<label for="edd-amount"><?php 
_e('Amount', 'easy-digital-downloads');
?>
</label>
				</th>
				<td>
					<input type="text" id="edd-amount" name="amount" value="" style="width: 40px;"/>
					<p class="description edd-amount-description flat-discount" style="display:none;"><?php 
printf(__('Enter the discount amount in %s', 'easy-digital-downloads'), edd_get_currency());
?>
</p>
					<p class="description edd-amount-description percent-discount"><?php 
_e('Enter the discount percentage. 10 = 10%', 'easy-digital-downloads');
?>
</p>
				</td>
			</tr>
			<?php 
do_action('edd_add_discount_form_before_products');
?>
			<tr>
				<th scope="row" valign="top">
					<label for="edd-products"><?php 
printf(__('%s Requirements', 'easy-digital-downloads'), edd_get_label_singular());
/**
 * Get the currency code a payment was made in
 *
 * @since 2.2
 * @param int $payment_id Payment ID
 * @return string $currency The currency code
 */
function edd_get_payment_currency_code($payment_id = 0)
{
    $meta = edd_get_payment_meta($payment_id);
    $currency = isset($meta['currency']) ? $meta['currency'] : edd_get_currency();
    return apply_filters('edd_payment_currency_code', $currency, $payment_id);
}
Ejemplo n.º 27
0
/**
 * Set the number of decimal places per currency
 *
 * @since 1.4.2
 * @param int $decimals Number of decimal places
 * @return int $decimals
*/
function edd_currency_decimal_filter($decimals = 2)
{
    $currency = edd_get_currency();
    switch ($currency) {
        case 'RIAL':
        case 'JPY':
        case 'TWD':
            $decimals = 0;
            break;
    }
    return apply_filters('edd_currency_decimal_count', $decimals, $currency);
}
 /**
  * Process payment submission
  *
  * @access      public
  * @since       1.0.0
  * @param       array $purchase_data The data for a specific purchase
  * @return      void
  */
 public function process_payment($purchase_data)
 {
     if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'edd-gateway')) {
         wp_die(__('Nonce verification has failed', 'edd-wallet'), __('Error', 'edd-wallet'), array('response' => 403));
     }
     $error = false;
     // Double check that we can afford this item
     $value = edd_wallet()->wallet->balance($purchase_data['user_email']);
     if ($value < $purchase_data['price']) {
         edd_record_gateway_error(__('Wallet Gateway Error', 'edd-wallet'), __('User wallet has insufficient funds.', 'edd-wallet'), 0);
         edd_set_error('wallet_error', __('Insufficient funds.', 'edd-wallet'));
         edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
     }
     $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'status' => 'pending');
     // Record the pending payment
     $payment = edd_insert_payment($payment_data);
     if ($payment) {
         // Update payment status
         edd_update_payment_status($payment, 'publish');
         // Withdraw the funds
         edd_wallet()->wallet->withdraw($purchase_data['user_info']['id'], $payment_data['price'], 'withdrawal', $payment);
         edd_empty_cart();
         edd_send_to_success_page();
     } else {
         edd_record_gateway_error(__('Wallet Gateway Error', 'edd-wallet'), sprintf(__('Payment creation failed while processing a Wallet purchase. Payment data: %s', 'edd-wallet'), json_encode($payment_data)), $payment);
         edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
     }
 }
 /**
  * Plugin Setup (On Activation)
  *
  * Does the initial setup,
  * stest default values for the plugin options.
  *
  * @package Easy Digital Downloads - Currency Converter
  * @since 1.0.0
  **/
 function edd_currency_install()
 {
     global $wpdb, $user_ID, $edd_options;
     //register post type
     edd_currency_reg_create_post_type();
     //IMP Call of Function
     //Need to call when custom post type is being used in plugin
     flush_rewrite_rules();
     //get option for when plugin is activating first time
     $edd_currency_set_option = get_option('edd_currency_set_option');
     //check plugin version option
     if (empty($edd_currency_set_option)) {
         $edd_page = array('post_type' => 'page', 'post_status' => 'publish', 'post_title' => __('Select Currency', 'eddcurrency'), 'post_content' => '[edd_select_currency][/edd_select_currency]', 'post_author' => 1, 'menu_order' => 0, 'comment_status' => 'closed');
         //create main page for plugin
         $edd_currency_page_id = wp_insert_post($edd_page);
         //update currency page option
         update_option('edd_currency_select_currency_page', $edd_currency_page_id);
         $edd_currencies = edd_get_currencies();
         $edd_currency_order_count = 0;
         $edd_currency_orders = array();
         foreach ($edd_currencies as $currency_code => $currency_value) {
             $edd_currency_order_count++;
             $currency_arr = array('post_title' => $currency_code, 'post_content' => $currency_value, 'post_status' => 'publish', 'post_author' => 1, 'menu_order' => $edd_currency_order_count, 'post_type' => EDD_CURRENCY_POST_TYPE);
             //create currency
             $edd_currency_id = wp_insert_post($currency_arr);
             if (!empty($edd_currency_id)) {
                 //check inserted currency id
                 $edd_currency_symbol = edd_currency_get_symbol($currency_code);
                 update_post_meta($edd_currency_id, '_edd_currency_symbol', $edd_currency_symbol);
                 // store cuurency id and order no
                 $edd_currency_orders[$edd_currency_id] = $edd_currency_order_count;
             }
         }
         //update sort order
         update_option('edd_currency_sort_order', $edd_currency_orders);
         //update sort order count
         update_option('edd_currency_sort_order_count', $edd_currency_order_count);
         //update plugin version to option
         update_option('edd_currency_set_option', '1.0');
     }
     //end if to check set option is empty or not
     //check currency set option is equal to 1.0 or not
     if ($edd_currency_set_option == '1.0') {
         //future code will here
     }
     //end if
     /*************** Default Options Saving to Options of EDD Start ***************/
     //create currency page option default
     $currency_page = get_option('edd_currency_select_currency_page');
     $udpopt = false;
     //check exchange rates method is not set
     if (!isset($edd_options['exchange_rates_method'])) {
         $edd_options['exchange_rates_method'] = 'open_exchange';
         $udpopt = true;
     }
     //end if
     //check select currency page is not set
     if (!isset($edd_options['select_currency'])) {
         $edd_options['select_currency'] = $currency_page;
         $udpopt = true;
     }
     //end if
     //check append code enabled is not set
     if (!isset($edd_options['append_code'])) {
         $edd_options['append_code'] = '';
         $udpopt = true;
     }
     //end if
     //check append code enabled is not set
     if (!isset($edd_options['curr_code_position'])) {
         $edd_options['curr_code_position'] = 'after';
         $udpopt = true;
     }
     //end if
     //check replace base currency is not set
     if (!isset($edd_options['replace_base_currency'])) {
         $edd_options['replace_base_currency'] = '';
         $udpopt = true;
     }
     //end if
     //check display cart notification is not set
     if (!isset($edd_options['display_cart_notification'])) {
         $edd_options['display_cart_notification'] = 'yes';
         $udpopt = true;
     }
     //end if
     //check base currency is not set
     if (!isset($edd_options['curr_base_currency'])) {
         $edd_options['curr_base_currency'] = edd_get_currency();
         $udpopt = true;
     }
     //end if
     //check exchange app id is not set
     if (!isset($edd_options['exchange_app_id'])) {
         $edd_options['exchange_app_id'] = '';
         $udpopt = true;
     }
     //end if
     //check exchange rates cache is not set
     if (!isset($edd_options['exchange_rates_cache'])) {
         $edd_options['exchange_rates_cache'] = '60';
         $udpopt = true;
     }
     //end if
     //check currency detection is not set
     if (!isset($edd_options['currency_detection'])) {
         $edd_options['currency_detection'] = 'no';
         $udpopt = true;
     }
     //end if
     //check prompt user detection is not set
     if (!isset($edd_options['prompt_user_detection'])) {
         $edd_options['prompt_user_detection'] = 'no';
         $udpopt = true;
     }
     //end if
     //check need to update the defaults value to options
     if ($udpopt == true) {
         // if any of the settings need to be updated
         update_option('edd_settings', $edd_options);
     }
     /*************** Default Options Saving to Options of EDD End ***************/
 }
Ejemplo n.º 30
0
/**
 * Load Admin Scripts
 *
 * Enqueues the required admin scripts.
 *
 * @since 1.0
 * @global $post
 * @param string $hook Page hook
 * @return void
 */
function edd_load_admin_scripts($hook)
{
    if (!apply_filters('edd_load_admin_scripts', edd_is_admin_page(), $hook)) {
        return;
    }
    global $wp_version, $post;
    $js_dir = EDD_PLUGIN_URL . 'assets/js/';
    $css_dir = EDD_PLUGIN_URL . 'assets/css/';
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    // These have to be global
    wp_register_style('jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), EDD_VERSION);
    wp_enqueue_style('jquery-chosen');
    wp_register_script('jquery-chosen', $js_dir . 'chosen.jquery' . $suffix . '.js', array('jquery'), EDD_VERSION);
    wp_enqueue_script('jquery-chosen');
    wp_register_script('edd-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array('jquery'), EDD_VERSION, false);
    wp_enqueue_script('edd-admin-scripts');
    wp_localize_script('edd-admin-scripts', 'edd_vars', array('post_id' => isset($post->ID) ? $post->ID : null, 'edd_version' => EDD_VERSION, 'add_new_download' => __('Add New Download', 'edd'), 'use_this_file' => __('Use This File', 'edd'), 'quick_edit_warning' => __('Sorry, not available for variable priced products.', 'edd'), 'delete_payment' => __('Are you sure you wish to delete this payment?', 'edd'), 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'edd'), 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'edd'), 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'edd'), 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'edd'), 'resend_receipt' => __('Are you sure you wish to resend the purchase receipt?', 'edd'), 'copy_download_link_text' => __('Copy these links to your clipboard and give them to your customer', 'edd'), 'delete_payment_download' => sprintf(__('Are you sure you wish to delete this %s?', 'edd'), edd_get_label_singular()), 'one_price_min' => __('You must have at least one price', 'edd'), 'one_field_min' => __('You must have at least one field', 'edd'), 'one_download_min' => __('Payments must contain at least one item', 'edd'), 'one_option' => sprintf(__('Choose a %s', 'edd'), edd_get_label_singular()), 'one_or_more_option' => sprintf(__('Choose one or more %s', 'edd'), edd_get_label_plural()), 'numeric_item_price' => __('Item price must be numeric', 'edd'), 'numeric_quantity' => __('Quantity must be numeric', 'edd'), 'currency' => edd_get_currency(), 'currency_sign' => edd_currency_filter(''), 'currency_pos' => edd_get_option('currency_position', 'before'), 'currency_decimals' => edd_currency_decimal_filter(), 'new_media_ui' => apply_filters('edd_use_35_media_ui', 1), 'remove_text' => __('Remove', 'edd'), 'type_to_search' => sprintf(__('Type to search %s', 'edd'), edd_get_label_plural()), 'quantities_enabled' => edd_item_quantities_enabled()));
    wp_enqueue_style('wp-color-picker');
    wp_enqueue_script('wp-color-picker');
    wp_register_style('colorbox', $css_dir . 'colorbox' . $suffix . '.css', array(), '1.3.20');
    wp_enqueue_style('colorbox');
    wp_register_script('colorbox', $js_dir . 'jquery.colorbox-min.js', array('jquery'), '1.3.20');
    wp_enqueue_script('colorbox');
    if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) {
        //call for new media manager
        wp_enqueue_media();
    }
    wp_register_script('jquery-flot', $js_dir . 'jquery.flot' . $suffix . '.js');
    wp_enqueue_script('jquery-flot');
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_script('jquery-ui-dialog');
    $ui_style = 'classic' == get_user_option('admin_color') ? 'classic' : 'fresh';
    wp_register_style('jquery-ui-css', $css_dir . 'jquery-ui-' . $ui_style . $suffix . '.css');
    wp_enqueue_style('jquery-ui-css');
    wp_enqueue_script('media-upload');
    wp_enqueue_script('thickbox');
    wp_enqueue_style('thickbox');
    wp_register_style('edd-admin', $css_dir . 'edd-admin' . $suffix . '.css', EDD_VERSION);
    wp_enqueue_style('edd-admin');
}