@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * EDU_SveaWebPay integrates EduAdmin-WordPress plugin with SveaWebPay as payment gateway |
| 15 | 15 | */ |
| 16 | - class EDU_SveaWebPay extends EDU_Integration { |
|
| 16 | + class EDU_SveaWebPay extends EDU_Integration {
|
|
| 17 | 17 | /** |
| 18 | 18 | * Constructor |
| 19 | 19 | */ |
| 20 | - public function __construct() { |
|
| 20 | + public function __construct() {
|
|
| 21 | 21 | $this->id = 'eduadmin-sveawebpay'; |
| 22 | 22 | $this->displayName = __( 'Svea Webpay (Checkout)', 'eduadmin-sveawebpay' ); |
| 23 | 23 | $this->description = ''; |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @param $bookingInfo EduAdminBookingInfo |
| 37 | 37 | */ |
| 38 | - public function intercept_booking( $bookingInfo = null ) { |
|
| 39 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
| 38 | + public function intercept_booking( $bookingInfo = null ) {
|
|
| 39 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
|
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | - if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) { |
|
| 42 | + if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
|
|
| 43 | 43 | $bookingInfo->NoRedirect = true; |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * Initializes the settingsfields |
| 49 | 49 | */ |
| 50 | - public function init_form_fields() { |
|
| 50 | + public function init_form_fields() {
|
|
| 51 | 51 | $this->setting_fields = array( |
| 52 | 52 | 'enabled' => array( |
| 53 | 53 | 'title' => __( 'Enabled', 'eduadmin-sveawebpay' ), |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | /** |
| 80 | 80 | * |
| 81 | 81 | */ |
| 82 | - public function process_svearesponse() { |
|
| 82 | + public function process_svearesponse() {
|
|
| 83 | 83 | |
| 84 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
| 84 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
|
|
| 85 | 85 | return; |
| 86 | 86 | } |
| 87 | - if ( ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) ) || ( isset( $_REQUEST['edu-cancel'] ) && isset( $_REQUEST['svea'] ) ) ) { |
|
| 87 | + if ( ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) ) || ( isset( $_REQUEST['edu-cancel'] ) && isset( $_REQUEST['svea'] ) ) ) {
|
|
| 88 | 88 | |
| 89 | 89 | $eclId = ( isset( $_REQUEST['edu-thankyou'] ) ? $_REQUEST['edu-thankyou'] : $_REQUEST['edu-cancel'] ); |
| 90 | 90 | |
@@ -113,20 +113,20 @@ discard block |
||
| 113 | 113 | $selectedCountry = 'SE'; |
| 114 | 114 | |
| 115 | 115 | $invoiceCountry = $ebi->Customer->InvoiceCountry; |
| 116 | - if ( empty( $invoiceCountry ) ) { |
|
| 116 | + if ( empty( $invoiceCountry ) ) {
|
|
| 117 | 117 | $invoiceCountry = $ebi->Customer->Country; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - foreach ( $countries as $country ) { |
|
| 121 | - if ( $invoiceCountry == $country->CountryName ) { |
|
| 120 | + foreach ( $countries as $country ) {
|
|
| 121 | + if ( $invoiceCountry == $country->CountryName ) {
|
|
| 122 | 122 | $selectedCountry = $country->CountryCode; |
| 123 | 123 | break; |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) { |
|
| 127 | + if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
|
|
| 128 | 128 | $wpConfig = new EduSveaWebPayTestConfig( $this ); |
| 129 | - } else { |
|
| 129 | + } else {
|
|
| 130 | 130 | $wpConfig = new EduSveaWebPayProductionConfig( $this ); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $sveaOrderId = get_transient( 'eduadmin-sveaorderid-' . $ebi->EventBooking->EventCustomerLnkID, - 1 ); |
| 136 | 136 | |
| 137 | - if ( $sveaOrderId > 0 ) { |
|
| 137 | + if ( $sveaOrderId > 0 ) {
|
|
| 138 | 138 | $wpOrder = WebPay::checkout( $wpConfig ); |
| 139 | 139 | |
| 140 | 140 | $wpOrder->setCheckoutOrderId( $sveaOrderId ); |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | $order = $wpOrder->getOrder(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if ( 'Cancelled' !== $order['Status'] ) { |
|
| 145 | + if ( 'Cancelled' !== $order['Status'] ) {
|
|
| 146 | 146 | EDU()->api->SetValidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID ); |
| 147 | - } else { |
|
| 147 | + } else {
|
|
| 148 | 148 | EDU()->api->SetInvalidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID ); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | /** |
| 163 | 163 | * @param $bookingInfo EduAdminBookingInfo |
| 164 | 164 | */ |
| 165 | - public function process_booking( $bookingInfo = null ) { |
|
| 166 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
| 165 | + public function process_booking( $bookingInfo = null ) {
|
|
| 166 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
|
|
| 167 | 167 | return; |
| 168 | 168 | } |
| 169 | - if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) { |
|
| 169 | + if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
|
|
| 170 | 170 | $bookingInfo->NoRedirect = true; |
| 171 | 171 | |
| 172 | 172 | $countries = EDU()->api->GetCountries( EDU()->get_token(), 'Swedish' ); |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | $selectedLocale = 'sv-SE'; |
| 176 | 176 | |
| 177 | 177 | $invoiceCountry = $bookingInfo->Customer->InvoiceCountry; |
| 178 | - if ( empty( $invoiceCountry ) ) { |
|
| 178 | + if ( empty( $invoiceCountry ) ) {
|
|
| 179 | 179 | $invoiceCountry = $bookingInfo->Customer->Country; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - foreach ( $countries as $country ) { |
|
| 183 | - if ( $invoiceCountry == $country->CountryName ) { |
|
| 182 | + foreach ( $countries as $country ) {
|
|
| 183 | + if ( $invoiceCountry == $country->CountryName ) {
|
|
| 184 | 184 | $selectedCountry = $country->CountryCode; |
| 185 | - if ( ! empty( $country->CultureName ) ) { |
|
| 185 | + if ( ! empty( $country->CultureName ) ) {
|
|
| 186 | 186 | $selectedLocale = $country->CultureName; |
| 187 | 187 | } |
| 188 | 188 | break; |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | $currency = get_option( 'eduadmin-currency', 'SEK' ); |
| 195 | 195 | |
| 196 | - if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) { |
|
| 196 | + if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
|
|
| 197 | 197 | $wpConfig = new EduSveaWebPayTestConfig( $this ); |
| 198 | - } else { |
|
| 198 | + } else {
|
|
| 199 | 199 | $wpConfig = new EduSveaWebPayProductionConfig( $this ); |
| 200 | 200 | } |
| 201 | 201 | #$wpOrder = WebPay::createOrder( $wpConfig ); |
@@ -211,21 +211,21 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | $customer = WebPayItem::companyCustomer(); |
| 213 | 213 | |
| 214 | - if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) { |
|
| 214 | + if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
|
|
| 215 | 215 | $customer->setCompanyName( $bookingInfo->Customer->InvoiceName ); |
| 216 | - } else { |
|
| 216 | + } else {
|
|
| 217 | 217 | $customer->setCompanyName( $bookingInfo->Customer->CustomerName ); |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) { |
|
| 220 | + if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
|
|
| 221 | 221 | $customer->setStreetAddress( $bookingInfo->Customer->InvoiceAddress1 ); |
| 222 | - } else { |
|
| 222 | + } else {
|
|
| 223 | 223 | $customer->setStreetAddress( $bookingInfo->Customer->Address1 ); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) { |
|
| 226 | + if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
|
|
| 227 | 227 | $customer->setZipCode( $bookingInfo->Customer->InvoiceZip ); |
| 228 | - } else { |
|
| 228 | + } else {
|
|
| 229 | 229 | $customer->setZipCode( $bookingInfo->Customer->Zip ); |
| 230 | 230 | } |
| 231 | 231 | |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | ->setIsReadonly( false ); |
| 236 | 236 | $wpOrder->addPresetValue( $zipPreset ); |
| 237 | 237 | |
| 238 | - if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) { |
|
| 238 | + if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
|
|
| 239 | 239 | $customer->setLocality( $bookingInfo->Customer->InvoiceCity ); |
| 240 | - } else { |
|
| 240 | + } else {
|
|
| 241 | 241 | $customer->setLocality( $bookingInfo->Customer->City ); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if ( ! empty( $bookingInfo->Customer->Phone ) ) { |
|
| 244 | + if ( ! empty( $bookingInfo->Customer->Phone ) ) {
|
|
| 245 | 245 | $customer->setPhoneNumber( $bookingInfo->Customer->Phone ); |
| 246 | 246 | $phonePreset = WebPayItem::presetValue() |
| 247 | 247 | ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::PHONE_NUMBER ) |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | $wpOrder->addPresetValue( $phonePreset ); |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) { |
|
| 253 | + if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
|
|
| 254 | 254 | $customer->setEmail( $bookingInfo->Customer->InvoiceEmail ); |
| 255 | - } else { |
|
| 255 | + } else {
|
|
| 256 | 256 | $customer->setEmail( $bookingInfo->Customer->Email ); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | set_transient( 'eduadmin-sveaorderid-' . $bookingInfo->EventBooking->EventCustomerLnkID, $wpForm['OrderId'], HOUR_IN_SECONDS ); |
| 300 | 300 | |
| 301 | - if ( array_key_exists( 'Gui', $wpForm ) ) { |
|
| 301 | + if ( array_key_exists( 'Gui', $wpForm ) ) {
|
|
| 302 | 302 | echo $wpForm['Gui']['Snippet']; |
| 303 | 303 | } |
| 304 | 304 | /*if ( $wpForm->accepted ) { |