jharna27 avatar image
jharna27 asked ·

400 When making a Payment

The following piece of code that I was using was running perfectly until a few hours ago. But now throws error.

    # create a cipher from the RSA key and use it to encrypt the card number, prepended with the prefix 
    #from GET /v2/merchant/{muid}/pay/key
    cipher =
    # encode str to byte (
    encrypted = cipher.encrypt((prefix + cardNumber).encode())

    # Base64 encode the resulting encrypted data into a string to use as the cardEncrypted' property.
    cardEncrypted = b64encode(encrypted)

    post_data = {
        "orderId": orderId,
        "currency": "usd",
        "amount": int(total),
        "expMonth": expMonth,
        "cvv": CVV,
        "expYear": expYear,
        "cardEncrypted": cardEncrypted,
        "last4": cardNumber[-4:],
        "first6": cardNumber[0:6]

    posturl = environment + "v2/merchant/" + muid + "/pay"
    response =,headers = headers,data= post_data)
    if response.status_code != 200:
        print(str(response.status_code)+"Something went wrong during developer pay")

400: Cannot Parse JSON error.

Please help

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

It would be helpful if you would tell us what environment you are making the request in and provide your merchant id.

0 Likes 0 · ·
jharna27 avatar image jharna27 David Marginian ♦♦ ·

I am running a Python script, REST API... and the merchant id is RCTST0000008099, muid = "G6ZYXRGX6VPY1"

0 Likes 0 · ·

Are you sure you are making your request against the sandbox url? Because that is a sandbox merchant. I looked at the logs and I do see the pay endpoint being hit (in sandbox) as of yesterday for your merchant but we are returning a 200 for every single request (there are 0 400 responses being sent by us in the last 30 days). Also, the developer pay API is going to be out of service in the relatively near future, you should be using our ecomm API -

0 Likes 0 · ·
Show more comments

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community