Integration
There are two pieces of information you will require from BluePay for integration: Account ID (merchant ID) and Secret Key.
All code is under DevBridge.BluePay namespace.
Imports DevBridge.BluePay
Transaction Processing
There are four basic transaction types:
- AUTH - This transaction type "reserves" funds on the customer's card for later CAPTURE.
- CAPTURE - This transaction type debits the funds, reserved earlier by an AUTH, and causes them to be transferred to the merchant's account. Successful AUTH guarantees a later CAPTURE - if performed within the time limit.
- SALE - This transaction is essentially an AUTH and a CAPTURE in one step and is the transaction type of choice for the majority of our merchants.
- REFUND - The concept of a REFUND is to reverse an earlier CAPTURE or SALE. A REFUND may also be referred to as a RETURN or CREDIT. This means the customer's card was debited, and then a separate transaction will need to be run that transfers the money back onto the customer's card.
Every transaction starts by initializing BluePay2Request instance and setting up required values.
Dim merchantId = ConfigurationManager.AppSettings("BluePayMerchantId")
Dim serviceKey = ConfigurationManager.AppSettings("BluePayServiceKey")
Dim bpApi = New BluePay2Request(merchantId, serviceKey)
bpApi.TransactionType = "AUTH"
'Setup request values ...
After all needed values hav been set, call process the request. Process returns BluePay2Response object that contains response values from BluePay. Returned TransactionId is a unique identifier for each transaction that is returned by BluePay and is required when processing CAPTURE or REFUND transactions.
Dim bpResponse = bpApi.Process() Dim transactionId = bpApi.TransactionId Dim status = bpResponse.Result & ": " & bpResponse.Message
Process Credit Card - Sample Code
Private Sub ProcessCreditCard()
Dim merchantId = ConfigurationManager.AppSettings("BluePayMerchantId")
Dim serviceKey = ConfigurationManager.AppSettings("BluePayServiceKey")
Dim bpApi = New BluePay2Request(merchantId, serviceKey)
bpApi.TransactionType = "SALE"
bpApi.Name = "John Doe"
bpApi.CardNumber = "1111222233334444"
bpApi.CardExpiration = "0312" 'MMYY
bpApi.CardCvv2 = "325"
bpApi.Address1 = "517 Nobles Rd"
bpApi.Address2 = "Suite 302"
bpApi.City = "Chicago"
bpApi.State = "IL"
bpApi.ZipCode = "60656"
bpApi.Country = "US"
bpApi.Phone = "8001112222"
bpApi.Email = "jdoe@company.com"
bpApi.OrderId = "25" 'Your internal order number
bpApi.Amount = 10.99D
bpApi.AmountTax = 0.98D
bpApi.CustomId = "1" 'Internal customer ID
'Verify if all values have been set....
Dim bpResponse = bpApi.Process()
Dim transactionId = bpApi.TransactionId
Dim status = bpResponse.Result & ": " & bpResponse.Message
If bpResponse.Approved Then
'Transaction has been approved.
'TODO: complete order processing
Else
'Transaction denied
'TODO: notify customer by showing status
End If
End Sub
Issue Refund Sample Code
Private Sub IssueRefund(ByVal originalTransactionId As String, ByVal amount As Decimal)
Dim merchantId = ConfigurationManager.AppSettings("BluePayMerchantId")
Dim serviceKey = ConfigurationManager.AppSettings("BluePayServiceKey")
Dim bpApi = New BluePay2Request(merchantId, serviceKey)
bpApi.TransactionType = "REFUND"
bpApi.Amount = amount 'Amount to refund
bpApi.TransactionId = originalTransactionId
Dim bpResponse = bpApi.Process()
If bpResponse.Approved Then
'Transaction has been approved.
'TODO: mark order as refunded.
Else
'Transaction denied
'TODO: handle failure
End If
End Sub
Contact
If you'd like to speak with us about your software development project, then please contact us.



