question

jharna27 avatar image
jharna27 asked David Marginian Deactivated commented

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.

##PAYMENTS
    
    # 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 = PKCS1_OAEP.new(RSAkey)
    # encode str to byte (https://eli.thegreenplace.net/2012/01/30/the-bytesstr-dichotomy-in-python-3)
    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"
    sleep(0.1)
    response = requests.post(posturl,headers = headers,data= post_data)
    
    if response.status_code != 200:
        print(response.text.encode('utf8'))
        print(str(response.status_code)+"Something went wrong during developer pay")
        sys.exit()

400: Cannot Parse JSON error.

Please help

Payments
8 comments
10 |2000

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

David Marginian avatar image David Marginian ♦♦ commented ·

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 ♦♦ commented ·

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

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

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 - https://docs.clover.com/docs/ecommerce-api-tutorials.

0 Likes 0 ·
Show more comments

0 Answers

·

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