Okay
  Public Ticket #2962999
Creating new Customer using API in site that requires approval
Closed

Comments

  •  6
    Nicolai started the conversation

    We have recently enabled approval requirement for manual approval for all customers that signs up using our "sign up" form in the main site. 

    But I also want to create users using the API, which worked great prior to enabled approval requirement. But now, customers created via API, is requireing manul approval in the admin interface! This is despite that I'm also sending:

     { key = "b2bking_account_approved", value = "yes" }

    How can I bypass the approval needed when I'm creating the users using API? 


  •  2,218
    WebWizards replied

    Hi Nicolai,

    Thank you for purchasing,


    What does your sign up form look like? Can you share a link or screenshot?

    If your form uses B2BKing registration roles, then you could try to disable B2BKing -> Settings -> Manual approval for all , and then go to B2BKing -> Registration Roles and set each role to manual. 

    Is that possible / does it make sense in your setup?



    Setting the b2bking_account_approved key to "yes" as you described is the correct approach. I'm guessing what happens is that even though you're creating customers via API, our plugin's functions are still running and setting it to "no" during creation.


    Looking forward to your reply,

    Kind regards,

    Stefan



  •  6
    Nicolai replied

    Hi. 

    I have just tried to implement your solution, which now brings me a step closer. Now it seems like the account gets approved, but it overwrites some of information I throw via the API. F.x. the user group isn't transferred, but manuel override of shipment/payment IS tranferred correctly. 

    Please see the attached PDF for examples and documentation...

    I will also send you both full postman and my C# code for reference - this will be send in a Private post.

    Best regards,

    Nicolai



  •   Nicolai replied privately
  •  6
    Nicolai replied

    After further investigation, I can add a (perhaps) usefull information:

    After creation, I have tried to send exactly the same information but as an "update" (PUT) on the newly created user. Then everyhting is updated, including correct B2BGroup and VAT ID.!

    So it seems like it has something to do with the sequence of meta-data uploaded via the API?

  •  6
    Nicolai replied

    (Sorry for all the spamming)

    I have now temporarily solved it by splitting my customer creation into two in my C# code. First I create the customer with all general data incl. all metadata concerning payment/shipping. Then I wait for 3-4 seconds, and make a new REST API call update to the customer id, with meta data on group  & vat.

    So now my site works, but it is not a pretty solution :)  

  •  2,218
    WebWizards replied

    Thanks for the update.

    So it seems like it has something to do with the sequence of meta-data uploaded via the API?

    This makes sense. I guess in the first call, our plugin's "user creation" action gets triggered and sets it to "no", but that no longer happens in the second, update call.