PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.3.1
GiveWP – Donation Plugin and Fundraising Platform v2.3.1
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
give / includes / gateways / manual.php

manual.php in GiveWP – Donation Plugin and Fundraising Platform 2.3.1, at includes/gateways/manual.php

76 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Manual Gateway
4 *
5 * @package Give
6 * @subpackage Gateways
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Manual Gateway does not need a CC form, so remove it.
19 *
20 * @since 1.0
21 * @return void
22 */
23 add_action( 'give_manual_cc_form', '__return_false' );
24
25 /**
26 * Processes the donation data and uses the Manual Payment gateway to record
27 * the donation in the Donation History
28 *
29 * @since 1.0
30 *
31 * @param array $purchase_data Donation Data
32 *
33 * @return void
34 */
35 function give_manual_payment( $purchase_data ) {
36
37 if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) {
38 wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
39 }
40
41 //Create payment_data array
42 $payment_data = array(
43 'price' => $purchase_data['price'],
44 'give_form_title' => $purchase_data['post_data']['give-form-title'],
45 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ),
46 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '',
47 'date' => $purchase_data['date'],
48 'user_email' => $purchase_data['user_email'],
49 'purchase_key' => $purchase_data['purchase_key'],
50 'currency' => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ),
51 'user_info' => $purchase_data['user_info'],
52 'status' => 'pending'
53 );
54 // Record the pending payment
55 $payment = give_insert_payment( $payment_data );
56
57 if ( $payment ) {
58 give_update_payment_status( $payment, 'publish' );
59 give_send_to_success_page();
60 } else {
61 give_record_gateway_error(
62 esc_html__( 'Payment Error', 'give' ),
63 sprintf(
64 /* translators: %s: payment data */
65 esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ),
66 json_encode( $payment_data )
67 ),
68 $payment
69 );
70 // If errors are present, send the user back to the donation page so they can be corrected
71 give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
72 }
73 }
74
75 add_action( 'give_gateway_manual', 'give_manual_payment' );
76