本文整理汇总了PHP中edd_update_payment_status函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_update_payment_status函数的具体用法?PHP edd_update_payment_status怎么用?PHP edd_update_payment_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_update_payment_status函数的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: 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']);
}
}
示例4: 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
}
}
示例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');
}
}
}
示例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;
}
}
示例7: performPayment
/**
* Simple wrapper for the api call / response treatement
*
* @param string $url
* @param array $fields
*/
private function performPayment($url, $fields)
{
$result = $this->curlAction($url, $fields);
$result = $this->getDataTransaction($result);
if ($result['CODEREPONSE'] == '00000') {
edd_update_payment_status($this->payment, 'publish');
edd_complete_purchase($this->payment, 'publish', 'pending');
foreach ($this->purchaseDatas['downloads'] as $download) {
$log = edd_record_log('Payment', 'Payment', $download['id'], 'sale');
update_post_meta($log, '_edd_log_payment_id', $this->payment);
}
edd_empty_cart();
edd_send_to_success_page();
} else {
if ($result['CODEREPONSE'] == '00001' || $result['CODEREPONSE'] == '00003') {
$settings = $this->getSettings();
// if the first prod url failed try the second
if (!$settings['preprod'] && $url !== $settings['url_prod_2'] && isset($settings['url_prod_2'])) {
$this->performPayment($settings['url_prod_2'], $fields);
}
edd_record_gateway_error(__('Payment Error', 'edd'), __('Payment gateways unavailable', 'edd'));
edd_send_back_to_checkout('?payment-mode=' . $this->gateway);
} else {
edd_record_gateway_error(__('Payment Error', 'edd'), $result['COMMENTAIRE']);
edd_send_back_to_checkout('?payment-mode=' . $this->gateway);
}
}
}
开发者ID:lounis,项目名称:easy-digital-downloads-paybox-gateway,代码行数:34,代码来源:easy-digital-downloads-paybox-gayteway.php
示例8: status_update
/**
* Update the status of the specified payment
*
* @param Pronamic_Pay_Payment $payment
* @param boolean $can_redirect (optional, defaults to false)
*/
public static function status_update(Pronamic_Pay_Payment $payment, $can_redirect = false)
{
$source_id = $payment->get_source_id();
$data = new Pronamic_WP_Pay_Extensions_EDD_PaymentData($source_id, array());
// Only update if order is not completed
$should_update = edd_get_payment_status($source_id) !== Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH;
// Defaults
$status = null;
$note = null;
$url = $data->get_normal_return_url();
$status = $payment->get_status();
switch ($status) {
case Pronamic_WP_Pay_Statuses::CANCELLED:
$url = $data->get_cancel_url();
break;
case Pronamic_WP_Pay_Statuses::EXPIRED:
if ($should_update) {
edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_ABANDONED);
}
$url = $data->get_error_url();
break;
case Pronamic_WP_Pay_Statuses::FAILURE:
if ($should_update) {
edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_FAILED);
}
$url = $data->get_error_url();
break;
case Pronamic_WP_Pay_Statuses::SUCCESS:
if ($should_update) {
edd_insert_payment_note($source_id, __('Payment completed.', 'pronamic_ideal'));
/*
* @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L36
* @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/admin/payments/view-order-details.php#L199-L206
* @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/payments/functions.php#L1312-L1332
* @see https://github.com/easydigitaldownloads/Easy-Digital-Downloads/blob/2.2.8/includes/gateways/paypal-standard.php#L555-L576
*/
}
edd_update_payment_status($source_id, Pronamic_WP_Pay_Extensions_EDD_EasyDigitalDownloads::ORDER_STATUS_PUBLISH);
edd_empty_cart();
$url = $data->get_success_url();
break;
case Pronamic_WP_Pay_Statuses::OPEN:
if ($should_update) {
edd_insert_payment_note($source_id, __('Payment open.', 'pronamic_ideal'));
}
break;
default:
if ($should_update) {
edd_insert_payment_note($source_id, __('Payment unknown.', 'pronamic_ideal'));
}
break;
}
if ($can_redirect) {
wp_redirect($url, 303);
exit;
}
}
示例9: edd_process_paypal_refund
/**
* Process PayPal IPN Refunds
*
* @since 1.3.4
* @param array $data IPN Data
* @return void
*/
function edd_process_paypal_refund($data, $payment_id = 0)
{
// Collect payment details
if (empty($payment_id)) {
return;
}
if (get_post_status($payment_id) == 'refunded') {
return;
// Only refund payments once
}
$payment_amount = edd_get_payment_amount($payment_id);
$refund_amount = $data['payment_gross'] * -1;
if (number_format((double) $refund_amount, 2) < number_format((double) $payment_amount, 2)) {
edd_insert_payment_note($payment_id, sprintf(__('Partial PayPal refund processed: %s', 'edd'), $data['parent_txn_id']));
return;
// This is a partial refund
}
edd_insert_payment_note($payment_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'edd'), $data['parent_txn_id'], $data['reason_code']));
edd_insert_payment_note($payment_id, sprintf(__('PayPal Refund Transaction ID: %s', 'edd'), $data['txn_id']));
edd_update_payment_status($payment_id, 'refunded');
}
示例10: payments
/**
* 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']) : 'guest@local.dev';
$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);
}
//.........这里部分代码省略.........
示例11: listen_for_pagseguro_ipn
/**
* Listen for PagSeguro IPN
*
* PagSeguro instant payment notifications.
*
* @return void
* @since 1.0
*/
function listen_for_pagseguro_ipn()
{
global $edd_options;
// check for incoming order id
$code = isset($_POST['notificationCode']) && trim($_POST['notificationCode']) !== "" ? trim($_POST['notificationCode']) : null;
$type = isset($_POST['notificationType']) && trim($_POST['notificationType']) !== "" ? trim($_POST['notificationType']) : null;
// check for the edd-listener in the URL request
if (is_null($code) || is_null($type)) {
return;
}
// debug notification
if ($this->debug === true) {
wp_mail(get_bloginfo('admin_email'), __('PagSeguro Gateway Debug 1: Incoming Notification'), var_export($_POST, true));
}
// get credentials
$credentials = $this->get_credentials();
// check credentials have been set
if (is_null($credentials['email']) || is_null($credentials['token'])) {
return;
}
// debug credentials
if ($this->debug === true) {
wp_mail(get_bloginfo('admin_email'), __('PagSeguro Gateway Debug 2: Credentials'), 'OK');
}
// require PagSeguro files
$this->load_pagseguro_sdk();
// verify classes exists
if (!class_exists('PagSeguroNotificationType')) {
return;
}
// debug sdk
if ($this->debug === true) {
wp_mail(get_bloginfo('admin_email'), __('PagSeguro Gateway Debug 3: SDK'), 'OK');
}
// get notification
$notificationType = new PagSeguroNotificationType($type);
$strType = $notificationType->getTypeFromValue();
// debug type
if ($this->debug === true) {
wp_mail(get_bloginfo('admin_email'), __('PagSeguro Gateway Debug 4: Notification Type'), var_export($strType, true));
}
// try to verify the notification
try {
// generate credentials
$credentials = new PagSeguroAccountCredentials($credentials['email'], $credentials['token']);
// notification service
$transaction = PagSeguroNotificationService::checkTransaction($credentials, $code);
// debug check
if ($this->debug === true) {
wp_mail(get_bloginfo('admin_email'), __('PagSeguro Gateway Debug 5: Transaction Check'), 'OK');
}
// get both values
$reference = $transaction->getReference();
$status = $transaction->getStatus();
// check there is an external reference
if (isset($reference) && isset($status)) {
// check for succesful status
if ($status->getValue() == 3) {
// debug status
if ($this->debug === true) {
wp_mail(get_bloginfo('admin_email'), __('PagSeguro Gateway Debug 6: Status Check'), 'OK');
}
// update succesful payment
edd_update_payment_status($reference, 'publish');
} else {
// debug status
if ($this->debug === true) {
wp_mail(get_bloginfo('admin_email'), __('PagSeguro Gateway Debug 6: Status Check'), 'ERROR');
}
}
} else {
// debug reference/status error
if ($this->debug === true) {
wp_mail(get_bloginfo('admin_email'), __('PagSeguro Gateway Debug 8: Reference/Status Check'), 'ERROR');
}
}
} catch (Exception $e) {
wp_mail(get_bloginfo('admin_email'), __('PagSeguro IPN Service Error', 'edd-pagseguro-gateway'), $e->getMessage());
return;
}
}
示例12: mondca_process_payment
function mondca_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_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'gateway' => 'mondca', 'status' => 'pending');
if (!mondca_is_credit_card_number($purchase_data['post_data']['card_number'])) {
edd_set_error('invalid_card_number', __('Credit Card Number is not valid.', 'mondca_patsatech'));
}
if (!mondca_is_correct_expire_date(date("y", strtotime($purchase_data['post_data']['card_exp_month'])), $purchase_data['post_data']['card_exp_year'])) {
edd_set_error('invalid_card_expiry', __('Card Expire Date is not valid.', 'mondca_patsatech'));
}
if (!$purchase_data['post_data']['card_cvc']) {
edd_set_error('invalid_card_cvc', __('Card CVV is not entered.', 'mondca_patsatech'));
}
if (!$purchase_data['post_data']['card_name']) {
edd_set_error('invalid_card_name', __('CardHolder Name is not entered.', 'mondca_patsatech'));
}
if (!$purchase_data['post_data']['card_address']) {
edd_set_error('invalid_card_address', __('Billing Address is not entered.', 'mondca_patsatech'));
}
if (!$purchase_data['post_data']['card_zip']) {
edd_set_error('invalid_card_zip', __('Post Code is not entered.', 'mondca_patsatech'));
}
if (!$purchase_data['post_data']['card_state']) {
edd_set_error('invalid_card_state', __('State is not entered.', 'mondca_patsatech'));
}
if (!$purchase_data['post_data']['card_city']) {
edd_set_error('invalid_card_city', __('City is not entered.', 'mondca_patsatech'));
}
if (!$purchase_data['post_data']['edd_first']) {
edd_set_error('invalid_edd_first', __('First Name is not entered.', 'mondca_patsatech'));
}
if (!$purchase_data['post_data']['edd_last']) {
edd_set_error('invalid_edd_last', __('Last Name is not entered.', 'mondca_patsatech'));
}
$errors = edd_get_errors();
if ($errors) {
// problems? send back
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
} else {
// 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 {
$store_id = $edd_options['mondca_storeid'];
$api_token = $edd_options['mondca_apitoken'];
$type = 'purchase';
//$cust_id = $order->order_key;
$amount = number_format($purchase_data['price'], 2, '.', '');
$pan = $purchase_data['post_data']['card_number'];
$cavv = $purchase_data['post_data']['card_cvc'];
$expiry_date = substr($purchase_data['post_data']['card_exp_year'], -2) . sprintf("%02s", $purchase_data['post_data']['card_exp_month']);
$crypt = '7';
$status_check = 'false';
$stamp = date("YdmHisB");
$orderid = $stamp . '|' . $payment;
/***************** Transactional Associative Array ********************/
//$arr=explode("|",$teststring);
$txnArray = array('type' => $type, 'order_id' => $orderid, 'cust_id' => '', 'amount' => $amount, 'pan' => $pan, 'expdate' => $expiry_date, 'cavv' => $cavv);
/********************** Transaction Object ****************************/
$mpgTxn = new mpgTransaction($txnArray);
/************************ Request Object ******************************/
$mpgRequest = new mpgRequest($mpgTxn);
/*********************** HTTPSPost Object ****************************/
$mpgHttpPost = new mpgHttpsPost($store_id, $api_token, $mpgRequest);
/*************************** Response *********************************/
$mpgResponse = $mpgHttpPost->getMpgResponse();
$txnno = $mpgResponse->getTxnNumber();
$receipt = explode("|", $mpgResponse->getReceiptId());
$respcode = $mpgResponse->getResponseCode();
$refnum = $mpgResponse->getReferenceNum();
$auth = $mpgResponse->getAuthCode();
$mess = $mpgResponse->getMessage();
if ($respcode < '50' && $respcode > '0') {
edd_update_payment_status($payment, 'publish');
edd_insert_payment_note($payment, sprintf(__('Moneris CA Payment %s. The Transaction Id is %s', 'mondca_patsatech'), $mess, $txnno));
edd_empty_cart();
edd_send_to_success_page();
} else {
edd_insert_payment_note($payment, sprintf(__('Transaction Error. Message : %s', 'mondca_patsatech'), $mess));
edd_set_error('error_tranasction_failed', sprintf(__('Transaction Error. Message : %s', 'mondca_patsatech'), $mess));
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
}
}
}
}
示例13: edd_veritrans_notification
function edd_veritrans_notification()
{
global $edd_options;
require_once plugin_dir_path(__FILE__) . '/lib/Veritrans.php';
if (edd_is_test_mode()) {
// set test credentials here
// error_log('masuk test mode'); //debugan
Veritrans_Config::$serverKey = $edd_options['vt_sandbox_api_key'];
Veritrans_Config::$isProduction = false;
} else {
// set test credentials here
// error_log('masuk production mode'); //debugan
Veritrans_Config::$serverKey = $edd_options['vt_production_api_key'];
Veritrans_Config::$isProduction = true;
}
// error_log('serverKey: '.Veritrans_Config::$serverKey); //debugan
// error_log('isProduction: '.Veritrans_Config::$isProduction); //debugan
$notif = new Veritrans_Notification();
// error_log('$notif '.print_r($notif)); //debugan
$transaction = $notif->transaction_status;
$fraud = $notif->fraud_status;
$order_id = $notif->order_id;
// error_log('$order_id '.$order_id); //debugan
// error_log('$fraud '.$fraud); //debugan
// error_log('$transaction '.$transaction); //debugan
if ($transaction == 'capture') {
if ($fraud == 'challenge') {
// TODO Set payment status in merchant's database to 'challenge'
edd_update_payment_status($order_id, 'challenge');
// error_log('challenge gan!'); //debugan
} else {
if ($fraud == 'accept') {
edd_update_payment_status($order_id, 'complete');
// error_log('accepted gan!'); //debugan
}
}
} else {
if ($notif->transaction_status != 'credit_card' && $transaction == 'settlement') {
edd_update_payment_status($order_id, 'complete');
// error_log('accepted gan!'); //debugan
} else {
if ($transaction == 'cancel') {
edd_update_payment_status($order_id, 'cancel');
// error_log('cancelled gan!'); //debugan
} else {
if ($transaction == 'deny') {
edd_update_payment_status($order_id, 'failed');
// error_log('denied gan!'); //debugan
}
}
}
}
}
示例14: sagepay_direct_ipn
function sagepay_direct_ipn()
{
global $edd_options;
if (isset($_REQUEST['MD']) && isset($_REQUEST['PaRes']) && $_GET['sagepay_direct'] == 'ipn') {
$request_array = array('MD' => $_REQUEST['MD'], 'PARes' => $_REQUEST['PaRes'], 'VendorTxCode' => EDD()->session->get('sagepay_vtc'));
$request = http_build_query($request_array);
if ($edd_options['sagepay_direct_mode'] == 'test') {
$gateway_url = 'https://test.sagepay.com/gateway/service/direct3dcallback.vsp';
} else {
if ($edd_options['sagepay_direct_mode'] == 'live') {
$gateway_url = 'https://live.sagepay.com/gateway/service/direct3dcallback.vsp';
}
}
$response = wp_remote_post($gateway_url, array('body' => $request, 'method' => 'POST', 'sslverify' => false));
if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
$resp = array();
$lines = preg_split('/\\r\\n|\\r|\\n/', $response['body']);
foreach ($lines as $line) {
$key_value = preg_split('/=/', $line, 2);
if (count($key_value) > 1) {
$resp[trim($key_value[0])] = trim($key_value[1]);
}
}
if ($resp['Status'] == "OK" || $resp['Status'] == "REGISTERED" || $resp['Status'] == "AUTHENTICATED") {
edd_update_payment_status(EDD()->session->get('sagepay_oid'), 'publish');
edd_set_payment_transaction_id($payment, $resp['VPSTxId']);
edd_empty_cart();
edd_send_to_success_page();
} else {
if ($resp['Status'] == "3DAUTH") {
if ($resp['3DSecureStatus'] == 'OK') {
if (isset($resp['ACSURL']) && isset($resp['MD'])) {
$array = array('PaReq' => $resp['PAReq'], 'MD' => $resp['MD'], 'TermUrl' => trailingslashit(home_url()) . '?sagepay_direct=ipn');
$sagepay_arg_array = array();
foreach ($array as $key => $value) {
$sagepay_arg_array[] = '<input type="hidden" name="' . esc_attr($key) . '" value="' . esc_attr($value) . '" />';
}
echo '<form action="' . $resp['ACSURL'] . '" method="post" name="sagepay_direct_3dsecure_form" >
' . implode('', $sagepay_arg_array) . '
</form>
<b> Please wait while you are being redirected.</b>
<script type="text/javascript" event="onload">
ocument.sagepay_direct_3dsecure_form.submit();
</script>';
}
}
} else {
if (isset($resp['StatusDetail'])) {
edd_set_error('error_tranasction_failed', __('Transaction Failed. ' . $resp['StatusDetail'], 'sagepay_direct_patsatech'));
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
} else {
edd_set_error('error_tranasction_failed', __('Transaction Failed with ' . $resp['Status'] . ' status for Unknown Reason.', 'sagepay_direct_patsatech'));
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
}
}
}
} else {
edd_set_error('error_tranasction_failed', __('Gateway Error. Please Notify the Store Owner about this error.', 'sagepay_direct_patsatech'));
edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
}
}
}
开发者ID:oshadami,项目名称:sagepay-direct-gateway-for-easy-digital-downloads,代码行数:62,代码来源:edd-sagepay-direct.php
示例15: gourledd_gourlcallback
function gourledd_gourlcallback($user_id, $order_id, $payment_details, $box_status)
{
if (!in_array($box_status, array("cryptobox_newrecord", "cryptobox_updated"))) {
return false;
}
if (strpos($order_id, "order") === 0) {
$payment_id = substr($order_id, 5);
} else {
return false;
}
if (!$user_id || $payment_details["status"] != "payment_received") {
return false;
}
$payment = get_post($payment_id);
if (!$payment || !$payment->post_status) {
return false;
}
$coinName = ucfirst($payment_details["coinname"]);
$amount = $payment_details["amount"] . " " . $payment_details["coinlabel"] . "  ( \$" . $payment_details["amountusd"] . " )";
$payID = $payment_details["paymentID"];
$confirmed = $payment_details["is_confirmed"] ? __('Yes', GOURLEDD) : __('No', GOURLEDD);
// a. New Payment Received - Awaiting Transaction Confirmation...
if ($box_status == "cryptobox_newrecord") {
// Save Log
edd_insert_payment_note($payment_id, sprintf(__("<b>%s</b> Payment Received <br/>%s <br/><a href='%s'>Payment ID: %s</a>. <br/>Awaiting network confirmation...", GOURLEDD), __($coinName, GOURLEDD), $amount, GOURL_ADMIN . GOURL . "payments&s=payment_" . $payID, $payID) . ' <br/>');
edd_set_payment_transaction_id($payment_id, $payment_details["tx"]);
}
// b. Existing Payment Confirmed (6+ transaction confirmations)
if ($payment_details["is_confirmed"]) {
// Save Log
edd_insert_payment_note($payment_id, sprintf(__("%s Payment ID: <a href='%s'>%s</a> - <b>Confirmed</b>", GOURLEDD), __($coinName, GOURLEDD), GOURL_ADMIN . GOURL . "payments&s=payment_" . $payID, $payID) . ' <br/>');
}
// c. Update Status to Completed
if ($payment->post_status != 'publish') {
edd_update_payment_status($payment_id, 'publish');
}
return true;
}