question

zorencen avatar image
zorencen asked chanel Deactivated answered

DECLINED: Over limit / Insufficient funds.

Hi.

I'm currently use https://apisandbox.dev.clover.com/v3/merchants/#{Merchant}/orders for create and get order_id, and after use this for ruby https://github.com/cloverhackathons/DeveloperPayAPI/blob/master/ruby/webpay.rb but the result with a real credit card with credit and transaction is (DECLINED: Over limit / Insufficient funds.).

My code is:

  target_env = "https://sandbox.dev.clover.com/v2/merchant/"


    # GET to /v2/merchant/{mId}/pay/key
    url = "https://apisandbox.dev.clover.com/v2/merchant/#{Merchant}/pay/key?access_token=#{Api_token}"
    uri = URI(url)
    response = Net::HTTP.get(uri)
    json_response = JSON.parse(response)
    modulus = json_response["modulus"].to_i
    exponent = json_response["exponent"].to_i
    prefix = json_response["prefix"]


    #rsa
    rsa = OpenSSL::PKey::RSA.new.tap do |rsa|
     e = OpenSSL::BN.new(exponent)
     n = OpenSSL::BN.new(modulus)
     rsa.set_key(n,e, d=nil)
    end


    # create a cipher from the RSA key and use it to encrypt the card number, prepended with the prefix from GET /v2/merchant/{mId}/pay/key
    encrypted = rsa.public_encrypt(prefix + credit_card[:number], OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)


    # Base64 encode the resulting encrypted data into a string to Clover as the 'cardEncrypted' property.
    card_encrypted = Base64.encode64(encrypted)


    post_data =
      {
        "orderId": @cart_clover_id,
        "tipAmount": 0,
        "taxAmount": 0,
        "expMonth": credit_card[:exp_date].first(2).to_i,
        "cvv": credit_card[:cvv],
        "amount": (cart.amount.to_f * 100),
        "currency": "usd",
        "last4": credit_card[:number].last(4),
        "expYear": ('20' + credit_card[:exp_date].last(2)).to_i,
        "first6": credit_card[:number].first(6),
        "cardEncrypted": card_encrypted
      }.to_json


    uri = URI("#{target_env + Merchant}/pay")


    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    request = Net::HTTP::Post.new(uri.request_uri, header)
    request.body = post_data
    JSON.parse(http.request(request).body)
Developer Pay API
10 |2000

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

1 Answer

chanel avatar image
chanel Deactivated answered
If your implementation was off, you would get a CRYPTO_FAILURE or Invalid Card error. Once you send Clover valid and encrypted information, we simply pass it on to be processed. Your error is caused during the actual payment process (after it's out of Clover's hands). This means that your card either has insufficient funds or is over the appropriate credit limit.
10 |2000

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