当前位置: 首页>>代码示例>>PHP>>正文


PHP edd_get_currency函数代码示例

本文整理汇总了PHP中edd_get_currency函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_currency函数的具体用法?PHP edd_get_currency怎么用?PHP edd_get_currency使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了edd_get_currency函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gateway_function_to_process_payment

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
    }
}
开发者ID:arturi,项目名称:edd-yandex-kassa,代码行数:34,代码来源:edd-yandex-kassa.php

示例2: edd_manual_payment

/**
 * 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']);
    }
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:42,代码来源:manual.php

示例3: edd_process_paymentwall_purchase

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;
    }
}
开发者ID:vukhacdiep,项目名称:module-edd,代码行数:26,代码来源:edd-paymentwall.php

示例4: pay_vendors

 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;
 }
开发者ID:SelaInc,项目名称:eassignment,代码行数:48,代码来源:class-paypal-masspay.php

示例5: process_payment

 /**
  * 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');
         }
     }
 }
开发者ID:easydigitaldownloads,项目名称:edd-payeezy,代码行数:47,代码来源:edd-payeezy.php

示例6: edd_fd_process_payment

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;
    }
}
开发者ID:nguyenthai2010,项目名称:ngocshop,代码行数:39,代码来源:edd-gateway-firstdata.php

示例7: amt_product_data_jsonld_schemaorg_edd

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;
}
开发者ID:RomualdKarbido,项目名称:Zeroom,代码行数:9,代码来源:amt_extended.php

示例8: edd_currency_symbol

/**
 * 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);
}
开发者ID:berkapavel,项目名称:Easy-Digital-Downloads,代码行数:41,代码来源:misc-functions.php

示例9: _e

				<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>
开发者ID:Bragi26,项目名称:Easy-Digital-Downloads,代码行数:31,代码来源:edit-discount.php

示例10: edd_currency_get_base_currency

/**
 * 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;
}
开发者ID:nguyenthai2010,项目名称:ngocshop,代码行数:21,代码来源:edd-currency-misc-functions.php

示例11: process_purchase

 /**
  * 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']);
     }
 }
开发者ID:EngageWP,项目名称:Easy-Digital-Downloads,代码行数:53,代码来源:amazon-payments.php

示例12: edd_process_paypal_purchase

/**
 * 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;
    }
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:90,代码来源:paypal-standard.php

示例13: process_voguepay_purchase

 /**
  * 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;
     }
 }
开发者ID:jimiejosh,项目名称:edd-vogue-pay,代码行数:71,代码来源:edd-voguepay.php

示例14: process_shmart_purchase

 /**
  * 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;
     }
 }
开发者ID:rtCamp,项目名称:payment-gateway-easydigitaldownloads-shmart,代码行数:65,代码来源:edd-shmart.php

示例15: processPayboxPurchase

 /**
  * 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);
 }
开发者ID:lounis,项目名称:easy-digital-downloads-paybox-gateway,代码行数:23,代码来源:easy-digital-downloads-paybox-gayteway.php


注:本文中的edd_get_currency函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。