@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * EDU_SveaWebPay integrates EduAdmin-WordPress plugin with SveaWebPay as payment gateway |
| 13 | 13 | */ |
| 14 | - class EDU_SveaWebPay extends EDU_Integration { |
|
| 14 | + class EDU_SveaWebPay extends EDU_Integration {
|
|
| 15 | 15 | /** |
| 16 | 16 | * Constructor |
| 17 | 17 | */ |
| 18 | - public function __construct() { |
|
| 18 | + public function __construct() {
|
|
| 19 | 19 | $this->id = 'eduadmin-sveawebpay'; |
| 20 | 20 | $this->displayName = __( 'Svea Webpay', 'eduadmin-sveawebpay' ); |
| 21 | 21 | $this->description = ''; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * Initializes the settingsfields |
| 33 | 33 | */ |
| 34 | - public function init_form_fields() { |
|
| 34 | + public function init_form_fields() {
|
|
| 35 | 35 | $this->setting_fields = array( |
| 36 | 36 | 'enabled' => array( |
| 37 | 37 | 'title' => __( 'Enabled', 'eduadmin-sveawebpay' ), |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | /** |
| 64 | 64 | * |
| 65 | 65 | */ |
| 66 | - public function process_svearesponse() { |
|
| 67 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
| 66 | + public function process_svearesponse() {
|
|
| 67 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
|
|
| 68 | 68 | return; |
| 69 | 69 | } |
| 70 | - if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && isset( $_REQUEST['response'] ) ) { |
|
| 70 | + if ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) && isset( $_REQUEST['response'] ) ) {
|
|
| 71 | 71 | $filter = new XFiltering(); |
| 72 | 72 | $f = new XFilter( 'EventCustomerLnkID', '=', $_REQUEST['edu-thankyou'] ); |
| 73 | 73 | $filter->AddItem( $f ); |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | $selectedCountry = 'SE'; |
| 94 | 94 | |
| 95 | 95 | $invoiceCountry = $ebi->Customer->InvoiceCountry; |
| 96 | - if ( empty( $invoiceCountry ) ) { |
|
| 96 | + if ( empty( $invoiceCountry ) ) {
|
|
| 97 | 97 | $invoiceCountry = $ebi->Customer->Country; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - foreach ( $countries as $country ) { |
|
| 101 | - if ( $invoiceCountry == $country->CountryName ) { |
|
| 100 | + foreach ( $countries as $country ) {
|
|
| 101 | + if ( $invoiceCountry == $country->CountryName ) {
|
|
| 102 | 102 | $selectedCountry = $country->CountryCode; |
| 103 | 103 | break; |
| 104 | 104 | } |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | $response = ( new SveaResponse( $_REQUEST, $selectedCountry, $wpConfig ) )->getResponse(); |
| 110 | 110 | |
| 111 | - if ( $response->accepted ) { |
|
| 111 | + if ( $response->accepted ) {
|
|
| 112 | 112 | EDU()->api->SetValidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID ); |
| 113 | - } else { |
|
| 113 | + } else {
|
|
| 114 | 114 | EDU()->api->SetInvalidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID ); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * @param $bookingInfo EduAdminBookingInfo |
| 128 | 128 | */ |
| 129 | - public function process_booking( $bookingInfo = null ) { |
|
| 130 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
| 129 | + public function process_booking( $bookingInfo = null ) {
|
|
| 130 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
|
|
| 131 | 131 | return; |
| 132 | 132 | } |
| 133 | - if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) { |
|
| 133 | + if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
|
|
| 134 | 134 | $bookingInfo->NoRedirect = true; |
| 135 | 135 | |
| 136 | 136 | $countries = EDU()->api->GetCountries( EDU()->get_token(), 'Swedish' ); |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | $selectedLocale = 'sv-SE'; |
| 140 | 140 | |
| 141 | 141 | $invoiceCountry = $bookingInfo->Customer->InvoiceCountry; |
| 142 | - if ( empty( $invoiceCountry ) ) { |
|
| 142 | + if ( empty( $invoiceCountry ) ) {
|
|
| 143 | 143 | $invoiceCountry = $bookingInfo->Customer->Country; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - foreach ( $countries as $country ) { |
|
| 147 | - if ( $invoiceCountry == $country->CountryName ) { |
|
| 146 | + foreach ( $countries as $country ) {
|
|
| 147 | + if ( $invoiceCountry == $country->CountryName ) {
|
|
| 148 | 148 | $selectedCountry = $country->CountryCode; |
| 149 | - if ( ! empty( $country->CultureName ) ) { |
|
| 149 | + if ( ! empty( $country->CultureName ) ) {
|
|
| 150 | 150 | $selectedLocale = $country->CultureName; |
| 151 | 151 | } |
| 152 | 152 | break; |
@@ -170,37 +170,37 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | $customer = WebPayItem::companyCustomer(); |
| 172 | 172 | |
| 173 | - if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) { |
|
| 173 | + if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
|
|
| 174 | 174 | $customer->setCompanyName( $bookingInfo->Customer->InvoiceName ); |
| 175 | - } else { |
|
| 175 | + } else {
|
|
| 176 | 176 | $customer->setCompanyName( $bookingInfo->Customer->CustomerName ); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) { |
|
| 179 | + if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
|
|
| 180 | 180 | $customer->setStreetAddress( $bookingInfo->Customer->InvoiceAddress1 ); |
| 181 | - } else { |
|
| 181 | + } else {
|
|
| 182 | 182 | $customer->setStreetAddress( $bookingInfo->Customer->Address1 ); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) { |
|
| 185 | + if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
|
|
| 186 | 186 | $customer->setZipCode( $bookingInfo->Customer->InvoiceZip ); |
| 187 | - } else { |
|
| 187 | + } else {
|
|
| 188 | 188 | $customer->setZipCode( $bookingInfo->Customer->Zip ); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) { |
|
| 191 | + if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
|
|
| 192 | 192 | $customer->setLocality( $bookingInfo->Customer->InvoiceCity ); |
| 193 | - } else { |
|
| 193 | + } else {
|
|
| 194 | 194 | $customer->setLocality( $bookingInfo->Customer->City ); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if ( ! empty( $bookingInfo->Customer->Phone ) ) { |
|
| 197 | + if ( ! empty( $bookingInfo->Customer->Phone ) ) {
|
|
| 198 | 198 | $customer->setPhoneNumber( $bookingInfo->Customer->Phone ); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) { |
|
| 201 | + if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
|
|
| 202 | 202 | $customer->setEmail( $bookingInfo->Customer->InvoiceEmail ); |
| 203 | - } else { |
|
| 203 | + } else {
|
|
| 204 | 204 | $customer->setEmail( $bookingInfo->Customer->Email ); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -226,14 +226,14 @@ discard block |
||
| 226 | 226 | ->setCancelUrl( apply_filters( 'eduadmin-cancel-url', $defaultCancel ) ) |
| 227 | 227 | ->getPaymentUrl(); |
| 228 | 228 | |
| 229 | - if ( $wpForm->accepted ) { |
|
| 230 | - if ( 'no' === $this->get_option( 'testrun', 'no' ) ) { |
|
| 229 | + if ( $wpForm->accepted ) {
|
|
| 230 | + if ( 'no' === $this->get_option( 'testrun', 'no' ) ) {
|
|
| 231 | 231 | echo '<script type="text/javascript">location.href = "' . $wpForm->url . '";</script>'; |
| 232 | - } else { |
|
| 232 | + } else {
|
|
| 233 | 233 | echo '<script type="text/javascript">location.href = "' . $wpForm->testurl . '";</script>'; |
| 234 | 234 | } |
| 235 | - } else { |
|
| 236 | - add_filter( 'edu-booking-error', function( $errors ) use ( &$wpForm ) { |
|
| 235 | + } else {
|
|
| 236 | + add_filter( 'edu-booking-error', function( $errors ) use ( &$wpForm ) {
|
|
| 237 | 237 | $errors[] = $wpForm->errormessage; |
| 238 | 238 | } ); |
| 239 | 239 | } |