Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Validation of Bagisto's payment method registration API

    General Discussion
    2
    3
    126
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tmss last edited by tmss

      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?

      Rishabh-Webkul 1 Reply Last reply Reply Quote 0
      • Rishabh-Webkul
        Rishabh-Webkul @tmss last edited by

        @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..!!

        1 Reply Last reply Reply Quote 0
        • T
          tmss last edited by

          @Rishabh-Webkul

          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!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post