/** * This function renders most of the columns in the list table. * * @access public * @since 1.4 * * @param array $payment Contains all the data of the payment * @param string $column_name The name of the column * * @return string Column Name */ public function column_default($payment, $column_name) { switch ($column_name) { case 'amount': $amount = $payment->total; $amount = !empty($amount) ? $amount : 0; $value = edd_currency_filter(edd_format_amount($amount), edd_get_payment_currency_code($payment->ID)); break; case 'date': $date = strtotime($payment->date); $value = date_i18n(get_option('date_format'), $date); break; case 'status': $payment = get_post($payment->ID); $value = edd_get_payment_status($payment, true); break; case 'details': $value = '<a href="' . add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details')) . '">' . __('View Order Details', 'easy-digital-downloads') . '</a>'; break; default: $value = isset($payment->{$column_name}) ? $payment->{$column_name} : ''; break; } return apply_filters('edd_payments_table_column', $value, $payment->ID, $column_name); }
/** * Email template tag: value * The total value of the purchase * * @since 1.0.0 * @param int $payment_id * @return string value */ function edd_wallet_email_tag_value($payment_id) { if (get_post_type($payment_id) == 'edd_payment') { $value = edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment_id)), edd_get_payment_currency_code($payment_id)); } else { $item = edd_wallet()->db->get_customer_wallet_item($payment_id); $value = edd_currency_filter(edd_format_amount($item->amount)); } return html_entity_decode($value, ENT_COMPAT, 'UTF-8'); }
$item = get_post($payment_id); // Sanity check... fail if purchase ID is invalid if (!is_object($item) || $item->post_type != 'edd_payment') { wp_die(__('The specified ID does not belong to a payment. Please try again', 'edd'), __('Error', 'edd')); } $payment_meta = edd_get_payment_meta($payment_id); $transaction_id = esc_attr(edd_get_payment_transaction_id($payment_id)); $cart_items = edd_get_payment_meta_cart_details($payment_id); $user_id = edd_get_payment_user_id($payment_id); $customer_id = edd_get_payment_customer_id($payment_id); $payment_date = strtotime($item->post_date); $unlimited = edd_payment_has_unlimited_downloads($payment_id); $user_info = edd_get_payment_meta_user_info($payment_id); $address = !empty($user_info['address']) ? $user_info['address'] : array('line1' => '', 'line2' => '', 'city' => '', 'country' => '', 'state' => '', 'zip' => ''); $gateway = edd_get_payment_gateway($payment_id); $currency_code = edd_get_payment_currency_code($payment_id); ?> <div class="wrap edd-wrap"> <h2><?php printf(__('Payment %s', 'edd'), $number); ?> </h2> <?php do_action('edd_view_order_details_before', $payment_id); ?> <form id="edd-edit-order-form" method="post"> <?php do_action('edd_view_order_details_form_top', $payment_id); ?> <div id="poststuff"> <div id="edd-dashboard-widgets-wrap">
/** * Loads the dashboard sales widget via ajax * * @since 2.1 * @return void */ function edd_load_dashboard_sales_widget() { if (!current_user_can(apply_filters('edd_dashboard_stats_cap', 'view_shop_reports'))) { die; } $stats = new EDD_Payment_Stats(); ?> <div class="edd_dashboard_widget"> <div class="table table_left table_current_month"> <table> <thead> <tr> <td colspan="2"><?php _e('Current Month', 'edd'); ?> </td> </tr> </thead> <tbody> <tr> <td class="first t monthly_earnings"><?php _e('Earnings', 'edd'); ?> </td> <td class="b b-earnings"><?php echo edd_currency_filter(edd_format_amount($stats->get_earnings(0, 'this_month'))); ?> </td> </tr> <tr> <?php $monthly_sales = $stats->get_sales(0, 'this_month', false, array('publish', 'revoked')); ?> <td class="first t monthly_sales"><?php echo _n('Sale', 'Sales', $monthly_sales, 'edd'); ?> </td> <td class="b b-sales"><?php echo $monthly_sales; ?> </td> </tr> </tbody> </table> <table> <thead> <tr> <td colspan="2"><?php _e('Last Month', 'edd'); ?> </td> </tr> </thead> <tbody> <tr> <td class="first t earnings"><?php echo __('Earnings', 'edd'); ?> </td> <td class="b b-last-month-earnings"><?php echo edd_currency_filter(edd_format_amount($stats->get_earnings(0, 'last_month'))); ?> </td> </tr> <tr> <td class="first t sales"> <?php $last_month_sales = $stats->get_sales(0, 'last_month', false, array('publish', 'revoked')); ?> <?php echo _n('Sale', 'Sales', $last_month_sales, 'edd'); ?> </td> <td class="b b-last-month-sales"> <?php echo $last_month_sales; ?> </td> </tr> </tbody> </table> </div> <div class="table table_right table_today"> <table> <thead> <tr> <td colspan="2"> <?php _e('Today', 'edd'); ?> </td> </tr> </thead> <tbody> <tr> <td class="t sales"><?php _e('Earnings', 'edd'); ?> </td> <td class="last b b-earnings"> <?php $earnings_today = $stats->get_earnings(0, 'today', false); ?> <?php echo edd_currency_filter(edd_format_amount($earnings_today)); ?> </td> </tr> <tr> <td class="t sales"> <?php _e('Sales', 'edd'); ?> </td> <td class="last b b-sales"> <?php $sales_today = $stats->get_sales(0, 'today', false, array('publish', 'revoked')); ?> <?php echo edd_format_amount($sales_today, false); ?> </td> </tr> </tbody> </table> </div> <div class="table table_right table_totals"> <table> <thead> <tr> <td colspan="2"><?php _e('Totals', 'edd'); ?> </td> </tr> </thead> <tbody> <tr> <td class="t earnings"><?php _e('Total Earnings', 'edd'); ?> </td> <td class="last b b-earnings"><?php echo edd_currency_filter(edd_format_amount(edd_get_total_earnings())); ?> </td> </tr> <tr> <td class="t sales"><?php _e('Total Sales', 'edd'); ?> </td> <td class="last b b-sales"><?php echo edd_format_amount(edd_get_total_sales(), false); ?> </td> </tr> </tbody> </table> </div> <div style="clear: both"></div> <?php do_action('edd_sales_summary_widget_after_stats', $stats); ?> <?php $p_query = new EDD_Payments_Query(array('number' => 5, 'status' => 'publish')); $payments = $p_query->get_payments(); if ($payments) { ?> <div class="table recent_purchases"> <table> <thead> <tr> <td colspan="2"> <?php _e('Recent Purchases', 'edd'); ?> <a href="<?php echo admin_url('edit.php?post_type=download&page=edd-payment-history'); ?> "> – <?php _e('View All', 'edd'); ?> </a> </td> </tr> </thead> <tbody> <?php foreach ($payments as $payment) { ?> <tr> <td class="edd_order_label"> <a href="<?php echo add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details')); ?> " title="<?php printf(__('Purchase Details for Payment #%s', 'edd'), $payment->ID); ?> "> <?php echo get_the_title($payment->ID); ?> — <?php echo $payment->user_info['email']; ?> </a> <?php if ($payment->user_info['id'] > 0) { $user = get_user_by('id', $payment->user_info['id']); if ($user) { echo "(" . $user->data->user_login . ")"; } } ?> </td> <td class="edd_order_price"> <a href="<?php echo add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details')); ?> " title="<?php printf(__('Purchase Details for Payment #%s', 'edd'), $payment->ID); ?> "> <span class="edd_price_label"><?php echo edd_currency_filter(edd_format_amount($payment->total), edd_get_payment_currency_code($payment->ID)); ?> </span> </a> </td> </tr> <?php } // End foreach ?> </tbody> </table> </div> <?php } // End if ?> <?php do_action('edd_sales_summary_widget_after_purchases', $payments); ?> </div> <?php die; }
/** * Refund a charge in Amazon * * @access public * @since 2.4 * @param $payment_id int The ID number of the payment being refunded * @return string */ private function refund($payment_id = 0) { $refund = $this->client->refund(array('merchant_id' => edd_get_option('amazon_seller_id', ''), 'amazon_capture_id' => edd_get_payment_meta($payment_id, '_edd_amazon_capture_id', true), 'refund_reference_id' => md5(edd_get_payment_key($payment_id) . '-refund'), 'refund_amount' => edd_get_payment_amount($payment_id), 'currency_code' => edd_get_payment_currency_code($payment_id))); if (200 == $refund->response['Status']) { $refund = new ResponseParser($refund->response); $refund = $refund->toArray(); $reference_id = $refund['RefundResult']['RefundDetails']['RefundReferenceId']; $status = $refund['RefundResult']['RefundDetails']['RefundStatus']['State']; switch ($status) { case 'Declined': $code = $refund['RefundResult']['RefundDetails']['RefundStatus']['ReasonCode']; $note = __('Refund declined in Amazon. Refund ID: %s', 'edd'); break; case 'Completed': $refund_id = $refund['RefundResult']['RefundDetails']['AmazonRefundId']; $note = sprintf(__('Refund completed in Amazon. Refund ID: %s', 'edd'), $refund_id); break; case 'Pending': $note = sprintf(__('Refund initiated in Amazon. Reference ID: %s', 'edd'), $reference_id); break; } edd_insert_payment_note($payment_id, $note); } else { edd_insert_payment_note($payment_id, __('Refund request failed in Amazon.', 'edd')); } }
/** * Retrieves taxed amount for payment and then returns a full formatted amount * This function essentially calls edd_get_payment_tax() * * @since 1.3.3 * @see edd_get_payment_tax() * @param int $payment_id Payment ID * @param bool $payment_meta Payment Meta provided? (default: false) * @return string $subtotal Fully formatted payment subtotal */ function edd_payment_tax($payment_id = 0, $payment_meta = false) { $tax = edd_get_payment_tax($payment_id, $payment_meta); return edd_currency_filter(edd_format_amount($tax), edd_get_payment_currency_code($payment_id)); }
/** * Email template tag: price * The total price of the purchase * * @param int $payment_id * * @return string price */ function edd_email_tag_price($payment_id) { $price = edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment_id)), edd_get_payment_currency_code($payment_id)); return html_entity_decode($price, ENT_COMPAT, 'UTF-8'); }
public function cryptocoin_payment($payment) { global $gourl; if (!is_object($payment) || edd_get_payment_gateway($payment->ID) != "gourl") { return true; } // Current Order Details $status = $payment->post_status; $amount = edd_get_payment_amount($payment->ID); $currency = edd_get_payment_currency_code($payment->ID); $userID = edd_get_payment_user_id($payment->ID); $orderID = "order" . $payment->ID; // file shortcode-receipt.php // filter 'edd_payment_receipt_before' inside <table> echo '</thead></table>'; if (!$payment || !$payment->ID) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . __('The GoUrl payment plugin was called to process a payment but could not retrieve the order details. Cannot continue!', GOURLEDD) . "</div>"; } elseif (!in_array($status, array("pending", "publish"))) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__("This order's status is '%s' - it cannot be paid for. Please contact us if you need assistance.", GOURLEDD), $status) . "</div>"; } elseif (!class_exists('gourlclass') || !defined('GOURL') || !is_object($gourl)) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__("Please try a different payment method. Admin need to install and activate wordpress plugin <a href='%s'>GoUrl Bitcoin Gateway for Wordpress</a> to accept Bitcoin/Altcoin Payments online.", GOURLEDD), "https://gourl.io/bitcoin-wordpress-plugin.html") . "</div>"; } elseif (!$this->payments || !$this->defcoin || true === version_compare(EDD_VERSION, '2.4.2', '<') || true === version_compare(GOURL_VERSION, '1.3.4', '<') || array_key_exists($currency, $this->coin_names) && !array_key_exists($currency, $this->payments)) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__('Sorry, but there was an error processing your order. Please try a different payment method or contact us if you need assistance (GoUrl Bitcoin Plugin not configured / %s not activated).', GOURLEDD), !$this->payments || !$this->defcoin || !isset($this->coin_names[$currency]) ? $this->title : $this->coin_names[$currency]) . "</div>"; } else { $plugin = "gourledd"; $period = "NOEXPIRY"; $language = $this->deflang; $coin = $this->coin_names[$this->defcoin]; $affiliate_key = 'gourl'; $crypto = array_key_exists($currency, $this->coin_names); if (!$userID) { $userID = "guest"; } // allow guests to make checkout (payments) if (!$userID) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div align='center'><a href='" . wp_login_url(get_permalink()) . "'>\n\t\t\t\t\t\t\t<img style='border:none;box-shadow:none;' title='" . __('You need first to login or register on the website to make Bitcoin/Altcoin Payments', GOURLEDD) . "' vspace='10'\n\t\t\t\t\t\t\tsrc='" . $gourl->box_image() . "' border='0'></a></div>"; } elseif ($amount <= 0) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__("This order's amount is %s - it cannot be paid for. Please contact us if you need assistance.", GOURLEDD), $amount . " " . $currency) . "</div>"; } else { // Exchange (optional) // -------------------- if ($currency != "USD" && !$crypto) { $amount = gourl_convert_currency($currency, "USD", $amount); if ($amount <= 0) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__('Sorry, but there was an error processing your order. Please try later or use a different payment method. System cannot receive exchange rates for %s/USD from Google Finance', GOURLEDD), $currency) . "</div>"; } else { $currency = "USD"; } } if (!$crypto) { $amount = $amount * $this->emultiplier; } // Payment Box // ------------------ if ($amount > 0) { // crypto payment gateway $result = $gourl->cryptopayments($plugin, $amount, $currency, $orderID, $period, $language, $coin, $affiliate_key, $userID, $this->iconwidth); if (!isset($result["is_paid"]) || !$result["is_paid"]) { echo '<h3>' . __('Pay Now -', GOURLEDD) . '</h3>' . PHP_EOL; } if ($result["error"]) { echo "<div class='edd-alert edd-alert-error'>" . __("Sorry, but there was an error processing your order. Please try a different payment method.", GOURLEDD) . "<br/>" . $result["error"] . "</div>"; } else { // display payment box or successful payment result echo $result["html_payment_box"]; // payment received if ($result["is_paid"]) { if (false) { echo "<div align='center'>" . sprintf(__('%s Payment ID: #%s', GOURLEDD), ucfirst($result["coinname"]), $result["paymentID"]) . "</div>"; } echo "<br/>"; if ($status == 'pending') { header('Location: ' . $_SERVER['REQUEST_URI']); } } } } } } echo '<br/><br/><table id="edd_purchase_receipt"><thead>'; return true; }