wp-pay-gateways /
icepay
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\Icepay; |
||
| 4 | |||
| 5 | use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Title: ICEPAY integration |
||
| 9 | * Description: |
||
| 10 | * Copyright: 2005-2019 Pronamic |
||
| 11 | * Company: Pronamic |
||
| 12 | * |
||
| 13 | * @author Reüel van der Steege |
||
| 14 | * @version 2.0.0 |
||
| 15 | * @since 1.0.0 |
||
| 16 | */ |
||
| 17 | class Integration extends AbstractIntegration { |
||
| 18 | 1 | public function __construct( $args = array() ) { |
|
| 19 | 1 | $args = wp_parse_args( |
|
| 20 | 1 | $args, |
|
| 21 | 1 | array( |
|
| 22 | 1 | 'id' => 'icepay-ideal', |
|
| 23 | 1 | 'name' => 'ICEPAY', |
|
| 24 | 1 | 'url' => 'https://icepay.com/', |
|
| 25 | 'product_url' => __( 'https://icepay.com/nl/en/pricing-and-accounts/', 'pronamic_ideal' ), |
||
| 26 | 'manual_url' => __( 'https://www.pronamic.eu/support/how-to-connect-icepay-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ), |
||
| 27 | 1 | 'dashboard_url' => 'https://portal.icepay.com/', |
|
| 28 | 'provider' => 'icepay', |
||
| 29 | 1 | ) |
|
| 30 | 1 | ); |
|
| 31 | |||
| 32 | 1 | $this->id = $args['id']; |
|
| 33 | $this->name = $args['name']; |
||
| 34 | 1 | $this->url = $args['url']; |
|
| 35 | 1 | $this->product_url = $args['product_url']; |
|
| 36 | $this->manual_url = $args['manual_url']; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 37 | $this->dashboard_url = $args['dashboard_url']; |
||
| 38 | $this->provider = $args['provider']; |
||
| 39 | $this->supports = array( |
||
| 40 | 'webhook', |
||
| 41 | 'webhook_log', |
||
| 42 | ); |
||
| 43 | |||
| 44 | // Actions |
||
| 45 | $function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
||
| 46 | |||
| 47 | if ( ! has_action( 'wp_loaded', $function ) ) { |
||
| 48 | add_action( 'wp_loaded', $function ); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | public function get_settings_fields() { |
||
| 53 | $fields = array(); |
||
| 54 | |||
| 55 | // Merchant ID |
||
| 56 | $fields[] = array( |
||
| 57 | 'section' => 'general', |
||
| 58 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 59 | 'meta_key' => '_pronamic_gateway_icepay_merchant_id', |
||
| 60 | 'title' => _x( 'Merchant ID', 'icepay', 'pronamic_ideal' ), |
||
| 61 | 'type' => 'text', |
||
| 62 | 'tooltip' => __( 'Merchant ID as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ), |
||
| 63 | ); |
||
| 64 | |||
| 65 | // Secret Code |
||
| 66 | $fields[] = array( |
||
| 67 | 'section' => 'general', |
||
| 68 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 69 | 'meta_key' => '_pronamic_gateway_icepay_secret_code', |
||
| 70 | 'title' => _x( 'Secret Code', 'icepay', 'pronamic_ideal' ), |
||
| 71 | 'type' => 'text', |
||
| 72 | 'classes' => array( 'regular-text', 'code' ), |
||
| 73 | 'tooltip' => __( 'Secret Code as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ), |
||
| 74 | ); |
||
| 75 | |||
| 76 | // Purchase ID |
||
| 77 | $fields[] = array( |
||
| 78 | 'section' => 'advanced', |
||
| 79 | 'filter' => array( |
||
| 80 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 81 | 'flags' => FILTER_FLAG_NO_ENCODE_QUOTES, |
||
| 82 | ), |
||
| 83 | 'meta_key' => '_pronamic_gateway_icepay_order_id', |
||
| 84 | 'title' => __( 'Order ID', 'pronamic_ideal' ), |
||
| 85 | 'type' => 'text', |
||
| 86 | 'classes' => array( 'regular-text', 'code' ), |
||
| 87 | 'tooltip' => sprintf( |
||
| 88 | /* translators: %s: <code>OrderID</code> */ |
||
| 89 | __( 'The Icepay %s parameter.', 'pronamic_ideal' ), |
||
| 90 | sprintf( '<code>%s</code>', 'OrderID' ) |
||
| 91 | ), |
||
| 92 | 'description' => sprintf( |
||
| 93 | '%s %s<br />%s', |
||
| 94 | __( 'Available tags:', 'pronamic_ideal' ), |
||
| 95 | sprintf( |
||
| 96 | '<code>%s</code> <code>%s</code>', |
||
| 97 | '{order_id}', |
||
| 98 | '{payment_id}' |
||
| 99 | ), |
||
| 100 | sprintf( |
||
| 101 | /* translators: %s: <code>{payment_id}</code> */ |
||
| 102 | __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
||
| 103 | '{payment_id}' |
||
| 104 | ) |
||
| 105 | ), |
||
| 106 | ); |
||
| 107 | |||
| 108 | // Thank you page URL |
||
| 109 | $fields[] = array( |
||
| 110 | 'section' => 'feedback', |
||
| 111 | 'title' => __( 'Thank you page URL', 'pronamic_ideal' ), |
||
| 112 | 'type' => 'text', |
||
| 113 | 'classes' => array( 'regular-text', 'code' ), |
||
| 114 | 'value' => home_url( '/' ), |
||
| 115 | 'readonly' => true, |
||
| 116 | ); |
||
| 117 | |||
| 118 | // Error page URL |
||
| 119 | $fields[] = array( |
||
| 120 | 'section' => 'feedback', |
||
| 121 | 'title' => __( 'Error page URL', 'pronamic_ideal' ), |
||
| 122 | 'type' => 'text', |
||
| 123 | 'classes' => array( 'regular-text', 'code' ), |
||
| 124 | 'value' => home_url( '/' ), |
||
| 125 | 'readonly' => true, |
||
| 126 | ); |
||
| 127 | |||
| 128 | // Postback URL |
||
| 129 | $fields[] = array( |
||
| 130 | 'section' => 'feedback', |
||
| 131 | 'title' => __( 'Postback URL', 'pronamic_ideal' ), |
||
| 132 | 'type' => 'text', |
||
| 133 | 'classes' => array( 'regular-text', 'code' ), |
||
| 134 | 'value' => home_url( '/' ), |
||
| 135 | 'readonly' => true, |
||
| 136 | ); |
||
| 137 | |||
| 138 | return $fields; |
||
| 139 | } |
||
| 140 | |||
| 141 | public function get_config( $post_id ) { |
||
| 142 | $config = new Config(); |
||
| 143 | |||
| 144 | $config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_icepay_merchant_id', true ); |
||
| 145 | $config->secret_code = get_post_meta( $post_id, '_pronamic_gateway_icepay_secret_code', true ); |
||
| 146 | $config->order_id = get_post_meta( $post_id, '_pronamic_gateway_icepay_order_id', true ); |
||
| 147 | |||
| 148 | return $config; |
||
| 149 | } |
||
| 150 | |||
| 151 | /** |
||
| 152 | * Get gateway. |
||
| 153 | * |
||
| 154 | * @param int $post_id Post ID. |
||
| 155 | * @return Gateway |
||
| 156 | */ |
||
| 157 | public function get_gateway( $post_id ) { |
||
| 158 | return new Gateway( $this->get_config( $post_id ) ); |
||
| 159 | } |
||
| 160 | } |
||
| 161 |