@@ -5,7 +5,6 @@ |
||
| 5 | 5 | |
| 6 | 6 | use Svea\WebPay\WebPay; |
| 7 | 7 | use Svea\WebPay\WebPayItem; |
| 8 | -use Svea\WebPay\Config\ConfigurationService; |
|
| 9 | 8 | use Svea\WebPay\Response\SveaResponse; |
| 10 | 9 | |
| 11 | 10 | if ( ! class_exists( 'EDU_SveaWebPay' ) ): |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $zipPreset = WebPayItem::presetValue() |
| 207 | - ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::POSTAL_CODE ) |
|
| 208 | - ->setValue( ! empty( $bookingInfo->Customer->InvoiceZip ) ? $bookingInfo->Customer->InvoiceZip : $bookingInfo->Customer->Zip ) |
|
| 209 | - ->setIsReadonly( false ); |
|
| 207 | + ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::POSTAL_CODE ) |
|
| 208 | + ->setValue( ! empty( $bookingInfo->Customer->InvoiceZip ) ? $bookingInfo->Customer->InvoiceZip : $bookingInfo->Customer->Zip ) |
|
| 209 | + ->setIsReadonly( false ); |
|
| 210 | 210 | $wpOrder->addPresetValue( $zipPreset ); |
| 211 | 211 | |
| 212 | 212 | if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) { |
@@ -218,9 +218,9 @@ discard block |
||
| 218 | 218 | if ( ! empty( $bookingInfo->Customer->Phone ) ) { |
| 219 | 219 | $customer->setPhoneNumber( $bookingInfo->Customer->Phone ); |
| 220 | 220 | $phonePreset = WebPayItem::presetValue() |
| 221 | - ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::PHONE_NUMBER ) |
|
| 222 | - ->setValue( $bookingInfo->Customer->Phone ) |
|
| 223 | - ->setIsReadonly( false ); |
|
| 221 | + ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::PHONE_NUMBER ) |
|
| 222 | + ->setValue( $bookingInfo->Customer->Phone ) |
|
| 223 | + ->setIsReadonly( false ); |
|
| 224 | 224 | $wpOrder->addPresetValue( $phonePreset ); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | $emailPreset = WebPayItem::presetValue() |
| 234 | - ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::EMAIL_ADDRESS ) |
|
| 235 | - ->setValue( ! empty( $bookingInfo->Customer->InvoiceEmail ) ? $bookingInfo->Customer->InvoiceEmail : $bookingInfo->Customer->Email ) |
|
| 236 | - ->setIsReadonly( false ); |
|
| 234 | + ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::EMAIL_ADDRESS ) |
|
| 235 | + ->setValue( ! empty( $bookingInfo->Customer->InvoiceEmail ) ? $bookingInfo->Customer->InvoiceEmail : $bookingInfo->Customer->Email ) |
|
| 236 | + ->setIsReadonly( false ); |
|
| 237 | 237 | $wpOrder->addPresetValue( $emailPreset ); |
| 238 | 238 | |
| 239 | 239 | $customer->setIpAddress( EDU()->get_ip_adress() ); |
@@ -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 = ''; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * Initializes the settingsfields |
| 35 | 35 | */ |
| 36 | - public function init_form_fields() { |
|
| 36 | + public function init_form_fields() {
|
|
| 37 | 37 | $this->setting_fields = array( |
| 38 | 38 | 'enabled' => array( |
| 39 | 39 | 'title' => __( 'Enabled', 'eduadmin-sveawebpay' ), |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * |
| 67 | 67 | */ |
| 68 | - public function process_svearesponse() { |
|
| 68 | + public function process_svearesponse() {
|
|
| 69 | 69 | |
| 70 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
| 70 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
|
|
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | - if ( ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) ) || ( isset( $_REQUEST['edu-cancel'] ) && isset( $_REQUEST['svea'] ) ) ) { |
|
| 73 | + if ( ( isset( $_REQUEST['edu-thankyou'] ) && isset( $_REQUEST['svea'] ) ) || ( isset( $_REQUEST['edu-cancel'] ) && isset( $_REQUEST['svea'] ) ) ) {
|
|
| 74 | 74 | |
| 75 | 75 | $eclId = ( isset( $_REQUEST['edu-thankyou'] ) ? $_REQUEST['edu-thankyou'] : $_REQUEST['edu-cancel'] ); |
| 76 | 76 | |
@@ -99,28 +99,28 @@ discard block |
||
| 99 | 99 | $selectedCountry = 'SE'; |
| 100 | 100 | |
| 101 | 101 | $invoiceCountry = $ebi->Customer->InvoiceCountry; |
| 102 | - if ( empty( $invoiceCountry ) ) { |
|
| 102 | + if ( empty( $invoiceCountry ) ) {
|
|
| 103 | 103 | $invoiceCountry = $ebi->Customer->Country; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - foreach ( $countries as $country ) { |
|
| 107 | - if ( $invoiceCountry == $country->CountryName ) { |
|
| 106 | + foreach ( $countries as $country ) {
|
|
| 107 | + if ( $invoiceCountry == $country->CountryName ) {
|
|
| 108 | 108 | $selectedCountry = $country->CountryCode; |
| 109 | 109 | break; |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) { |
|
| 113 | + if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
|
|
| 114 | 114 | $wpConfig = new EduSveaWebPayTestConfig( $this ); |
| 115 | - } else { |
|
| 115 | + } else {
|
|
| 116 | 116 | $wpConfig = new EduSveaWebPayProductionConfig( $this ); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $response = ( new SveaResponse( $_REQUEST, $selectedCountry, $wpConfig ) )->getResponse(); |
| 120 | 120 | |
| 121 | - if ( $response->accepted ) { |
|
| 121 | + if ( $response->accepted ) {
|
|
| 122 | 122 | EDU()->api->SetValidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID ); |
| 123 | - } else { |
|
| 123 | + } else {
|
|
| 124 | 124 | EDU()->api->SetInvalidPayment( EDU()->get_token(), $ebi->EventBooking->EventCustomerLnkID ); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | /** |
| 137 | 137 | * @param $bookingInfo EduAdminBookingInfo |
| 138 | 138 | */ |
| 139 | - public function process_booking( $bookingInfo = null ) { |
|
| 140 | - if ( 'no' === $this->get_option( 'enabled', 'no' ) ) { |
|
| 139 | + public function process_booking( $bookingInfo = null ) {
|
|
| 140 | + if ( 'no' === $this->get_option( 'enabled', 'no' ) ) {
|
|
| 141 | 141 | return; |
| 142 | 142 | } |
| 143 | - if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) { |
|
| 143 | + if ( isset( $_POST['act'] ) && 'bookCourse' === $_POST['act'] ) {
|
|
| 144 | 144 | $bookingInfo->NoRedirect = true; |
| 145 | 145 | |
| 146 | 146 | $countries = EDU()->api->GetCountries( EDU()->get_token(), 'Swedish' ); |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | $selectedLocale = 'sv-SE'; |
| 150 | 150 | |
| 151 | 151 | $invoiceCountry = $bookingInfo->Customer->InvoiceCountry; |
| 152 | - if ( empty( $invoiceCountry ) ) { |
|
| 152 | + if ( empty( $invoiceCountry ) ) {
|
|
| 153 | 153 | $invoiceCountry = $bookingInfo->Customer->Country; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - foreach ( $countries as $country ) { |
|
| 157 | - if ( $invoiceCountry == $country->CountryName ) { |
|
| 156 | + foreach ( $countries as $country ) {
|
|
| 157 | + if ( $invoiceCountry == $country->CountryName ) {
|
|
| 158 | 158 | $selectedCountry = $country->CountryCode; |
| 159 | - if ( ! empty( $country->CultureName ) ) { |
|
| 159 | + if ( ! empty( $country->CultureName ) ) {
|
|
| 160 | 160 | $selectedLocale = $country->CultureName; |
| 161 | 161 | } |
| 162 | 162 | break; |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | $currency = get_option( 'eduadmin-currency', 'SEK' ); |
| 169 | 169 | |
| 170 | - if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) { |
|
| 170 | + if ( 'no' !== $this->get_option( 'testrun', 'no' ) ) {
|
|
| 171 | 171 | $wpConfig = new EduSveaWebPayTestConfig( $this ); |
| 172 | - } else { |
|
| 172 | + } else {
|
|
| 173 | 173 | $wpConfig = new EduSveaWebPayProductionConfig( $this ); |
| 174 | 174 | } |
| 175 | 175 | #$wpOrder = WebPay::createOrder( $wpConfig ); |
@@ -185,21 +185,21 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | $customer = WebPayItem::companyCustomer(); |
| 187 | 187 | |
| 188 | - if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) { |
|
| 188 | + if ( ! empty( $bookingInfo->Customer->InvoiceName ) ) {
|
|
| 189 | 189 | $customer->setCompanyName( $bookingInfo->Customer->InvoiceName ); |
| 190 | - } else { |
|
| 190 | + } else {
|
|
| 191 | 191 | $customer->setCompanyName( $bookingInfo->Customer->CustomerName ); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) { |
|
| 194 | + if ( ! empty( $bookingInfo->Customer->InvoiceAddress1 ) ) {
|
|
| 195 | 195 | $customer->setStreetAddress( $bookingInfo->Customer->InvoiceAddress1 ); |
| 196 | - } else { |
|
| 196 | + } else {
|
|
| 197 | 197 | $customer->setStreetAddress( $bookingInfo->Customer->Address1 ); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) { |
|
| 200 | + if ( ! empty( $bookingInfo->Customer->InvoiceZip ) ) {
|
|
| 201 | 201 | $customer->setZipCode( $bookingInfo->Customer->InvoiceZip ); |
| 202 | - } else { |
|
| 202 | + } else {
|
|
| 203 | 203 | $customer->setZipCode( $bookingInfo->Customer->Zip ); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -209,13 +209,13 @@ discard block |
||
| 209 | 209 | ->setIsReadonly( false ); |
| 210 | 210 | $wpOrder->addPresetValue( $zipPreset ); |
| 211 | 211 | |
| 212 | - if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) { |
|
| 212 | + if ( ! empty( $bookingInfo->Customer->InvoiceCity ) ) {
|
|
| 213 | 213 | $customer->setLocality( $bookingInfo->Customer->InvoiceCity ); |
| 214 | - } else { |
|
| 214 | + } else {
|
|
| 215 | 215 | $customer->setLocality( $bookingInfo->Customer->City ); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( ! empty( $bookingInfo->Customer->Phone ) ) { |
|
| 218 | + if ( ! empty( $bookingInfo->Customer->Phone ) ) {
|
|
| 219 | 219 | $customer->setPhoneNumber( $bookingInfo->Customer->Phone ); |
| 220 | 220 | $phonePreset = WebPayItem::presetValue() |
| 221 | 221 | ->setTypeName( \Svea\WebPay\Checkout\Model\PresetValue::PHONE_NUMBER ) |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | $wpOrder->addPresetValue( $phonePreset ); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) { |
|
| 227 | + if ( ! empty( $bookingInfo->Customer->InvoiceEmail ) ) {
|
|
| 228 | 228 | $customer->setEmail( $bookingInfo->Customer->InvoiceEmail ); |
| 229 | - } else { |
|
| 229 | + } else {
|
|
| 230 | 230 | $customer->setEmail( $bookingInfo->Customer->Email ); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | //$wpForm = $wpBuild->getPaymentUrl(); |
| 271 | 271 | $wpForm = $wpBuild->createOrder(); |
| 272 | 272 | //print_r( $wpForm ); |
| 273 | - if ( array_key_exists( 'Gui', $wpForm ) ) { |
|
| 273 | + if ( array_key_exists( 'Gui', $wpForm ) ) {
|
|
| 274 | 274 | echo $wpForm['Gui']['Snippet']; |
| 275 | 275 | } |
| 276 | 276 | /*if ( $wpForm->accepted ) { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class EduSveaWebPayBaseConfig implements \Svea\WebPay\Config\ConfigurationProvider { |
|
| 3 | +class EduSveaWebPayBaseConfig implements \Svea\WebPay\Config\ConfigurationProvider {
|
|
| 4 | 4 | /** |
| 5 | 5 | * @var EDU_SveaWebPay |
| 6 | 6 | */ |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @param EDU_SveaWebPay $_plugin |
| 13 | 13 | */ |
| 14 | - public function __construct( $_plugin ) { |
|
| 14 | + public function __construct( $_plugin ) {
|
|
| 15 | 15 | $this->plugin = $_plugin; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException in case of unsupported $type |
| 27 | 27 | * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException in case of unsupported $country |
| 28 | 28 | */ |
| 29 | - public function getUsername( $type, $country ) { |
|
| 29 | + public function getUsername( $type, $country ) {
|
|
| 30 | 30 | echo 'username'; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException in case of unsupported $type |
| 42 | 42 | * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException in case of unsupported $country |
| 43 | 43 | */ |
| 44 | - public function getPassword( $type, $country ) { |
|
| 44 | + public function getPassword( $type, $country ) {
|
|
| 45 | 45 | echo 'password'; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @throws \Svea\WebPay\HostedService\Helper\InvalidTypeException in case of unsupported $type |
| 57 | 57 | * @throws \Svea\WebPay\HostedService\Helper\InvalidCountryException in case of unsupported $country |
| 58 | 58 | */ |
| 59 | - public function getClientNumber( $type, $country ) { |
|
| 59 | + public function getClientNumber( $type, $country ) {
|
|
| 60 | 60 | echo 'client'; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param string $type Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings |
| 69 | 69 | * @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE |
| 70 | 70 | */ |
| 71 | - public function getMerchantId( $type, $country ) { |
|
| 71 | + public function getMerchantId( $type, $country ) {
|
|
| 72 | 72 | $merchantId = $this->plugin->get_option( 'merchant_key', '' ); |
| 73 | 73 | |
| 74 | 74 | return $merchantId; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param string $type Svea\WebPay\Config\ConfigurationProvider::INVOICE_TYPE, ::PAYMENTPLAN_TYPE can be used if needed to match different configuration settings |
| 83 | 83 | * @param string $country CountryCode eg. SE, NO, DK, FI, NL, DE |
| 84 | 84 | */ |
| 85 | - public function getSecret( $type, $country ) { |
|
| 85 | + public function getSecret( $type, $country ) {
|
|
| 86 | 86 | $secret = $this->plugin->get_option( 'merchant_secret', '' ); |
| 87 | 87 | |
| 88 | 88 | return $secret; |
@@ -98,7 +98,8 @@ discard block |
||
| 98 | 98 | * @return string |
| 99 | 99 | */ |
| 100 | 100 | |
| 101 | - public function getEndPoint( $type ) { /* Defined in subclasses */ |
|
| 101 | + public function getEndPoint( $type ) {
|
|
| 102 | +/* Defined in subclasses */ |
|
| 102 | 103 | } |
| 103 | 104 | |
| 104 | 105 | /** |
@@ -106,7 +107,7 @@ discard block |
||
| 106 | 107 | * |
| 107 | 108 | * @return string |
| 108 | 109 | */ |
| 109 | - public function getCheckoutMerchantId() { |
|
| 110 | + public function getCheckoutMerchantId() {
|
|
| 110 | 111 | $merchantId = $this->plugin->get_option( 'merchant_key', '' ); |
| 111 | 112 | |
| 112 | 113 | return $merchantId; |
@@ -117,22 +118,22 @@ discard block |
||
| 117 | 118 | * |
| 118 | 119 | * @return string |
| 119 | 120 | */ |
| 120 | - public function getCheckoutSecret() { |
|
| 121 | + public function getCheckoutSecret() {
|
|
| 121 | 122 | $secret = $this->plugin->get_option( 'merchant_secret', '' ); |
| 122 | 123 | |
| 123 | 124 | return $secret; |
| 124 | 125 | } |
| 125 | 126 | |
| 126 | - public function getIntegrationCompany() { |
|
| 127 | + public function getIntegrationCompany() {
|
|
| 127 | 128 | return 'MultiNet Interactive AB : EduAdmin WordPress-plugin'; |
| 128 | 129 | } |
| 129 | 130 | |
| 130 | - public function getIntegrationPlatform() { |
|
| 131 | + public function getIntegrationPlatform() {
|
|
| 131 | 132 | return 'EduAdmin WordPress'; |
| 132 | 133 | } |
| 133 | 134 | } |
| 134 | 135 | |
| 135 | -class EduSveaWebPayProductionConfig extends EduSveaWebPayBaseConfig { |
|
| 136 | +class EduSveaWebPayProductionConfig extends EduSveaWebPayBaseConfig {
|
|
| 136 | 137 | |
| 137 | 138 | /** |
| 138 | 139 | * Constants for the endpoint url found in the class ConfigurationService.php |
@@ -144,8 +145,8 @@ discard block |
||
| 144 | 145 | * @return string |
| 145 | 146 | */ |
| 146 | 147 | |
| 147 | - public function getEndPoint( $type ) { |
|
| 148 | - switch ( strtoupper( $type ) ) { |
|
| 148 | + public function getEndPoint( $type ) {
|
|
| 149 | + switch ( strtoupper( $type ) ) {
|
|
| 149 | 150 | case 'HOSTED': |
| 150 | 151 | return Svea\WebPay\Config\ConfigurationService::SWP_PROD_URL; |
| 151 | 152 | break; |
@@ -169,7 +170,7 @@ discard block |
||
| 169 | 170 | } |
| 170 | 171 | } |
| 171 | 172 | |
| 172 | -class EduSveaWebPayTestConfig extends EduSveaWebPayBaseConfig { |
|
| 173 | +class EduSveaWebPayTestConfig extends EduSveaWebPayBaseConfig {
|
|
| 173 | 174 | |
| 174 | 175 | /** |
| 175 | 176 | * Constants for the endpoint url found in the class ConfigurationService.php |
@@ -180,8 +181,8 @@ discard block |
||
| 180 | 181 | * @throws Exception |
| 181 | 182 | * @return string |
| 182 | 183 | */ |
| 183 | - public function getEndPoint( $type ) { |
|
| 184 | - switch ( strtoupper( $type ) ) { |
|
| 184 | + public function getEndPoint( $type ) {
|
|
| 185 | + switch ( strtoupper( $type ) ) {
|
|
| 185 | 186 | case 'HOSTED': |
| 186 | 187 | return Svea\WebPay\Config\ConfigurationService::SWP_TEST_URL; |
| 187 | 188 | break; |