本文整理汇总了PHP中edd_send_back_to_checkout函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_send_back_to_checkout函数的具体用法?PHP edd_send_back_to_checkout怎么用?PHP edd_send_back_to_checkout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_send_back_to_checkout函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edd_process_paytm_gateway_ipn
function edd_process_paytm_gateway_ipn()
{
global $edd_options;
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
return;
}
$payment_id = $_GET['payment_id'];
if (empty($payment_id)) {
edd_send_back_to_checkout('?payment-mode=paytm_gateway');
}
// Fallback just in case post_max_size is lower than needed
if (isset($_POST['ORDERID']) && isset($_POST['RESPCODE'])) {
$order_sent = $_POST['ORDERID'];
$responseDescription = $_POST['RESPMSG'];
if ($_POST['RESPCODE'] == '01') {
// success
$order_sent = $_POST['ORDERID'];
$res_code = $_POST['RESPCODE'];
$responseDescription = $_POST['RESPMSG'];
$checksum_recv = $_POST['CHECKSUMHASH'];
$paramList = $_POST;
$order_amount = $_POST['TXNAMOUNT'];
// code by paytm team
$bool = "FALSE";
$secret_key = $edd_options['paytm_mer_access_key'];
$bool = verifychecksum_e($paramList, $secret_key, $checksum_recv);
if ($bool == "TRUE") {
$payment_meta = edd_get_payment_meta($payment_id);
edd_insert_payment_note($payment_id, sprintf(__('Thank you for your order . Your transaction has been successful. Paytm Transaction ID: %s', 'edd'), $_REQUEST['TXNID']));
edd_set_payment_transaction_id($payment_id, $_REQUEST['TXNID']);
edd_update_payment_status($payment_id, 'complete');
edd_empty_cart();
edd_send_to_success_page();
} else {
edd_record_gateway_error(__('Paytm Error', 'edd'), sprintf(__('Transaction Failed Invalid Checksum', 'edd'), ''), $payment_id);
edd_update_payment_status($payment_id, 'failed');
edd_insert_payment_note($payment_id, sprintf(__('Transaction Failed Invalid Checksum', 'edd'), ''));
wp_redirect('?page_id=6&payment-mode=paytm_gateway');
//edd_send_back_to_checkout( '?payment-mode=paytm_gateway' );
}
} else {
edd_record_gateway_error(__('Paytm Error', 'edd'), sprintf(__('Transaction Failed. %s', 'edd'), $responseDescription), $payment_id);
edd_update_payment_status($payment_id, 'failed');
edd_insert_payment_note($payment_id, sprintf(__('Transaction Failed. %s', 'edd'), $responseDescription));
wp_redirect('?page_id=6&payment-mode=paytm_gateway');
}
} else {
edd_record_gateway_error(__('Paytm Error', 'edd'), sprintf(__('Transaction Failed, No Response ', 'edd'), ''), $payment_id);
edd_update_payment_status($payment_id, 'failed');
edd_insert_payment_note($payment_id, sprintf(__('Transaction Failed, No Response ', 'edd'), ''));
wp_redirect('?page_id=6&payment-mode=paytm_gateway');
}
exit;
}
示例2: edd_manual_payment
/**
* Manual Payment
*
* @access private
* @since 1.0
* @return void
*/
function edd_manual_payment($purchase_data)
{
global $edd_options;
/*
* 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 = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => $edd_options['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);
if ($payment) {
edd_update_payment_status($payment, 'publish');
// empty the shopping cart
edd_empty_cart();
edd_send_to_success_page();
} else {
// 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']);
}
}
示例3: edds_process_payza_payment
/**
* Process the payment through Payza
*
* @param array $purchase_data
*/
function edds_process_payza_payment($purchase_data)
{
global $edd_options;
// record the pending payment
$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');
// Inserts a new payment
$payment = edd_insert_payment($payment_data);
if ($payment) {
require_once 'payza.gateway.php';
// Request details
$merchant_id = trim($edd_options['payza_merchant_id']);
$currency = edd_get_currency();
$return_url = edd_get_success_page_url('?payment-confirmation=payza');
$cancel_url = edd_get_failed_transaction_uri();
$ipn_url = trailingslashit(home_url()) . '?edd-listener=PAYZA_IPN';
// Create a new instance of the mb class
$payza = new wp_payza_gateway($merchant_id, 'item', $currency, $return_url, $cancel_url, $ipn_url, edd_is_test_mode());
// Get a new session ID
$redirect_url = $payza->transaction($payment, $purchase_data['cart_details']);
if ($redirect_url) {
// Redirects the user
wp_redirect($redirect_url);
exit;
} else {
edd_send_back_to_checkout('?payment-mode=payza');
}
} else {
edd_send_back_to_checkout('?payment-mode=payza');
}
}
示例4: 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']);
}
}
示例5: 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;
}
}
示例6: edd_process_paypal_purchase
/**
* Process PayPal Purchase
*
* @since 1.0
* @global $edd_options Array of all the EDD Options
* @param array $purchase_data Purchase Data
* @return void
*/
function edd_process_paypal_purchase($purchase_data)
{
global $edd_options;
// Check there is a gateway name
if (!isset($purchase_data['post_data']['edd-gateway'])) {
return;
}
/*
Purchase data comes in like this:
$purchase_data = array(
'downloads' => array of download IDs,
'tax' => taxed amount on shopping cart
'subtotal' => total price before tax
'price' => total price of cart contents after taxes,
'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,
);
*/
// 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'], '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 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 = trailingslashit(home_url()) . '?edd-listener=IPN';
// Get the success url
$return_url = add_query_arg('payment-confirmation', 'paypal', get_permalink($edd_options['success_page']));
// Get the complete cart cart_summary
$summary = edd_get_purchase_summary($purchase_data, false);
// Get the PayPal redirect uri
$paypal_redirect = trailingslashit(edd_get_paypal_redirect()) . '?';
// Setup PayPal arguments
$paypal_args = array('cmd' => '_xclick', 'amount' => round($purchase_data['price'] - $purchase_data['tax'], 2), 'business' => $edd_options['paypal_email'], 'item_name' => stripslashes_deep(html_entity_decode(wp_strip_all_tags($summary), ENT_COMPAT, 'UTF-8')), 'email' => $purchase_data['user_email'], 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => edd_get_currency(), 'item_number' => $purchase_data['purchase_key'], 'charset' => get_bloginfo('charset'), 'custom' => $payment, 'rm' => '2', 'return' => $return_url, 'cancel_return' => edd_get_failed_transaction_uri(), 'notify_url' => $listener_url, 'page_style' => edd_get_paypal_page_style());
if (edd_use_taxes()) {
$paypal_args['tax'] = $purchase_data['tax'];
}
$paypal_args = apply_filters('edd_paypal_redirect_args', $paypal_args, $purchase_data);
// Build query
$paypal_redirect .= http_build_query($paypal_args);
// Get rid of cart contents
edd_empty_cart();
// Redirect to PayPal
wp_redirect($paypal_redirect);
exit;
}
}
示例7: edd_process_purchase_form
/**
* Process Purchase Form
*
* Handles the purchase form process.
*
* @access private
* @since 1.0
* @version 1.0.8.1
* @return void
*/
function edd_process_purchase_form()
{
// no need to run on admin
if (is_admin()) {
return;
}
// verify the nonce for this action
if (!isset($_POST['edd-nonce']) || !wp_verify_nonce($_POST['edd-nonce'], 'edd-purchase-nonce')) {
return;
}
// make sure the cart isn't empty
$cart = edd_get_cart_contents();
if (empty($cart)) {
wp_die(sprintf(__('Your cart is empty, please return to the %ssite%s and try again.', 'edd'), '<a href="' . esc_url(home_url()) . '" title="' . get_bloginfo('name') . '">', '</a>'), __('Error', 'edd'));
}
// validate the form $_POST data
$valid_data = edd_purchase_form_validate_fields();
// allow themes and plugins to hoook to errors
do_action('edd_checkout_error_checks', $_POST);
// check errors
if (false !== ($errors = edd_get_errors())) {
// we have errors, send back to checkout
edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
exit;
}
// check user
if (false === ($user = edd_get_purchase_form_user($valid_data))) {
// something went wrong when collecting data, send back to checkout
edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
exit;
}
// setup user information
$user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'discount' => $valid_data['discount']);
// setup purchase information
$purchase_data = array('downloads' => edd_get_cart_contents(), 'subtotal' => edd_get_cart_amount(false), 'tax' => edd_get_cart_tax(), 'price' => edd_get_cart_amount(), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s'), 'user_info' => $user_info, 'post_data' => $_POST, 'cart_details' => edd_get_cart_content_details(), 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
// add the user data for hooks
$valid_data['user'] = $user;
// allow themes and plugins to hook before the gateway
do_action('edd_checkout_before_gateway', $_POST, $user_info, $valid_data);
// allow the purchase data to be modified before it is sent to the gateway
$purchase_data = apply_filters('edd_purchase_data_before_gateway', $purchase_data, $valid_data);
// if the total amount in the cart is 0, send to the manaul gateway. This emulates a free download purchase
if ($purchase_data['price'] <= 0) {
// revert to manual
$valid_data['gateway'] = 'manual';
}
// used for showing download links to non logged-in users after purchase, and for other plugins needing purchase data.
edd_set_purchase_session($purchase_data);
// send info to the gateway for payment processing
edd_send_to_gateway($valid_data['gateway'], $purchase_data);
exit;
}
示例8: edd_process_paypal_purchase
/**
* Process PayPal Purchase
*
* @access private
* @since 1.0
* @return void
*/
function edd_process_paypal_purchase($purchase_data)
{
global $edd_options;
// check there is a gateway name
if (!isset($purchase_data['post_data']['edd-gateway'])) {
return;
}
/*
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,
);
*/
// 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_options['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);
// check payment
if (!$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 = trailingslashit(home_url()) . '?edd-listener=IPN';
// get the success url
$return_url = add_query_arg('payment-confirmation', 'paypal', get_permalink($edd_options['success_page']));
// get the complete cart summary
$cart_summary = edd_get_purchase_summary($purchase_data, false);
// get the PayPal redirect uri
$paypal_redirect = trailingslashit(edd_get_paypal_redirect()) . '?';
// setup PayPal arguments
$paypal_args = array('cmd' => '_xclick', 'amount' => $purchase_data['price'], 'business' => $edd_options['paypal_email'], 'item_name' => stripslashes_deep(html_entity_decode($cart_summary, ENT_COMPAT, 'UTF-8')), 'email' => $purchase_data['user_email'], 'no_shipping' => '1', 'shipping' => '0', 'no_note' => '1', 'currency_code' => $edd_options['currency'], 'item_number' => $purchase_data['purchase_key'], 'charset' => get_bloginfo('charset'), 'custom' => $payment, 'rm' => '2', 'return' => $return_url, 'notify_url' => $listener_url);
// build query
$paypal_redirect .= http_build_query(apply_filters('edd_paypal_redirect_args', $paypal_args, $purchase_data));
// get rid of cart contents
edd_empty_cart();
// Redirect to PayPal
wp_redirect($paypal_redirect);
exit;
}
}
示例9: edd_process_purchase_form
/**
* Process Purchase Form
*
* Handles the purchase form process.
*
* @access private
* @since 1.0
* @version 1.0.8.1
* @return void
*/
function edd_process_purchase_form()
{
global $edd_options;
// no need to run on admin
if (is_admin()) {
return;
}
// verify the nonce for this action
if (!isset($_POST['edd-nonce']) || !wp_verify_nonce($_POST['edd-nonce'], 'edd-purchase-nonce')) {
return;
}
// validate the form $_POST data
$valid_data = edd_purchase_form_validate_fields();
// allow themes and plugins to hoook to errors
do_action('edd_checkout_error_checks', $_POST);
// check errors
if (false !== ($errors = edd_get_errors())) {
// we have errors, send back to checkout
edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
exit;
}
// check user
if (false === ($user = edd_get_purchase_form_user($valid_data))) {
// something went wrong when collecting data, send back to checkout
edd_send_back_to_checkout('?payment-mode=' . $valid_data['gateway']);
exit;
}
// setup user information
$user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'discount' => $valid_data['discount']);
// setup purchase information
$purchase_data = array('downloads' => edd_get_cart_contents(), 'price' => edd_get_cart_amount(), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s'), 'user_info' => $user_info, 'post_data' => $_POST, 'cart_details' => edd_get_cart_content_details(), 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
// add the user data for hooks
$valid_data['user'] = $user;
// allow themes and plugins to hook before the gateway
do_action('edd_checkout_before_gateway', $_POST, $user_info, $valid_data);
// allow the purchase data to be modified before it is sent to the gateway
$purchase_data = apply_filters('edd_purchase_data_before_gateway', $purchase_data, $valid_data);
// if the total amount in the cart is 0, send to the manaul gateway. This emulates a free download purchase
if ($purchase_data['price'] <= 0) {
// revert to manual
$valid_data['gateway'] = 'manual';
}
if (isset($edd_options['show_links_on_success'])) {
// used for showing download links to non logged-in users after purchase
edd_set_purchase_session($purchase_data);
}
// send info to the gateway for payment processing
edd_send_to_gateway($valid_data['gateway'], $purchase_data);
exit;
}
示例10: edd_process_paypal_purchase
/**
* Process PayPal Purchase
*
* @access private
* @since 1.0
* @return void
*/
function edd_process_paypal_purchase($purchase_data)
{
global $edd_options;
/*
* 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_options['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) {
// only send to paypal if the pending payment is created successfully
$listener_url = trailingslashit(home_url()) . '?edd-listener=IPN';
$return_url = add_query_arg('payment-confirmation', 'paypal', get_permalink($edd_options['success_page']));
$cart_summary = edd_get_purchase_summary($purchase_data, false);
// one time payment
if (edd_is_test_mode()) {
$paypal_redirect = 'https://www.sandbox.paypal.com/cgi-bin/webscr/?';
} else {
$paypal_redirect = 'https://www.paypal.com/cgi-bin/webscr/?';
}
$paypal_args = array('cmd' => '_xclick', 'amount' => $purchase_data['price'], 'business' => $edd_options['paypal_email'], 'item_name' => $cart_summary, 'email' => $purchase_data['user_email'], 'no_shipping' => '1', 'no_note' => '1', 'currency_code' => $edd_options['currency'], 'item_number' => $purchase_data['purchase_key'], 'charset' => 'UTF-8', 'custom' => $payment, 'rm' => '2', 'return' => $return_url, 'notify_url' => $listener_url);
//var_dump(http_build_query($paypal_args)); exit;
$paypal_redirect .= http_build_query($paypal_args);
//var_dump(urldecode($paypal_redirect)); exit;
// get rid of cart contents
edd_empty_cart();
// Redirect to paypal
wp_redirect($paypal_redirect);
exit;
} else {
// 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']);
}
}
示例11: sofort_process_payment
function sofort_process_payment($purchase_data)
{
global $edd_options;
// check there is a gateway name
if (!isset($purchase_data['post_data']['edd-gateway'])) {
return;
}
// 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_options['currency'], 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'status' => 'pending');
$errors = edd_get_errors();
if ($errors) {
// problems? send back
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
} else {
$payment = edd_insert_payment($payment_data);
// check payment
if (!$payment) {
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
} else {
if (!class_exists('SofortLib')) {
require_once 'library/sofortLib.php';
}
$return_url = add_query_arg('payment-confirmation', 'paypal', get_permalink($edd_options['success_page']));
$Sofort = new SofortLib_Multipay(trim($edd_options['sofort_config_id']));
$Sofort->setSofortueberweisung();
$Sofort->setAmount($purchase_data['price']);
$Sofort->setReason('CartId ' . $payment, $purchase_data['post_data']['edd_first'] . ' ' . $purchase_data['post_data']['edd_last']);
$Sofort->addUserVariable($payment);
$Sofort->setSuccessUrl($return_url);
$Sofort->setAbortUrl(edd_get_failed_transaction_uri());
$Sofort->setTimeoutUrl(edd_get_failed_transaction_uri());
$Sofort->setNotificationUrl(home_url('/?sofort=ipn'));
$Sofort->sendRequest();
if ($Sofort->isError()) {
//PNAG-API didn't accept the data
wp_die($Sofort->getError(), 'Error');
} else {
//buyer must be redirected to $paymentUrl else payment cannot be successfully completed!
$paymentUrl = $Sofort->getPaymentUrl();
edd_empty_cart();
wp_redirect($paymentUrl);
exit;
}
}
}
}
示例12: 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;
}
}
示例13: 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');
}
}
}
示例14: 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']);
}
}
示例15: eddcg_process_payment
/**
* Process the payment
*
* @since 1.0
* @return void
*/
function eddcg_process_payment($purchase_data)
{
global $edd_options;
$purchase_summary = edd_get_purchase_summary($purchase_data);
// setup the payment details
$payment = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => $edd_options['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);
if ($payment) {
edd_cg_send_admin_notice($payment);
edd_empty_cart();
edd_send_to_success_page();
} else {
// 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']);
}
}