Easy Digital Downloads
  • Package
  • Function
  • Tree

Packages

  • EDD
    • Admin
      • Actions
      • Add-ons
      • Dashboard
      • Discounts
      • Downloads
      • Export
      • Notices
      • Pages
      • Payments
      • Reports
      • Settings
      • System
      • Upgrades
      • Upload
      • Welcome
    • Cart
    • Checkout
    • Classes
      • API
      • Fees
      • HTML
      • Roles
      • Session
    • Emails
    • Functions
      • AJAX
      • Compatibility
      • Errors
      • Formatting
      • Install
      • Login
      • Taxes
      • Templates
    • Gateways
    • Logging
    • Payments
    • Shortcodes
    • Widgets

Functions

  • edd_get_chosen_gateway
  • edd_get_default_gateway
  • edd_get_enabled_payment_gateways
  • edd_get_gateway_admin_label
  • edd_get_gateway_checkout_label
  • edd_get_payment_gateways
  • edd_get_paypal_page_style
  • edd_get_paypal_redirect
  • edd_is_gateway_active
  • edd_listen_for_paypal_ipn
  • edd_load_ajax_gateway
  • edd_manual_payment
  • edd_manual_remove_cc_form
  • edd_no_gateway_error
  • edd_process_paypal_ipn
  • edd_process_paypal_purchase
  • edd_process_paypal_refund
  • edd_process_paypal_web_accept
  • edd_record_gateway_error
  • edd_send_to_gateway
  • edd_show_gateways
 1 <?php
 2 /**
 3  * Manual Gateway
 4  *
 5  * @package     EDD
 6  * @subpackage  Gateways
 7  * @copyright   Copyright (c) 2013, Pippin Williamson
 8  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 9  * @since       1.0
10  */
11 
12 /**
13  * Manual Gateway does not need a CC form, so remove it. This function is only
14  * defined so that the credit card form isn't shown.
15  *
16  * @since 1.0
17  * @return void
18  */
19 function edd_manual_remove_cc_form() {
20     /** We only register the action so that the default CC form is not shown */
21 }
22 add_action( 'edd_manual_cc_form', 'edd_manual_remove_cc_form' );
23 
24 /**
25  * Processes the purchase data and uses the Manual Payment gateway to record
26  * the transaction in the Purchase History
27  *
28  * @since 1.0
29  * @global $edd_options Array of all the EDD Options
30  * @param array $purchase_data Purchase Data
31  * @return void
32 */
33 function edd_manual_payment( $purchase_data ) {
34     global $edd_options;
35 
36     /*
37     * Purchase data comes in like this
38     *
39     $purchase_data = array(
40         'downloads' => array of download IDs,
41         'price' => total price of cart contents,
42         'purchase_key' =>  // Random key
43         'user_email' => $user_email,
44         'date' => date('Y-m-d H:i:s'),
45         'user_id' => $user_id,
46         'post_data' => $_POST,
47         'user_info' => array of user's information and used discount code
48         'cart_details' => array of cart details,
49     );
50     */
51 
52     $payment_data = array(
53         'price'         => $purchase_data['price'],
54         'date'          => $purchase_data['date'],
55         'user_email'    => $purchase_data['user_email'],
56         'purchase_key'  => $purchase_data['purchase_key'],
57         'currency'      => $edd_options['currency'],
58         'downloads'     => $purchase_data['downloads'],
59         'user_info'     => $purchase_data['user_info'],
60         'cart_details'  => $purchase_data['cart_details'],
61         'status'        => 'pending'
62     );
63 
64     // Record the pending payment
65     $payment = edd_insert_payment( $payment_data );
66 
67     if ( $payment ) {
68         edd_update_payment_status( $payment, 'publish' );
69         // Empty the shopping cart
70         edd_empty_cart();
71         edd_send_to_success_page();
72     } else {
73         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 );
74         // If errors are present, send the user back to the purchase page so they can be corrected
75         edd_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['edd-gateway'] );
76     }
77 }
78 add_action( 'edd_gateway_manual', 'edd_manual_payment' );
Easy Digital Downloads API documentation generated by ApiGen 2.8.0