Update a Transaction

This code steps you through the process of updating an existing transaction (i.e. for tips).

There are three outcomes when processing credit card transactions:

  1. Approved
  2. Declined
  3. Error

'Approved' transactions can be charged against customers' credit cards. 'Declined' transactions can't be charged. As a result, in order to test the process of charging a customer's credit card, you must first pass an odd dollar amount. This returns the transaction with an 'Approved' status. You can then charge the credit card to complete the transaction.

An error could result from a variety of conditions such as missing data, invalid card numbers, and expiration dates provided in invalid formats.

The following sample code calls a routine from our Code Library.
Download BluePay.php
Or, download via GitHub

# BluePay Ruby Sample code.
# This code sample runs a $3.00 Credit Card Sale transaction
# against a customer using test payment information. If
# approved, a 2nd transaction is run to update the first transaction
# to $5.75, $2.75 more than the original $3.00.
# If using TEST mode, odd dollar amounts will return
# an approval and even dollar amounts will return a decline.

require_relative "../../lib/bluepay.rb"

ACCOUNT_ID = "Merchant's Account ID"
SECRET_KEY = "Merchant's Secret Key"

payment = BluePay.new(
  account_id: ACCOUNT_ID, 
  secret_key: SECRET_KEY, 
  mode: MODE

  first_name: "Bob",
  last_name: "Tester",
  address1: "123 Test St.",
  address2: "Apt #500",
  city: "Testville",
  state: "IL",
  zip_code: "54321",
  country: "USA",
  phone: "123-123-1234", 
  email: "[email protected]

  cc_number: "4111111111111111", # Customer Credit Card Number
  cc_expiration: "1225", # Card Expiration Date: MMYY
  cvv2: "123" # Card CVV2

payment.sale(amount: "3.00") # Sale Amount: $3.00

# Makes the API Request for processing the sale

# If transaction was approved..
if payment.successful_transaction? 

  payment_update = BluePay.new(
    account_id: ACCOUNT_ID, 
    secret_key: SECRET_KEY, 
    mode: MODE

  # Creates an update transaction against previous sale
    trans_id: payment.get_trans_id, # id of previous transaction to update
    amount: "5.75" # add $2.75 to previous amount

  # Makes the API Request to process update

  # Reads the response from BluePay
  puts "TRANSACTION STATUS: " + payment_update.get_status
  puts "TRANSACTION MESSAGE: " + payment_update.get_message
  puts "TRANSACTION ID: " + payment_update.get_trans_id
  puts "AVS RESPONSE: " + payment_update.get_avs_code
  puts "CVV2 RESPONSE: " + payment_update.get_cvv2_code
  puts "MASKED PAYMENT ACCOUNT: " + payment_update.get_masked_account
  puts "CARD TYPE: " + payment_update.get_card_type
  puts "AUTH CODE: " + payment_update.get_auth_code
  puts payment_update.get_message
Can’t find what you’re
looking for? We can help.

Contact 800-350-2684 for Integration Support.

  • Microsoft Gold Partner Badge
  • 2018 American Business Awards Gold Stevie® Winner Badge for Best Payment and Electronic Commerce Solution
  • 2018 CNP Awards Customer Choice Winner Badge for Best E-Commerce Platform/Gateway
  • Best in Biz Awards 2018 Silver Winner Badge for Business Development Department of the Year
  • TSG Gateway Awards 2019 BluePay
BluePay Processing, LLC is a registered ISO of Wells Fargo Bank, N.A., Concord, CA, 94524 U.S.A.
BluePay Canada ULC, is a Registered ISO/MSP of Peoples Trust Company, Vancouver, Canada.