Changeset 2921565
- Timestamp:
- 06/05/2023 10:42:21 AM (3 years ago)
- Location:
- bayarcash-givewp
- Files:
-
- 26 edited
-
tags/3.0.0/bayarcash-givewp.php (modified) (2 diffs)
-
tags/3.0.0/includes/helpers.php (modified) (1 diff)
-
tags/3.0.0/includes/load.php (modified) (1 diff)
-
tags/3.0.0/includes/src/Bayarcash.php (modified) (2 diffs)
-
tags/3.0.0/includes/src/FpxApi.php (modified) (1 diff)
-
tags/3.0.0/includes/src/FpxCron.php (modified) (1 diff)
-
tags/3.0.0/includes/src/FpxDatabase.php (modified) (1 diff)
-
tags/3.0.0/includes/src/FpxResponseTransformer.php (modified) (1 diff)
-
tags/3.0.0/includes/src/FpxTransactionStatus.php (modified) (1 diff)
-
tags/3.0.0/includes/src/Givewp.php (modified) (7 diffs)
-
tags/3.0.0/includes/src/PaymentsQuery.php (modified) (1 diff)
-
tags/3.0.0/includes/src/ResponseSanitizer.php (modified) (1 diff)
-
tags/3.0.0/includes/src/ResponseValidator.php (modified) (1 diff)
-
tags/3.0.0/languages/bayarcash-givewp.pot (modified) (3 diffs)
-
trunk/bayarcash-givewp.php (modified) (2 diffs)
-
trunk/includes/src/Bayarcash.php (modified) (2 diffs)
-
trunk/includes/src/FpxApi.php (modified) (1 diff)
-
trunk/includes/src/FpxCron.php (modified) (1 diff)
-
trunk/includes/src/FpxDatabase.php (modified) (1 diff)
-
trunk/includes/src/FpxResponseTransformer.php (modified) (1 diff)
-
trunk/includes/src/FpxTransactionStatus.php (modified) (1 diff)
-
trunk/includes/src/Givewp.php (modified) (7 diffs)
-
trunk/includes/src/PaymentsQuery.php (modified) (1 diff)
-
trunk/includes/src/ResponseSanitizer.php (modified) (1 diff)
-
trunk/includes/vendor/composer (modified) (1 prop)
-
trunk/languages/bayarcash-givewp.pot (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bayarcash-givewp/tags/3.0.0/bayarcash-givewp.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * … … 15 15 * Version: 3.0.0 16 16 * Description: Bayarcash payment plugin for GiveWP 17 * Author: Web Impian Sdn. Bhd.17 * Author: Bayarcash 18 18 * Author URI: https://bayarcash.com/?utm_source=wp-plugins-givewps&utm_campaign=author-uri&utm_medium=wp-dash 19 19 * Requires at least: 5.6 -
bayarcash-givewp/tags/3.0.0/includes/helpers.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/includes/load.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/includes/src/Bayarcash.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * … … 121 121 } 122 122 }); 123 124 // Must define before give_recurring is loaded. 125 add_filter('give_recurring_available_gateways', function ($gateways) { 126 $gateways['bayarcash'] = 'BayarCash\\GiveWP\\Givewp'; 127 128 return $gateways; 129 }); 123 130 } 124 131 -
bayarcash-givewp/tags/3.0.0/includes/src/FpxApi.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/includes/src/FpxCron.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/includes/src/FpxDatabase.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/includes/src/FpxResponseTransformer.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/includes/src/FpxTransactionStatus.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/includes/src/Givewp.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * … … 13 13 \defined('ABSPATH') || exit; 14 14 15 use Exception; 15 16 use Give\Helpers\Form\Utils as FormUtils; 17 use Give_Donor; 18 use Give_Recurring_Subscriber; 19 use Give_Subscription; 16 20 17 21 final class Givewp … … 30 34 $this->form_setups(); 31 35 $this->payment_setups(); 36 $this->subscription_setups(); 32 37 $this->pt->register_cronjob(); 33 38 } … … 213 218 } 214 219 220 private function subscription_setups() 221 { 222 add_action('give_checkout_error_checks', function ($valid_data) { 223 $post_data = give_clean($_POST); 224 if (!empty($post_data['give-gateway']) && 'bayarcash' !== $post_data['give-gateway']) { 225 return; 226 } 227 228 if (!is_user_logged_in() && !empty($post_data['give-form-id'])) { 229 $form_id = absint($post_data['give-form-id']); 230 231 // Only required if email access not on & recurring enabled. 232 if (give_is_form_recurring($form_id) && !give_is_setting_enabled(give_get_option('email_access'))) { 233 // check if form is recurring and create account checkbox should be checked. 234 if (!empty($post_data['_give_is_donation_recurring']) && empty($post_data['give_create_account'])) { 235 give_set_error('recurring_create_account', __('Please tick the create account button if you want to create a subscription donation', 'bayarcash-givewp')); 236 } 237 } 238 } 239 }, 0, 1); 240 241 add_action('give_cancel_subscription', [$this, 'process_cancellation']); 242 add_filter('give_subscription_can_cancel', [$this, 'can_cancel'], 10, 2); 243 add_filter('give_subscription_can_sync', [$this, 'can_sync'], 10, 2); 244 add_filter('give_subscription_can_update', [$this, 'can_update'], 10, 2); 245 add_filter('give_subscription_can_update_subscription', [$this, 'can_update_subscription'], 10, 2); 246 247 add_filter('give_subscription_can_cancel_bayarcash_subscription', [ 248 $this, 249 'can_cancel', 250 ], 10, 2); 251 252 add_action('give_recurring_update_subscription_payment_method', [ 253 $this, 254 'process_payment_method_update', 255 ], 10, 3); 256 257 add_filter('give_subscription_profile_link_bayarcash', [$this, 'link_profile_id'], 10, 2); 258 add_action('give_recurring_update_bayarcash_subscription', [$this, 'update_payment_method'], 10, 2); 259 260 add_action('give_recurring_update_renewal_subscription', [ 261 $this, 262 'process_renewal_subscription_update', 263 ], 10, 3); 264 add_action('give_recurring_update_renewal_bayarcash_subscription', [$this, 'update_subscription'], 10, 2); 265 } 266 215 267 private function endpoint_tokens($form_id) 216 268 { … … 263 315 if (give_get_errors()) { 264 316 give_send_back_to_checkout('?payment-mode=bayarcash'); 317 318 return; 265 319 } 266 320 267 321 unset($data['card_info']); 322 323 $is_recurring = Give_Recurring()->is_donation_recurring($data); 324 325 $buyer_id = !empty($data['user_info']['id']) ? $data['user_info']['id'] : null; 326 $buyer_name = ''; 327 $buyer_email = !empty($data['user_email']) ? $data['user_email'] : ''; 328 $buyer_phone = ''; 329 if (!empty($data['user_info'])) { 330 if (empty($buyer_email)) { 331 $buyer_email = $data['user_info']['email']; 332 } 333 334 $buyer_name = $data['user_info']['title'].' '.$data['user_info']['first_name'].' '.$data['user_info']['last_name']; 335 $buyer_name = trim($buyer_name); 336 } 337 338 $post_data = $data['post_data']; 339 if (empty($buyer_name)) { 340 $buyer_name = $post_data['give_title'].' '.$post_data['give_first'].' '.$post_data['give_last']; 341 $buyer_name = trim($buyer_name); 342 } 343 344 if (empty($buyer_email)) { 345 $buyer_email = $post_data['give_email']; 346 } 347 348 /*if ($is_recurring) { 349 if (empty($buyer_id)) { 350 $subscriber = new Give_Donor($buyer_email); 351 } else { 352 $subscriber = new Give_Donor($buyer_id, true); 353 } 354 355 if (empty($subscriber->id)) { 356 $subscriber->create([ 357 'name' => trim($buyer_name), 358 'email' => $buyer_email, 359 'user_id' => $buyer_id, 360 ]); 361 } 362 }*/ 363 364 $data['user_email'] = $buyer_email; 268 365 269 366 $payment_id = $this->create_payment($data); … … 275 372 } 276 373 374 // Anonymous 375 $is_anonymous = isset($data['post_data']['give_anonymous_donation']) && absint($data['post_data']['give_anonymous_donation']); 376 update_post_meta($payment_id , '_give_anonymous_donation', (int) $is_anonymous); 377 277 378 $amount = $data['price']; 278 379 279 $buyer_name = ''; 280 $buyer_email = !empty($data['user_email']) ? $data['user_email'] : ''; 281 $buyer_phone = ''; 282 if (!empty($data['user_info'])) { 283 if (empty($buyer_email)) { 284 $buyer_email = $data['user_info']['email']; 285 } 286 287 $buyer_name = $data['user_info']['title'].' '.$data['user_info']['first_name'].' '.$data['user_info']['last_name']; 288 $buyer_name = trim($buyer_name); 289 } 290 291 $post_data = $data['post_data']; 292 if (empty($buyer_name)) { 293 $buyer_name = $post_data['give_title'].' '.$post_data['give_first'].' '.$post_data['give_last']; 294 $buyer_name = trim($buyer_name); 295 } 296 297 if (empty($buyer_email)) { 298 $buyer_email = $post_data['give_email']; 299 } 300 301 if (isset($purchase_data['give-form-url'])) { 302 $return_url = $purchase_data['give-form-url']; 380 if (isset($data['give-form-url'])) { 381 $return_url = $data['give-form-url']; 303 382 } else { 304 383 $return_url = site_url('/give-api/bayarcash_gateway/'); … … 595 674 return false; 596 675 } 676 677 public function process_cancellation($data) 678 { 679 // Need the sub ID to proceed. 680 if (empty($data['sub_id'])) { 681 return; 682 } 683 684 /* 685 * Sanity check: 686 * 687 * a) If subscriber is not logged in. 688 * b) email access is not enabled nor active. 689 * c) they don't have an active donation session. 690 */ 691 if ( 692 !is_user_logged_in() 693 && false == Give_Recurring()->subscriber_has_email_access() 694 && !give_get_purchase_session() 695 ) { 696 return; 697 } 698 699 // Get subscription id. 700 $data['sub_id'] = absint($data['sub_id']); 701 702 // Verify the nonce for security. 703 if (!wp_verify_nonce($data['_wpnonce'], "give-recurring-cancel-{$data['sub_id']}")) { 704 wp_die(__('Nonce verification failed.', 'bayarcash-givewp'), __('Error', 'bayarcash-givewp'), ['response' => 403]); 705 } 706 707 $subscription = new Give_Subscription($data['sub_id']); 708 709 if (!$subscription->can_cancel()) { 710 wp_die(__('This subscription cannot be cancelled.', 'bayarcash-givewp'), __('Error', 'bayarcash-givewp'), ['response' => 403]); 711 } 712 713 try { 714 do_action('give_recurring_cancel_'.$subscription->gateway.'_subscription', $subscription, true); 715 716 $subscription->cancel(); 717 718 if (is_admin()) { 719 wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-subscriptions&give-message=cancelled&id='.$subscription->id)); 720 exit; 721 } 722 723 $args = !give_get_errors() ? ['give-message' => 'cancelled'] : []; 724 725 wp_redirect( 726 remove_query_arg( 727 [ 728 '_wpnonce', 729 'give_action', 730 'sub_id', 731 ], 732 add_query_arg($args) 733 ) 734 ); 735 736 exit; 737 } catch (Exception $e) { 738 wp_die($e->getMessage(), __('Error', 'bayarcash-givewp'), ['response' => 403]); 739 } 740 } 741 742 public function can_cancel($ret, $subscription) 743 { 744 return $ret; 745 } 746 747 public function can_sync($ret, $subscription) 748 { 749 return $ret; 750 } 751 752 public function can_update($ret, $subscription) 753 { 754 return $ret; 755 } 756 757 public function can_update_subscription($ret, $subscription) 758 { 759 return $ret; 760 } 761 762 public function update_payment_method($subscriber, $subscription, $data = null) 763 { 764 } 765 766 public function link_profile_id($profile_id, $subscription) 767 { 768 return $profile_id; 769 } 770 771 public function process_payment_method_update($user_id, $subscription_id, $verified) 772 { 773 $subscription = new Give_Subscription($subscription_id); 774 775 if (empty($subscription->id)) { 776 give_set_error('give_recurring_invalid_subscription_id', __('Invalid subscription ID.', 'bayarcash-givewp')); 777 } 778 779 if ('bayarcash' !== $subscription->gateway) { 780 return; 781 } 782 783 if (!$subscription->can_update()) { 784 give_set_error('give_recurring_subscription_not_updated', __('This subscription cannot be updated.', 'bayarcash-givewp')); 785 } 786 787 $subscriber = new Give_Recurring_Subscriber($subscription->customer_id); 788 if (empty($subscriber->id)) { 789 give_set_error('give_recurring_invalid_subscriber', __('Invalid subscriber.', 'bayarcash-givewp')); 790 } 791 792 // Make sure the User doing the update is the user the subscription belongs to 793 if ($user_id !== $subscriber->id) { 794 give_set_error('give_recurring_subscriber_not_match', __('User ID and Subscriber do not match.', 'bayarcash-givewp')); 795 } 796 797 do_action('give_recurring_update_bayarcash_subscription', $subscriber, $subscription); 798 799 $errors = give_get_errors(); 800 801 if (!wp_doing_ajax()) { 802 if (empty($errors)) { 803 $url = add_query_arg(['action' => 'update', 'updated' => true, 'subscription_id' => $subscription->id], give_get_subscriptions_page_uri()); 804 } else { 805 $url = add_query_arg(['action' => 'update', 'subscription_id' => $subscription->id], give_get_subscriptions_page_uri()); 806 } 807 808 wp_safe_redirect($url); 809 exit; 810 } 811 812 if (empty($errors)) { 813 $url = add_query_arg( 814 [ 815 'action' => 'update', 816 'updated' => '1', 817 'status' => 'success', 818 'subscription_id' => $subscription->id, 819 ], 820 give_get_subscriptions_page_uri() 821 ); 822 823 wp_send_json_success(['url' => $url]); 824 } 825 826 $url = add_query_arg( 827 [ 828 'action' => 'update', 829 'subscription_id' => $subscription->id, 830 'status' => 'error', 831 ], 832 give_get_subscriptions_page_uri() 833 ); 834 835 wp_send_json_error(['url' => $url]); 836 } 837 838 public function process_renewal_subscription_update($user_id, $subscription_id, $verified) 839 { 840 $subscription = new Give_Subscription($subscription_id); 841 842 // Bail out, if Gateway not match. 843 if ('bayarcash' !== $subscription->gateway) { 844 return; 845 } 846 847 // Set error if Subscription ID empty. 848 if (empty($subscription->id)) { 849 give_set_error('give_recurring_invalid_subscription_id', __('Invalid subscription ID.', 'bayarcash-givewp')); 850 } 851 852 // Set error if Subscription can not be update. 853 if (!$subscription->can_update_subscription()) { 854 give_set_error('give_recurring_renewal_subscription_not_updated', __('This subscription cannot be updated.', 'bayarcash-givewp')); 855 } 856 857 // Get Subscriber. 858 $subscriber = new Give_Recurring_Subscriber($subscription->customer_id); 859 860 // Set error if Invalid subscriber. 861 if (empty($subscriber->id)) { 862 give_set_error('give_recurring_invalid_subscriber', __('Invalid subscriber.', 'bayarcash-givewp')); 863 } 864 865 // Make sure the User doing the update is the user the subscription belongs to. 866 if ($user_id !== $subscriber->id) { 867 give_set_error('give_recurring_subscriber_not_match', __('User ID and Subscriber do not match.', 'bayarcash-givewp')); 868 } 869 870 $this->validateRenewalAmount($subscription); 871 872 /* 873 * Update renewal subscription information. 874 * Like renewal amount etc. 875 * 876 * @param Give_Recurring_Subscriber $subscriber 877 * @param Give_Subscription $subscription 878 * 879 * @since 1.8 880 * 881 */ 882 do_action('give_recurring_update_renewal_bayarcash_subscription', $subscriber, $subscription); 883 884 // Is errors? 885 $errors = give_get_errors(); 886 887 // Build URL based on error got or not. 888 if (empty($errors)) { 889 // Update subscription details if don't get any error. 890 $this->update_renewal_subscription_details($subscription); 891 892 $url = add_query_arg( 893 [ 894 'action' => 'edit_subscription', 895 'subscription_id' => $subscription->id, 896 'status' => 'success', 897 ], 898 give_get_subscriptions_page_uri() 899 ); 900 901 wp_send_json_success(['url' => $url]); 902 } 903 904 $url = add_query_arg( 905 [ 906 'action' => 'edit_subscription', 907 'subscription_id' => $subscription->id, 908 'status' => 'error', 909 ], 910 give_get_subscriptions_page_uri() 911 ); 912 913 wp_send_json_error(['url' => $url]); 914 } 597 915 } -
bayarcash-givewp/tags/3.0.0/includes/src/PaymentsQuery.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/includes/src/ResponseSanitizer.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/includes/src/ResponseValidator.php
r2920974 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/tags/3.0.0/languages/bayarcash-givewp.pot
r2920974 r2921565 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2023-06-0 1T14:39:58+00:00\n"12 "POT-Creation-Date: 2023-06-04T17:47:59+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.7.1\n" … … 28 28 29 29 #. Author of the plugin 30 msgid " Web Impian Sdn. Bhd."30 msgid "Bayarcash" 31 31 msgstr "" 32 32 … … 39 39 msgstr "" 40 40 41 #: includes/src/Bayarcash.php:1 3441 #: includes/src/Bayarcash.php:141 42 42 msgid "Bayarcash require GiveWP plugin. Please install and activate." 43 43 msgstr "" 44 44 45 #: includes/src/Givewp.php: 3946 #: includes/src/Givewp.php:4 047 #: includes/src/Givewp.php: 4748 #: includes/src/Givewp.php:15 245 #: includes/src/Givewp.php:44 46 #: includes/src/Givewp.php:45 47 #: includes/src/Givewp.php:52 48 #: includes/src/Givewp.php:157 49 49 msgid "Bayarcash" 50 50 msgstr "" 51 51 52 #: includes/src/Givewp.php: 6652 #: includes/src/Givewp.php:71 53 53 msgid "General Settings" 54 54 msgstr "" 55 55 56 #: includes/src/Givewp.php:7 157 #: includes/src/Givewp.php:1 1856 #: includes/src/Givewp.php:76 57 #: includes/src/Givewp.php:123 58 58 msgid "Bearer Token" 59 msgstr ""60 61 #: includes/src/Givewp.php:7262 #: includes/src/Givewp.php:11963 msgid "Enter your Bearer Token."64 59 msgstr "" 65 60 66 61 #: includes/src/Givewp.php:77 67 62 #: includes/src/Givewp.php:124 63 msgid "Enter your Bearer Token." 64 msgstr "" 65 66 #: includes/src/Givewp.php:82 67 #: includes/src/Givewp.php:129 68 68 msgid "Bayarcash Portal Key" 69 69 msgstr "" 70 70 71 #: includes/src/Givewp.php: 7872 #: includes/src/Givewp.php:1 2571 #: includes/src/Givewp.php:83 72 #: includes/src/Givewp.php:130 73 73 msgid "Enter your portal key." 74 74 msgstr "" 75 75 76 #: includes/src/Givewp.php: 8776 #: includes/src/Givewp.php:92 77 77 msgid "Reference Settings" 78 78 msgstr "" 79 79 80 #: includes/src/Givewp.php:9 281 #: includes/src/Givewp.php:13 080 #: includes/src/Givewp.php:97 81 #: includes/src/Givewp.php:135 82 82 msgid "Billing Fields" 83 msgstr ""84 85 #: includes/src/Givewp.php:9386 #: includes/src/Givewp.php:13187 msgid "This option will enable the billing details section at the donation form."88 83 msgstr "" 89 84 90 85 #: includes/src/Givewp.php:98 91 86 #: includes/src/Givewp.php:136 87 msgid "This option will enable the billing details section at the donation form." 88 msgstr "" 89 90 #: includes/src/Givewp.php:103 91 #: includes/src/Givewp.php:141 92 92 msgid "Enabled" 93 93 msgstr "" 94 94 95 #: includes/src/Givewp.php: 9996 #: includes/src/Givewp.php:1 3795 #: includes/src/Givewp.php:104 96 #: includes/src/Givewp.php:142 97 97 msgid "Disabled" 98 98 msgstr "" 99 99 100 #: includes/src/Givewp.php:1 89100 #: includes/src/Givewp.php:194 101 101 msgid "Make your donation quickly and securely with Bayarcash" 102 102 msgstr "" 103 103 104 #: includes/src/Givewp.php:19 0104 #: includes/src/Givewp.php:195 105 105 msgid "How it works:" 106 106 msgstr "" 107 107 108 #: includes/src/Givewp.php:19 1108 #: includes/src/Givewp.php:196 109 109 msgid "You will be redirected to Bayarcash to pay using your online banking. You will then be brought back to this page to view your receipt." 110 110 msgstr "" 111 111 112 #: includes/src/Givewp.php:235 113 msgid "Please tick the create account button if you want to create a subscription donation" 114 msgstr "" 115 112 116 #. translators: %s: payment data 113 #: includes/src/Givewp.php: 272117 #: includes/src/Givewp.php:369 114 118 msgid "Payment creation failed before sending donor to Bayarcash. Payment data: %s" 115 119 msgstr "" 116 120 117 #: includes/src/Givewp.php: 273121 #: includes/src/Givewp.php:370 118 122 msgid "Payment Error" 119 123 msgstr "" 124 125 #: includes/src/Givewp.php:700 126 msgid "Nonce verification failed." 127 msgstr "" 128 129 #: includes/src/Givewp.php:700 130 #: includes/src/Givewp.php:706 131 #: includes/src/Givewp.php:734 132 msgid "Error" 133 msgstr "" 134 135 #: includes/src/Givewp.php:706 136 msgid "This subscription cannot be cancelled." 137 msgstr "" 138 139 #: includes/src/Givewp.php:772 140 #: includes/src/Givewp.php:845 141 msgid "Invalid subscription ID." 142 msgstr "" 143 144 #: includes/src/Givewp.php:780 145 #: includes/src/Givewp.php:850 146 msgid "This subscription cannot be updated." 147 msgstr "" 148 149 #: includes/src/Givewp.php:785 150 #: includes/src/Givewp.php:858 151 msgid "Invalid subscriber." 152 msgstr "" 153 154 #: includes/src/Givewp.php:790 155 #: includes/src/Givewp.php:863 156 msgid "User ID and Subscriber do not match." 157 msgstr "" -
bayarcash-givewp/trunk/bayarcash-givewp.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * … … 15 15 * Version: 3.0.0 16 16 * Description: Bayarcash payment plugin for GiveWP 17 * Author: Web Impian Sdn. Bhd.17 * Author: Bayarcash 18 18 * Author URI: https://bayarcash.com/?utm_source=wp-plugins-givewps&utm_campaign=author-uri&utm_medium=wp-dash 19 19 * Requires at least: 5.6 -
bayarcash-givewp/trunk/includes/src/Bayarcash.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * … … 121 121 } 122 122 }); 123 124 // Must define before give_recurring is loaded. 125 add_filter('give_recurring_available_gateways', function ($gateways) { 126 $gateways['bayarcash'] = 'BayarCash\\GiveWP\\Givewp'; 127 128 return $gateways; 129 }); 123 130 } 124 131 -
bayarcash-givewp/trunk/includes/src/FpxApi.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/trunk/includes/src/FpxCron.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/trunk/includes/src/FpxDatabase.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/trunk/includes/src/FpxResponseTransformer.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/trunk/includes/src/FpxTransactionStatus.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/trunk/includes/src/Givewp.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * … … 13 13 \defined('ABSPATH') || exit; 14 14 15 use Exception; 15 16 use Give\Helpers\Form\Utils as FormUtils; 17 use Give_Donor; 18 use Give_Recurring_Subscriber; 19 use Give_Subscription; 16 20 17 21 final class Givewp … … 30 34 $this->form_setups(); 31 35 $this->payment_setups(); 36 $this->subscription_setups(); 32 37 $this->pt->register_cronjob(); 33 38 } … … 213 218 } 214 219 220 private function subscription_setups() 221 { 222 add_action('give_checkout_error_checks', function ($valid_data) { 223 $post_data = give_clean($_POST); 224 if (!empty($post_data['give-gateway']) && 'bayarcash' !== $post_data['give-gateway']) { 225 return; 226 } 227 228 if (!is_user_logged_in() && !empty($post_data['give-form-id'])) { 229 $form_id = absint($post_data['give-form-id']); 230 231 // Only required if email access not on & recurring enabled. 232 if (give_is_form_recurring($form_id) && !give_is_setting_enabled(give_get_option('email_access'))) { 233 // check if form is recurring and create account checkbox should be checked. 234 if (!empty($post_data['_give_is_donation_recurring']) && empty($post_data['give_create_account'])) { 235 give_set_error('recurring_create_account', __('Please tick the create account button if you want to create a subscription donation', 'bayarcash-givewp')); 236 } 237 } 238 } 239 }, 0, 1); 240 241 add_action('give_cancel_subscription', [$this, 'process_cancellation']); 242 add_filter('give_subscription_can_cancel', [$this, 'can_cancel'], 10, 2); 243 add_filter('give_subscription_can_sync', [$this, 'can_sync'], 10, 2); 244 add_filter('give_subscription_can_update', [$this, 'can_update'], 10, 2); 245 add_filter('give_subscription_can_update_subscription', [$this, 'can_update_subscription'], 10, 2); 246 247 add_filter('give_subscription_can_cancel_bayarcash_subscription', [ 248 $this, 249 'can_cancel', 250 ], 10, 2); 251 252 add_action('give_recurring_update_subscription_payment_method', [ 253 $this, 254 'process_payment_method_update', 255 ], 10, 3); 256 257 add_filter('give_subscription_profile_link_bayarcash', [$this, 'link_profile_id'], 10, 2); 258 add_action('give_recurring_update_bayarcash_subscription', [$this, 'update_payment_method'], 10, 2); 259 260 add_action('give_recurring_update_renewal_subscription', [ 261 $this, 262 'process_renewal_subscription_update', 263 ], 10, 3); 264 add_action('give_recurring_update_renewal_bayarcash_subscription', [$this, 'update_subscription'], 10, 2); 265 } 266 215 267 private function endpoint_tokens($form_id) 216 268 { … … 263 315 if (give_get_errors()) { 264 316 give_send_back_to_checkout('?payment-mode=bayarcash'); 317 318 return; 265 319 } 266 320 267 321 unset($data['card_info']); 322 323 $is_recurring = Give_Recurring()->is_donation_recurring($data); 324 325 $buyer_id = !empty($data['user_info']['id']) ? $data['user_info']['id'] : null; 326 $buyer_name = ''; 327 $buyer_email = !empty($data['user_email']) ? $data['user_email'] : ''; 328 $buyer_phone = ''; 329 if (!empty($data['user_info'])) { 330 if (empty($buyer_email)) { 331 $buyer_email = $data['user_info']['email']; 332 } 333 334 $buyer_name = $data['user_info']['title'].' '.$data['user_info']['first_name'].' '.$data['user_info']['last_name']; 335 $buyer_name = trim($buyer_name); 336 } 337 338 $post_data = $data['post_data']; 339 if (empty($buyer_name)) { 340 $buyer_name = $post_data['give_title'].' '.$post_data['give_first'].' '.$post_data['give_last']; 341 $buyer_name = trim($buyer_name); 342 } 343 344 if (empty($buyer_email)) { 345 $buyer_email = $post_data['give_email']; 346 } 347 348 /*if ($is_recurring) { 349 if (empty($buyer_id)) { 350 $subscriber = new Give_Donor($buyer_email); 351 } else { 352 $subscriber = new Give_Donor($buyer_id, true); 353 } 354 355 if (empty($subscriber->id)) { 356 $subscriber->create([ 357 'name' => trim($buyer_name), 358 'email' => $buyer_email, 359 'user_id' => $buyer_id, 360 ]); 361 } 362 }*/ 363 364 $data['user_email'] = $buyer_email; 268 365 269 366 $payment_id = $this->create_payment($data); … … 275 372 } 276 373 374 // Anonymous 375 $is_anonymous = isset($data['post_data']['give_anonymous_donation']) && absint($data['post_data']['give_anonymous_donation']); 376 update_post_meta($payment_id , '_give_anonymous_donation', (int) $is_anonymous); 377 277 378 $amount = $data['price']; 278 379 279 $buyer_name = ''; 280 $buyer_email = !empty($data['user_email']) ? $data['user_email'] : ''; 281 $buyer_phone = ''; 282 if (!empty($data['user_info'])) { 283 if (empty($buyer_email)) { 284 $buyer_email = $data['user_info']['email']; 285 } 286 287 $buyer_name = $data['user_info']['title'].' '.$data['user_info']['first_name'].' '.$data['user_info']['last_name']; 288 $buyer_name = trim($buyer_name); 289 } 290 291 $post_data = $data['post_data']; 292 if (empty($buyer_name)) { 293 $buyer_name = $post_data['give_title'].' '.$post_data['give_first'].' '.$post_data['give_last']; 294 $buyer_name = trim($buyer_name); 295 } 296 297 if (empty($buyer_email)) { 298 $buyer_email = $post_data['give_email']; 299 } 300 301 if (isset($purchase_data['give-form-url'])) { 302 $return_url = $purchase_data['give-form-url']; 380 if (isset($data['give-form-url'])) { 381 $return_url = $data['give-form-url']; 303 382 } else { 304 383 $return_url = site_url('/give-api/bayarcash_gateway/'); … … 595 674 return false; 596 675 } 676 677 public function process_cancellation($data) 678 { 679 // Need the sub ID to proceed. 680 if (empty($data['sub_id'])) { 681 return; 682 } 683 684 /* 685 * Sanity check: 686 * 687 * a) If subscriber is not logged in. 688 * b) email access is not enabled nor active. 689 * c) they don't have an active donation session. 690 */ 691 if ( 692 !is_user_logged_in() 693 && false == Give_Recurring()->subscriber_has_email_access() 694 && !give_get_purchase_session() 695 ) { 696 return; 697 } 698 699 // Get subscription id. 700 $data['sub_id'] = absint($data['sub_id']); 701 702 // Verify the nonce for security. 703 if (!wp_verify_nonce($data['_wpnonce'], "give-recurring-cancel-{$data['sub_id']}")) { 704 wp_die(__('Nonce verification failed.', 'bayarcash-givewp'), __('Error', 'bayarcash-givewp'), ['response' => 403]); 705 } 706 707 $subscription = new Give_Subscription($data['sub_id']); 708 709 if (!$subscription->can_cancel()) { 710 wp_die(__('This subscription cannot be cancelled.', 'bayarcash-givewp'), __('Error', 'bayarcash-givewp'), ['response' => 403]); 711 } 712 713 try { 714 do_action('give_recurring_cancel_'.$subscription->gateway.'_subscription', $subscription, true); 715 716 $subscription->cancel(); 717 718 if (is_admin()) { 719 wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-subscriptions&give-message=cancelled&id='.$subscription->id)); 720 exit; 721 } 722 723 $args = !give_get_errors() ? ['give-message' => 'cancelled'] : []; 724 725 wp_redirect( 726 remove_query_arg( 727 [ 728 '_wpnonce', 729 'give_action', 730 'sub_id', 731 ], 732 add_query_arg($args) 733 ) 734 ); 735 736 exit; 737 } catch (Exception $e) { 738 wp_die($e->getMessage(), __('Error', 'bayarcash-givewp'), ['response' => 403]); 739 } 740 } 741 742 public function can_cancel($ret, $subscription) 743 { 744 return $ret; 745 } 746 747 public function can_sync($ret, $subscription) 748 { 749 return $ret; 750 } 751 752 public function can_update($ret, $subscription) 753 { 754 return $ret; 755 } 756 757 public function can_update_subscription($ret, $subscription) 758 { 759 return $ret; 760 } 761 762 public function update_payment_method($subscriber, $subscription, $data = null) 763 { 764 } 765 766 public function link_profile_id($profile_id, $subscription) 767 { 768 return $profile_id; 769 } 770 771 public function process_payment_method_update($user_id, $subscription_id, $verified) 772 { 773 $subscription = new Give_Subscription($subscription_id); 774 775 if (empty($subscription->id)) { 776 give_set_error('give_recurring_invalid_subscription_id', __('Invalid subscription ID.', 'bayarcash-givewp')); 777 } 778 779 if ('bayarcash' !== $subscription->gateway) { 780 return; 781 } 782 783 if (!$subscription->can_update()) { 784 give_set_error('give_recurring_subscription_not_updated', __('This subscription cannot be updated.', 'bayarcash-givewp')); 785 } 786 787 $subscriber = new Give_Recurring_Subscriber($subscription->customer_id); 788 if (empty($subscriber->id)) { 789 give_set_error('give_recurring_invalid_subscriber', __('Invalid subscriber.', 'bayarcash-givewp')); 790 } 791 792 // Make sure the User doing the update is the user the subscription belongs to 793 if ($user_id !== $subscriber->id) { 794 give_set_error('give_recurring_subscriber_not_match', __('User ID and Subscriber do not match.', 'bayarcash-givewp')); 795 } 796 797 do_action('give_recurring_update_bayarcash_subscription', $subscriber, $subscription); 798 799 $errors = give_get_errors(); 800 801 if (!wp_doing_ajax()) { 802 if (empty($errors)) { 803 $url = add_query_arg(['action' => 'update', 'updated' => true, 'subscription_id' => $subscription->id], give_get_subscriptions_page_uri()); 804 } else { 805 $url = add_query_arg(['action' => 'update', 'subscription_id' => $subscription->id], give_get_subscriptions_page_uri()); 806 } 807 808 wp_safe_redirect($url); 809 exit; 810 } 811 812 if (empty($errors)) { 813 $url = add_query_arg( 814 [ 815 'action' => 'update', 816 'updated' => '1', 817 'status' => 'success', 818 'subscription_id' => $subscription->id, 819 ], 820 give_get_subscriptions_page_uri() 821 ); 822 823 wp_send_json_success(['url' => $url]); 824 } 825 826 $url = add_query_arg( 827 [ 828 'action' => 'update', 829 'subscription_id' => $subscription->id, 830 'status' => 'error', 831 ], 832 give_get_subscriptions_page_uri() 833 ); 834 835 wp_send_json_error(['url' => $url]); 836 } 837 838 public function process_renewal_subscription_update($user_id, $subscription_id, $verified) 839 { 840 $subscription = new Give_Subscription($subscription_id); 841 842 // Bail out, if Gateway not match. 843 if ('bayarcash' !== $subscription->gateway) { 844 return; 845 } 846 847 // Set error if Subscription ID empty. 848 if (empty($subscription->id)) { 849 give_set_error('give_recurring_invalid_subscription_id', __('Invalid subscription ID.', 'bayarcash-givewp')); 850 } 851 852 // Set error if Subscription can not be update. 853 if (!$subscription->can_update_subscription()) { 854 give_set_error('give_recurring_renewal_subscription_not_updated', __('This subscription cannot be updated.', 'bayarcash-givewp')); 855 } 856 857 // Get Subscriber. 858 $subscriber = new Give_Recurring_Subscriber($subscription->customer_id); 859 860 // Set error if Invalid subscriber. 861 if (empty($subscriber->id)) { 862 give_set_error('give_recurring_invalid_subscriber', __('Invalid subscriber.', 'bayarcash-givewp')); 863 } 864 865 // Make sure the User doing the update is the user the subscription belongs to. 866 if ($user_id !== $subscriber->id) { 867 give_set_error('give_recurring_subscriber_not_match', __('User ID and Subscriber do not match.', 'bayarcash-givewp')); 868 } 869 870 $this->validateRenewalAmount($subscription); 871 872 /* 873 * Update renewal subscription information. 874 * Like renewal amount etc. 875 * 876 * @param Give_Recurring_Subscriber $subscriber 877 * @param Give_Subscription $subscription 878 * 879 * @since 1.8 880 * 881 */ 882 do_action('give_recurring_update_renewal_bayarcash_subscription', $subscriber, $subscription); 883 884 // Is errors? 885 $errors = give_get_errors(); 886 887 // Build URL based on error got or not. 888 if (empty($errors)) { 889 // Update subscription details if don't get any error. 890 $this->update_renewal_subscription_details($subscription); 891 892 $url = add_query_arg( 893 [ 894 'action' => 'edit_subscription', 895 'subscription_id' => $subscription->id, 896 'status' => 'success', 897 ], 898 give_get_subscriptions_page_uri() 899 ); 900 901 wp_send_json_success(['url' => $url]); 902 } 903 904 $url = add_query_arg( 905 [ 906 'action' => 'edit_subscription', 907 'subscription_id' => $subscription->id, 908 'status' => 'error', 909 ], 910 give_get_subscriptions_page_uri() 911 ); 912 913 wp_send_json_error(['url' => $url]); 914 } 597 915 } -
bayarcash-givewp/trunk/includes/src/PaymentsQuery.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/trunk/includes/src/ResponseSanitizer.php
r2920975 r2921565 3 3 * Bayarcash GiveWP. 4 4 * 5 * @author Web Impian Sdn. Bhd.5 * @author Bayarcash 6 6 * @license GPLv3 7 7 * -
bayarcash-givewp/trunk/includes/vendor/composer
-
Property
svn:ignore
set to
ClassLoader.php-e
-
Property
svn:ignore
set to
-
bayarcash-givewp/trunk/languages/bayarcash-givewp.pot
r2920976 r2921565 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 2023-06-0 1T14:39:58+00:00\n"12 "POT-Creation-Date: 2023-06-04T17:47:59+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.7.1\n" … … 28 28 29 29 #. Author of the plugin 30 msgid " Web Impian Sdn. Bhd."30 msgid "Bayarcash" 31 31 msgstr "" 32 32 … … 39 39 msgstr "" 40 40 41 #: includes/src/Bayarcash.php:1 3441 #: includes/src/Bayarcash.php:141 42 42 msgid "Bayarcash require GiveWP plugin. Please install and activate." 43 43 msgstr "" 44 44 45 #: includes/src/Givewp.php: 3946 #: includes/src/Givewp.php:4 047 #: includes/src/Givewp.php: 4748 #: includes/src/Givewp.php:15 245 #: includes/src/Givewp.php:44 46 #: includes/src/Givewp.php:45 47 #: includes/src/Givewp.php:52 48 #: includes/src/Givewp.php:157 49 49 msgid "Bayarcash" 50 50 msgstr "" 51 51 52 #: includes/src/Givewp.php: 6652 #: includes/src/Givewp.php:71 53 53 msgid "General Settings" 54 54 msgstr "" 55 55 56 #: includes/src/Givewp.php:7 157 #: includes/src/Givewp.php:1 1856 #: includes/src/Givewp.php:76 57 #: includes/src/Givewp.php:123 58 58 msgid "Bearer Token" 59 msgstr ""60 61 #: includes/src/Givewp.php:7262 #: includes/src/Givewp.php:11963 msgid "Enter your Bearer Token."64 59 msgstr "" 65 60 66 61 #: includes/src/Givewp.php:77 67 62 #: includes/src/Givewp.php:124 63 msgid "Enter your Bearer Token." 64 msgstr "" 65 66 #: includes/src/Givewp.php:82 67 #: includes/src/Givewp.php:129 68 68 msgid "Bayarcash Portal Key" 69 69 msgstr "" 70 70 71 #: includes/src/Givewp.php: 7872 #: includes/src/Givewp.php:1 2571 #: includes/src/Givewp.php:83 72 #: includes/src/Givewp.php:130 73 73 msgid "Enter your portal key." 74 74 msgstr "" 75 75 76 #: includes/src/Givewp.php: 8776 #: includes/src/Givewp.php:92 77 77 msgid "Reference Settings" 78 78 msgstr "" 79 79 80 #: includes/src/Givewp.php:9 281 #: includes/src/Givewp.php:13 080 #: includes/src/Givewp.php:97 81 #: includes/src/Givewp.php:135 82 82 msgid "Billing Fields" 83 msgstr ""84 85 #: includes/src/Givewp.php:9386 #: includes/src/Givewp.php:13187 msgid "This option will enable the billing details section at the donation form."88 83 msgstr "" 89 84 90 85 #: includes/src/Givewp.php:98 91 86 #: includes/src/Givewp.php:136 87 msgid "This option will enable the billing details section at the donation form." 88 msgstr "" 89 90 #: includes/src/Givewp.php:103 91 #: includes/src/Givewp.php:141 92 92 msgid "Enabled" 93 93 msgstr "" 94 94 95 #: includes/src/Givewp.php: 9996 #: includes/src/Givewp.php:1 3795 #: includes/src/Givewp.php:104 96 #: includes/src/Givewp.php:142 97 97 msgid "Disabled" 98 98 msgstr "" 99 99 100 #: includes/src/Givewp.php:1 89100 #: includes/src/Givewp.php:194 101 101 msgid "Make your donation quickly and securely with Bayarcash" 102 102 msgstr "" 103 103 104 #: includes/src/Givewp.php:19 0104 #: includes/src/Givewp.php:195 105 105 msgid "How it works:" 106 106 msgstr "" 107 107 108 #: includes/src/Givewp.php:19 1108 #: includes/src/Givewp.php:196 109 109 msgid "You will be redirected to Bayarcash to pay using your online banking. You will then be brought back to this page to view your receipt." 110 110 msgstr "" 111 111 112 #: includes/src/Givewp.php:235 113 msgid "Please tick the create account button if you want to create a subscription donation" 114 msgstr "" 115 112 116 #. translators: %s: payment data 113 #: includes/src/Givewp.php: 272117 #: includes/src/Givewp.php:369 114 118 msgid "Payment creation failed before sending donor to Bayarcash. Payment data: %s" 115 119 msgstr "" 116 120 117 #: includes/src/Givewp.php: 273121 #: includes/src/Givewp.php:370 118 122 msgid "Payment Error" 119 123 msgstr "" 124 125 #: includes/src/Givewp.php:700 126 msgid "Nonce verification failed." 127 msgstr "" 128 129 #: includes/src/Givewp.php:700 130 #: includes/src/Givewp.php:706 131 #: includes/src/Givewp.php:734 132 msgid "Error" 133 msgstr "" 134 135 #: includes/src/Givewp.php:706 136 msgid "This subscription cannot be cancelled." 137 msgstr "" 138 139 #: includes/src/Givewp.php:772 140 #: includes/src/Givewp.php:845 141 msgid "Invalid subscription ID." 142 msgstr "" 143 144 #: includes/src/Givewp.php:780 145 #: includes/src/Givewp.php:850 146 msgid "This subscription cannot be updated." 147 msgstr "" 148 149 #: includes/src/Givewp.php:785 150 #: includes/src/Givewp.php:858 151 msgid "Invalid subscriber." 152 msgstr "" 153 154 #: includes/src/Givewp.php:790 155 #: includes/src/Givewp.php:863 156 msgid "User ID and Subscriber do not match." 157 msgstr ""
Note: See TracChangeset
for help on using the changeset viewer.