PluginProbe
Pay with Vipps and MobilePay for WooCommerce / 6.2.2
Pay with Vipps and MobilePay for WooCommerce v6.2.2
6.2.3 6.2.2 6.2.1 6.2.0 6.1.10 6.1.9 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1.0 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 6.0.0 5.4.3 5.4.2 5.4.1 5.4.0 All 185 releases
← All changes | payment/VippsApi.class.php +9 -140 6.0.06.2.2 View file →
@@ -738,9 +738,9 @@
738 738 return $res;
739 739 }
740 740
741 741
742 - // This is Vipps Checkout IOK 2021-06-19
742 + // This is Checkout IOK 2021-06-19
743 743 // Updated for V3 2023-01-09
744 744 public function initiate_checkout($customerinfo,$order,$returnurl,$authtoken,$idempotency_key=null) {
745 745 $command = 'checkout/v3/session';
746 746 $static_shipping = $order->get_meta('_vipps_static_shipping');
@@ -814,9 +814,9 @@
814 814 $transaction['paymentDescription'] = substr($transaction['paymentDescription'],0,90); // Add some slack if this happens. IOK 2019-10-17
815 815 }
816 816
817 817
818 - ## Vipps Checkout Shipping
818 + ## Checkout Shipping
819 819 $shippingcallback = $this->gateway->shipping_details_callback_url($authtoken, $orderid);
820 820 $shippingcallback .= "/v3/checkout/" . $vippsorderid . "/shippingDetails"; # because this is how eCom v2 does it.
821 821 $gw = $this->gateway;
822 822 if ($needs_shipping) {
@@ -888,9 +888,9 @@
888 888 $configuration['elements'] = "Full";
889 889 $configuration['customerInteraction'] = apply_filters('woo_vipps_checkout_customerInteraction', 'CUSTOMER_NOT_PRESENT', $orderid);
890 890 $configuration['userFlow'] = "WEB_REDIRECT"; // Change to NATIVE_REDIRECT for apps in below filter
891 891 // Require consent of email and openid sub - really for login
892 - $configuration['requireUserInfo'] = apply_filters('woo_vipps_checkout_requireUserInfo', $gw->get_option('requireUserInfo_checkout') == 'yes' , $orderid);
892 + $configuration['requireUserInfo'] = (bool) apply_filters('woo_vipps_checkout_requireUserInfo', $gw->get_option('requireUserInfo_checkout') == 'yes' , $orderid);
893 893
894 894
895 895 // IOK 2023-12-22 and we can add an order summary, so do so by default
896 896 $summarize = apply_filters('woo_vipps_checkout_show_order_summary', true, $order);
@@ -949,10 +949,10 @@
949 949 $configuration['customConsent'] = $customconsent;
950 950 }
951 951
952 952 if (!$needs_shipping) {
953 - $nocontacts = $this->gateway->get_option('noContactFields') == 'yes';
954 - $noaddress = $this->gateway->get_option('noAddressFields') == 'yes';
953 + $nocontacts = (bool) ($this->gateway->get_option('noContactFields') == 'yes');
954 + $noaddress = (bool) ($this->gateway->get_option('noAddressFields') == 'yes');
955 955 if ($noaddress) {
956 956 $configuration['elements'] = "PaymentAndContactInfo";
957 957 }
958 958 // AddressFields cannot be enabled while ContactFields is disabled
@@ -1074,143 +1074,9 @@
1074 1074 }
1075 1075 return $res;
1076 1076 }
1077 1077
1078 - // Capture a payment made. Amount is in cents and required. IOK 2018-05-07
1079 - public function capture_payment($order,$amount,$requestid=1) {
1080 - $orderid = $order->get_meta('_vipps_orderid');
1081 1078
1082 - $command = 'Ecomm/v2/payments/'.$orderid.'/capture';
1083 - $msn = $this->get_merchant_serial();
1084 - $subkey = $this->get_key($msn);
1085 - if (!$subkey) {
1086 - throw new VippsAPIConfigurationException(__('The Vipps gateway is not correctly configured.','woo-vipps'));
1087 - $this->log(__('The Vipps gateway is not correctly configured.','woo-vipps'),'error');
1088 - }
1089 - if (!$msn) {
1090 - throw new VippsAPIConfigurationException(__('The Vipps gateway is not correctly configured.','woo-vipps'));
1091 - $this->log(__('The Vipps gateway is not correctly configured.','woo-vipps'),'error');
1092 - }
1093 - $headers = $this->get_headers($msn);
1094 - $headers['X-Request-Id'] = $requestid;
1095 -
1096 - $transaction = array();
1097 - // Ignore refOrderId - for child-transactions
1098 - $transaction['amount'] = round($amount);
1099 -
1100 - $shop_identification = apply_filters('woo_vipps_transaction_text_shop_id', home_url());
1101 -
1102 - $transaction['transactionText'] = __('Order capture for order','woo-vipps') . ' ' . $orderid . ' ' . $shop_identification;
1103 -
1104 - // The limit for the transaction text is 100. Ensure we don't go over. Thanks to Marco1970 on wp.org for reporting this. IOK 2019-10-17
1105 - $length = strlen($transaction['transactionText']);
1106 - if ($length>99) {
1107 - $this->log(__('The transaction text is too long! We are using a shorter transaction text to allow the transaction text to go through, but please check the \'woo_vipps_transaction_text_shop_id\' filter so that you can use a shorter name for your store', 'woo-vipps'));
1108 - $transaction['transactionText'] = __('Order capture for order','woo-vipps') . ' ' . $orderid;
1109 - $transaction['transactionText'] = substr($transaction['transactionText'],0,90); // Add some slack if this happens. IOK 2019-10-17
1110 - }
1111 -
1112 -
1113 -
1114 - $data = array();
1115 - $data['merchantInfo'] = array('merchantSerialNumber' => $msn);
1116 - $data['transaction'] = $transaction;
1117 -
1118 - $res = $this->http_call($msn,$command,$data,'POST',$headers,'json');
1119 - return $res;
1120 - }
1121 -
1122 - // Cancel a reserved but not captured payment IOK 2018-05-07
1123 - public function cancel_payment($order,$requestid=1) {
1124 - $orderid = $order->get_meta('_vipps_orderid');
1125 -
1126 - $command = 'Ecomm/v2/payments/'.$orderid.'/cancel';
1127 - $msn = $this->get_merchant_serial();
1128 - $subkey = $this->get_key($msn);
1129 - if (!$subkey) {
1130 - throw new VippsAPIConfigurationException(__('The Vipps gateway is not correctly configured.','woo-vipps'));
1131 - $this->log(__('The Vipps gateway is not correctly configured.','woo-vipps'),'error');
1132 - }
1133 - if (!$msn) {
1134 - throw new VippsAPIConfigurationException(__('The Vipps gateway is not correctly configured.','woo-vipps'));
1135 - $this->log(__('The Vipps gateway is not correctly configured.','woo-vipps'),'error');
1136 - }
1137 - $headers = $this->get_headers($msn);
1138 - $headers['X-Request-Id'] = $requestid;
1139 -
1140 - $transaction = array();
1141 - $transaction['transactionText'] = __('Order cancel for order','woo-vipps') . ' ' . $orderid . ' ';
1142 -
1143 - $data = array();
1144 - $data['merchantInfo'] = array('merchantSerialNumber' => $msn);
1145 - $data['transaction'] = $transaction;
1146 -
1147 - $res = $this->http_call($msn,$command,$data,'PUT',$headers,'json');
1148 - return $res;
1149 - }
1150 -
1151 - // Refund a captured payment. IOK 2018-05-08
1152 - public function refund_payment($order,$requestid=1,$amount=0,$cents=false) {
1153 - $orderid = $order->get_meta('_vipps_orderid');
1154 - $amount = $amount ? $amount : wc_format_decimal($order->get_total(),'');
1155 -
1156 - $command = 'Ecomm/v2/payments/'.$orderid.'/refund';
1157 - $msn = $this->get_merchant_serial();
1158 - $subkey = $this->get_key($msn);
1159 - if (!$subkey) {
1160 - throw new VippsAPIConfigurationException(__('The Vipps gateway is not correctly configured.','woo-vipps'));
1161 - $this->log(__('The Vipps gateway is not correctly configured.','woo-vipps'),'error');
1162 - }
1163 - if (!$msn) {
1164 - throw new VippsAPIConfigurationException(__('The Vipps gateway is not correctly configured.','woo-vipps'));
1165 - $this->log(__('The Vipps gateway is not correctly configured.','woo-vipps'),'error');
1166 - }
1167 - $headers = $this->get_headers($msn);
1168 - $headers['X-Request-Id'] = $requestid;
1169 -
1170 - // Ignore refOrderId - for child-transactions
1171 - $transaction = array();
1172 - // If we have passed the value as 'øre' we don't need to calculate any more.
1173 - if ($cents) {
1174 - $transaction['amount'] = $amount;
1175 - } else {
1176 - $transaction['amount'] = round($amount * 100);
1177 - }
1178 - $transaction['transactionText'] = __('Refund for order','woo-vipps') . ' ' . $orderid;
1179 -
1180 -
1181 - $data = array();
1182 - $data['merchantInfo'] = array('merchantSerialNumber' => $msn);
1183 - $data['transaction'] = $transaction;
1184 -
1185 - $res = $this->http_call($msn,$command,$data,'POST',$headers,'json');
1186 - return $res;
1187 - }
1188 -
1189 - // Used to retrieve shipping and user details for express checkout orders where relevant and the callback isn't coming.
1190 - public function payment_details ($order) {
1191 - $requestid=0;
1192 - $orderid = $order->get_meta('_vipps_orderid');
1193 - $command = 'Ecomm/v2/payments/'.$orderid.'/details';
1194 - $msn = $this->get_merchant_serial();
1195 - $subkey = $this->get_key($msn);
1196 - if (!$subkey) {
1197 - throw new VippsAPIConfigurationException(__('The Vipps gateway is not correctly configured.','woo-vipps'));
1198 - $this->log(__('The Vipps gateway is not correctly configured.','woo-vipps'),'error');
1199 - }
1200 - if (!$msn) {
1201 - throw new VippsAPIConfigurationException(__('The Vipps gateway is not correctly configured.','woo-vipps'));
1202 - $this->log(__('The Vipps gateway is not correctly configured.','woo-vipps'),'error');
1203 - }
1204 - $headers = $this->get_headers($msn);
1205 - $headers['X-Request-Id'] = $requestid;
1206 -
1207 - $data = array();
1208 -
1209 - $res = $this->http_call($msn,$command,$data,'GET',$headers,'json');
1210 - return $res;
1211 - }
1212 -
1213 1079 // Support for then new epayment API, which is also used by Checkout
1214 1080 // Cancel a reserved but not captured payment IOK 2018-05-07
1215 1081 // Currently must cancel the entire amount, but partial cancel will be possible.
1216 1082 public function epayment_cancel_payment($order,$requestid=1) {
@@ -1363,9 +1229,12 @@
1363 1229 return $res;
1364 1230 }
1365 1231
1366 1232 // Implement part of the userInfo api, just to be able to get user data from Express Orders that aren't express
1367 - // orders (because they didn't need shipping). In the future, will probably be used more + for integration with Login With Vipps
1233 + // orders (because they didn't need shipping).
1234 + // If a user has a sub, it is because we've added a scope to the epayment call, or because of integration with login.
1235 + // This is not used as of 2026-08-18, because we do not need to call this to retreive user details any more with ecom -
1236 + // we get that by just calling the payment details. Still may be useful in the future without depending on login integration. IOK 2026-08-18
1368 1237 public function get_userinfo($sub) {
1369 1238 $command = "vipps-userinfo-api/userinfo" . "/" . $sub;
1370 1239 $msn = $this->get_merchant_serial();
1371 1240 $subkey = $this->get_key($msn);