#chozboots

1 messages · Page 1 of 1 (latest)

rancid coveBOT
onyx jasper
frigid arrow
#

req_wnHcpQK0cbyh5

#

I can share more of the error if you need more information.

onyx jasper
frigid arrow
#
import wixLocation from 'wix-location';

$w.onReady(function () {
    $w("#submitButton").onClick((event) => {
        const payload = {
            name: {
                firstName: $w("#firstName").value,
                middleInitial: $w("#middleInitial").value,
                lastName: $w("#lastName").value,
            },
            address: {
                'line1': $w("#streetAddress").value,
                'city': $w("#city").value,
                'state': $w("#stateDropdown").value,
                'postal_code': $w("#zip").value,
            },
            email: $w("#email").value,
            phone: $w("#phone").value,
            instructionalDropdown: $w("#instructionalDropdown").value  // Changed from 'instructionalDropdownr' to 'instructionalDropdown'
        };

        fetch('http://<mylink>/checkout-session', {
            method: 'post',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify(payload),
        })
        .then((httpResponse) => {
            if (httpResponse.ok) {
                return httpResponse.json();
            } else {
                return Promise.reject("Fetch did not succeed");
            }
        })
        .then((json) => {
            wixLocation.to(`https://checkout.stripe.com/pay/${json.id}`);
        })
        .catch((err) => {
            console.error(err);
            $w("#errorMessage").text = "An error occurred. Please try again.";
            $w("#errorMessage").show(); // Show the error message when an error occurs

            setTimeout(() => {
                $w("#errorMessage").hide(); // Hide the error message after 5 seconds
            }, 5000);
        });
    });
});

By the way, this is the code I'm using to send form data that the customer object is using, if it helps.

frigid arrow
#

req_wnHcpQK0cbyh5z

#

That should be the correct one, the last character got cut off lol

#

Also, here is my error stream, if it helps.

File "app.py", line 23, in create_checkout_session
    customer = stripe.Customer.create(
  File "<path>\site-packages\stripe\api_resources\abstract\createable_api_resource.py", line 16, in create
    return cls._static_request(
  File "<path>\site-packages\stripe\api_resources\abstract\api_resource.py", line 139, in _static_request    
    response, api_key = requestor.request(method_, url_, params, headers)
  File "<path>\site-packages\stripe\api_requestor.py", line 122, in request
    resp = self.interpret_response(rbody, rcode, rheaders)
  File "<path>\site-packages\stripe\api_requestor.py", line 399, in interpret_response
    self.handle_error_response(rbody, rcode, resp.data, rheaders)
  File "<path>\site-packages\stripe\api_requestor.py", line 159, in handle_error_response
    raise err
stripe.error.InvalidRequestError: Request req_<request_id>: Invalid value type: {:line1=>"123 Example Street", :state=>"Alaska", :postal_code=>"55555", :city=>"Exampleville"} must be a string

Btw I'm using a Flask application for the backend

brittle hare
#

👋 taking over for my colleague. Let me catch up.

frigid arrow
#

Okee doke

brittle hare
#

the problem is not in the address field on the customer but rather when you add it to the metadata field

frigid arrow
#

Ohhhhh. I see.

brittle hare
#

the metadata dictionnary can only support key/value pairs which are both strings

frigid arrow
#

Ah, I gotcha. That makes sense.

#

I'll probably just drop it off since I'm going to be storing the form data in a separate database anyways.

#

Thanks for the help!