label LiteCart Fan Từ Australia Thành viên kể từ thg 12 2018 label 16 thg 4 2024 07:56 The Stripe fraud rules are really good. And we are able to stop most fraud with various rules. But the rules would be even better if we could set up a rule to request 3D Secure for a couple of high risk products. But to do this, we need to use Metadata. eg. Stripe gives an example: ::product_sku:: = 'expensive_sku' But it seems no metadata is passed on with this add-on? Is it possible to pass on metadata with the product_sku or product_name ? Thanks
tim Founder Từ Sweden Thành viên kể từ thg 5 2013 tim 16 thg 4 2024 20:58 Sure just open pm_stripe_checkout.inc.php and squeeze it in the $request. 😄 Maybe you can teach me something. I always wondered what meta data could be useful for. To trigger 3DS manually, set payment_method_options.card.request_three_d_secure to to any or challenge. https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-payment_method_options-card-request_three_d_secure Metadata is a $request parameter named metadata with key and value pairs. Stripe never collected sku for line items. Which is odd.
label LiteCart Fan Từ Australia Thành viên kể từ thg 12 2018 label 17 thg 4 2024 02:43 Thanks for the reply. But it is beyond me. Ideally I could include metadata with a key such as SKU & value as the SKUs. If that wasn't possible because the SKUs aren't collected in the add-on, the product names would also be OK, as fraud rules can be created like: Request 3D Secure if ::title:: INCLUDES 'High Risk Product Title' Request 3D Secure if ::SKU:: = '5A381D' Looking at the $request, I could only think of: 'metadata' => [], Which is the same as 'line_items'. I know this would be wrong, because it also needs to have a key :)
tim Founder Từ Sweden Thành viên kể từ thg 5 2013 tim 17 thg 4 2024 16:39 I don't think meta data can be related to any item in the checkout request. More like order meta data. But it sounds like you could do the condition on your end like this: 'Name 1', 'Name 2', ] as $needle) { if (str_contains($item['name'], $needle)) { $request['payment_method_options']['card']['request_three_d_secure'] = 'any'; } }``` or for sku: ```if (in_array($item['sku'], ['ABC001', 'DEF002'])) { $request['payment_method_options']['card']['request_three_d_secure'] = 'any'; }```
label LiteCart Fan Từ Australia Thành viên kể từ thg 12 2018 label 23 thg 4 2024 01:22 Thanks. I'm not sure if I did it correctly or not? It didn't work (3D Secure wasn't requested). Note: I changed the ABC001 & DEF002 SKU's in the code. In the code below I have copied a few lines above, and a few lines below to show where I put the new code. 'cancel_url' => document::ilink('checkout'), ]; if (in_array($item['sku'], ['ABC001', 'DEF002'])) { $request['payment_method_options']['card']['request_three_d_secure'] = 'any'; } if ($customer_id = $this->_get_remote_customer_id($order->data['customer']['email'])) { $request['customer'] = $customer_id; } else {```
tim Founder Từ Sweden Thành viên kể từ thg 5 2013 tim 23 thg 4 2024 01:53 If you are doing this outside the foreach ($order->data['items']) scope you will have to produce a new iterator: if (in_array($item['sku'], ['ABC001', 'DEF002'])) { // Check sku $request['payment_method_options']['card']['request_three_d_secure'] = 'any'; // do something because sku was matched break; // Escape the loop as we don't need more cycles } } Otherwise it will only check the last $item that was defined as a variable in the previous iterator.
label LiteCart Fan Từ Australia Thành viên kể từ thg 12 2018 label 23 thg 4 2024 02:24 Thanks. I added this, and from a quick test (1 order), it seems to be working :)
tim Founder Từ Sweden Thành viên kể từ thg 5 2013 tim 23 thg 4 2024 20:22 That is great to hear, well done :)