PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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 2.3.2 2.30.0 All 255 releases
give / src / TestData / Addons / RecurringDonations / RecurringDonationRepository.php

RecurringDonationRepository.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/TestData/Addons/RecurringDonations/RecurringDonationRepository.php

58 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\TestData\Addons\RecurringDonations;
4
5 /**
6 * Class RecurringDonationRepository
7 * @package Give\TestData\RecurringDonations
8 */
9 class RecurringDonationRepository
10 {
11 /**
12 * @var RecurringDonationFactory
13 */
14 private $donationFactory;
15
16 /**
17 * RecurringDonationRepository constructor.
18 *
19 * @param RecurringDonationFactory $donationFactory
20 */
21 public function __construct(RecurringDonationFactory $donationFactory)
22 {
23 $this->donationFactory = $donationFactory;
24 }
25
26 /**
27 * @param array $donation
28 */
29 public function insertDonation($donation)
30 {
31 global $wpdb;
32
33 $donation = wp_parse_args(
34 apply_filters('give-test-data-recurring-donation-definition', $donation),
35 $this->donationFactory->definition()
36 );
37
38 // Insert donation
39 $wpdb->insert(
40 "{$wpdb->prefix}give_subscriptions",
41 [
42 'customer_id' => $donation['customer_id'],
43 'period' => $donation['period'],
44 'frequency' => 1,
45 'initial_amount' => $donation['initial_amount'],
46 'recurring_amount' => $donation['recurring_amount'],
47 'parent_payment_id' => $donation['parent_payment_id'],
48 'product_id' => $donation['product_id'],
49 'created' => $donation['created'],
50 'expiration' => $donation['expiration'],
51 'status' => $donation['status'],
52 ]
53 );
54
55 do_action('give-test-data-insert-recurring-donation', $wpdb->insert_id, $donation);
56 }
57 }
58