Validation of Bagisto's payment method registration API
-
Thank you for all your help
"POST /api/checkout/onepage/payment-methods" seems to send the following value
"payment": { "method": "cashondelivery",. "method_title": "Cash On Delivery",. "description": "Cash On Delivery",. "sort": 1,. "image": "https://localhost/themes/shop/default/build/assets/cash-on-delivery-73061c49.png" }
This seems to be the only validation.
Webkul/Shop/src/Http/Controllers/API/OnepageController.php
public function storePaymentMethod(). { $validatedData = $this->validate(request(), [ 'payment' => 'required',. ]); ~~~~~~~~~~~~~~~~~~~~ }
I think you also need to validate the "payment.method", is it validated?
Currently, if there is no "payment.method", it barely seems to work with an error that the array key does not exist at the registration point.
Webkul/Checkout/src/Cart.php
public function savePaymentMethod($payment) { ~~~ $cartPayment->method = $payment['method']; ~~~ }
Is it OK that the only data used here is "payment.method" and no other values are needed?
-
@tmss said in Validation of Bagisto's payment method registration API:
public function storePaymentMethod().
{
$validatedData = $this->validate(request(), [
'payment' => 'required',.
]);
~~~~~~~~~~~~~~~~~~~~
}Yes, this method is validated.
And it is ok and depends on your requirements what values you need to add.Thanks & Regards..!!
-
You use it in a variety of patterns.
I don't know where it will be used, but it was helpful.Thank you so much!