paypal
4 years ago
base-gateway.php
4 years ago
gateway-manager.php
4 years ago
gateways-editor-data.php
4 years ago
gateways-editor-data.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Gateways; |
| 5 | |
| 6 | |
| 7 | use Jet_Form_Builder\Plugin; |
| 8 | |
| 9 | trait Gateways_Editor_Data { |
| 10 | |
| 11 | private function labels() { |
| 12 | return array_merge( |
| 13 | array( |
| 14 | 'notifications_before' => __( 'Before payment processed:', 'jet-form-builder' ), |
| 15 | 'notifications_success' => __( 'On successful payment:', 'jet-form-builder' ), |
| 16 | 'notifications_failed' => __( 'On failed payment:', 'jet-form-builder' ), |
| 17 | 'price_field' => __( 'Price/amount field', 'jet-form-builder' ), |
| 18 | 'message_success' => __( 'Payment success message', 'jet-form-builder' ), |
| 19 | 'message_failed' => __( 'Payment failed message', 'jet-form-builder' ), |
| 20 | 'use_success_redirect' => __( 'Use redirect URL from Redirect notification', 'jet-form-builder' ), |
| 21 | 'action_order' => __( 'Create payment order notification:', 'jet-form-builder' ) |
| 22 | ), |
| 23 | $this->options_labels() |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | public function default_messages() { |
| 28 | return array( |
| 29 | 'success' => 'Payment success message', |
| 30 | 'failed' => 'Payment failed message', |
| 31 | ); |
| 32 | } |
| 33 | |
| 34 | private function options_labels() { |
| 35 | $result = array(); |
| 36 | |
| 37 | foreach ( $this->_gateways as $gateway ) { |
| 38 | $result[ $gateway->get_id() ] = $gateway->options( 'label' ); |
| 39 | } |
| 40 | |
| 41 | return $result; |
| 42 | } |
| 43 | |
| 44 | private function gateways_for_js() { |
| 45 | $result = array(); |
| 46 | |
| 47 | foreach ( $this->_gateways as $gateway ) { |
| 48 | $result[] = array( |
| 49 | 'value' => $gateway->get_id(), |
| 50 | 'label' => $gateway->get_name() |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | return $result; |
| 55 | } |
| 56 | |
| 57 | public function editor_data() { |
| 58 | $result = array( |
| 59 | 'allowed' => Plugin::instance()->allow_gateways |
| 60 | ); |
| 61 | |
| 62 | if ( $result['allowed'] ) { |
| 63 | $result['labels'] = $this->labels(); |
| 64 | $result['list'] = $this->gateways_for_js(); |
| 65 | $result['messages'] = $this->default_messages(); |
| 66 | } |
| 67 | |
| 68 | return $result; |
| 69 | } |
| 70 | |
| 71 | } |