[JAVA] When I think about the 402 error that suddenly appeared in the middle of the introduction of PAY.jp, there was an unexpected place

Today, I have already done the task of introducing Pay, jp and processing payments with a credit card, and I would like to describe the 402 error that appeared on the console in the middle stage.

What does the 402 error mean?

402 Payment Required (Reservation code for future use) http://www5.plala.or.jp/vaio0630/mail/st_code.htmより That's right, but I didn't understand the meaning even if I saw this. If you look a little closer, it says that it is not currently implemented due to an error that appears when payment is required. The description at that time was like this.


const formResult = document.getElementById("charge-form");
    const formData = new FormData(formResult);

const card = {
      number: formData.get("item[number]"),
      cvc: formData.get("item[cvc]"),
      exp_month: formData.get("item[exp_month]"),
      exp_year: `20${formData.get("item[exp_year]")}`,

    Payjp.createToken(card, (status, response) => {
      if (status == 200) {
        const token = response.id;
    }); //Not all, some omitted//

In the part from Payjp.createToken ~, if the status code is 200 (200 means success) in the if statement, the token information is displayed on the console. Considering this and 402, I reviewed the description from const card ~. Up to that point, I had a good log, and this is the only reason for the reservation code.


<%= form_with model: @item, url: item_purchases_path, id: 'charge-form', class: 'transaction-form-wrap',local: true do |f| %>

I was pulling the id of this part from the above view code. First of all, the reason for the error was that the @item part had to bring in a different instance. Lol On the contrary, I wondered why @item worked normally so far. It's a rudimentary error when I try to solve it, but it worked fine up to this point, which caused confusion and took a lot of time to solve: joy:


Until now, when thinking about the reason for the error, if it was rails, the error amount was solid and it was better to check the error under MVC. And even with regard to JS, I felt that I was blind spotted this time because there were many basic parts so far, and the error part was almost a mistake without JS. The description of rails is correct because it was so successful! It took me an hour and a half, but it was a very valuable experience to know that there was a postpaid feeling of such an error. I'm very sorry for the title of 402 error. Lol Thank you for reading.

Recommended Posts

When I think about the 402 error that suddenly appeared in the middle of the introduction of PAY.jp, there was an unexpected place
In WSL2, when I did `docker-compose up`, I got an error saying that the sh file was not found.
I want you to put the story that the error was solved when you stabbed the charger in the corner of your head
When I was worried about static methods in java interface, I arrived in the order of name interpretation
I want to make the frame of the text box red when there is an input error
I thought about an extension that can select the color of placeHolder in one shot with UITextFiled
I want to display an error message when registering in the database
The strongest Omikuji app that only I, an EKS Lover, can think of
Fall 2017 Security Specialist I checked the frequency of words that appeared in the morning 2
About the solution of the error that occurred when trying to create a Japanese file of devise in the Docker development environment
The part I was addicted to in "Introduction to Ajax in Java Web Applications" of NetBeans
[JUnit] I suddenly got an initialization Error in the JUnit test that worked normally until the day before; background and solution memorandum
About the error that occurred when adding the column name in rails (rails db: migrate, rails db: rollback, add)
A story that I realized that I had to study as an engineer in the first place
I was confused because there was a split in the Array
[Docker] The story that an error occurred in docker-compose up
A memo of the update command when npm install causes an error in GitHub Action etc.