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)