public class EwayRapidClient
extends java.lang.Object
EwayRapidEnvironment; credentials come from EwayRapidConfig.
Card Number/CVN are CSE-encrypted when a Client Side Encryption key is supplied
(eCrypted: + RSA PKCS#1, matching eCrypt.encryptValue).| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CSE_PREFIX
Rapid CSE ciphertext prefix.
|
| Constructor and Description |
|---|
EwayRapidClient(EwayRapidConfig config) |
EwayRapidClient(EwayRapidEnvironment environment,
java.lang.String apiKey,
java.lang.String apiPassword,
java.lang.String cseKey) |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
authorisationCode(JSONObject response) |
static java.lang.String |
countryCode(java.lang.String country)
Map a country name or code to Rapid's two-letter country.
|
JSONObject |
createAccessCode(JSONObject body)
Transparent Redirect:
POST /AccessCodes. |
JSONObject |
createAccessCodeShared(JSONObject body)
Responsive Shared Page / Iframe:
POST /AccessCodesShared. |
JSONObject |
createTokenCustomer(java.lang.String firstName,
java.lang.String lastName,
java.lang.String email,
java.lang.String cardName,
java.lang.String cardNumber,
java.lang.String expiryMonth,
java.lang.String expiryYear,
java.lang.String cvn)
Create a token customer without charging.
|
JSONObject |
createTokenCustomer(java.lang.String title,
java.lang.String firstName,
java.lang.String lastName,
java.lang.String address,
java.lang.String suburbName,
java.lang.String state,
java.lang.String postcode,
java.lang.String country,
java.lang.String email,
java.lang.String phone,
java.lang.String mobile,
java.lang.String customerRef,
java.lang.String cardNumber,
java.lang.String cardName,
java.lang.String expiryMonth,
java.lang.String expiryYear,
java.lang.String cvn)
Create a token customer with the fields
EwayManager
previously sent to SOAP createCustomer. |
static java.lang.String |
encryptCse(java.lang.String plaintext,
java.lang.String cseKey)
RSA-encrypt a card field the way
eCrypt.encryptValue does. |
static java.lang.String |
errorText(JSONObject response)
Rapid
Errors plus ResponseMessage when they differ. |
static JSONObject |
firstCustomer(JSONObject response)
First customer in a
GET /Customer response (Customers[0]). |
static EwayRapidClient |
forCurrentArea() |
static EwayRapidClient |
forCurrentArea(java.lang.String merchant) |
static java.lang.String |
formatCodeLookup(java.lang.String originalCodes,
JSONObject response)
Build
CODE - DisplayMessage from a Code Lookup JSON body. |
static EwayRapidClient |
forTestMode(boolean testMode) |
static EwayRapidClient |
forTestMode(boolean testMode,
java.lang.String merchant) |
static EwayRapidClient |
from(EwayRapidEnvironment environment) |
static EwayRapidClient |
from(EwayRapidEnvironment environment,
java.lang.String merchant) |
EwayRapidEnvironment |
getEnvironment() |
java.lang.String |
getTransactionUrl() |
static boolean |
hasErrors(JSONObject response)
True when Rapid returned a failure.
|
static boolean |
isRapidErrorCode(java.lang.String token)
Rapid code shape: letter plus at least three digits (
V6110, D4401). |
java.lang.String |
lookupErrorText(java.lang.String codes)
Translate Rapid error codes via
POST /APICodeLookup. |
static int |
maxRefundCents(JSONObject query)
Transactions[0].MaxRefund in cents, or -1 when missing. |
JSONObject |
postTransaction(JSONObject body)
Direct Connection
POST /Transaction. |
JSONObject |
processPayment(java.lang.String firstName,
java.lang.String lastName,
java.lang.String email,
java.lang.String address,
java.lang.String postcode,
java.lang.String country,
java.lang.String cardName,
java.lang.String cardNumber,
java.lang.String expiryMonth,
java.lang.String expiryYear,
java.lang.String cvn,
int totalAmountCents,
java.lang.String invoiceNumber,
java.lang.String invoiceDescription)
One-off Direct Connection charge (Rapid
ProcessPayment). |
static EwayRapidClient |
production() |
static EwayRapidClient |
production(java.lang.String merchant) |
JSONObject |
queryAccessCode(java.lang.String accessCode)
Result of a hosted-form AccessCode:
GET /AccessCode/{AccessCode}. |
JSONObject |
queryTokenCustomer(java.lang.String tokenCustomerId)
GET
/Customer/{TokenCustomerID}. |
EwayRapidTokenFields |
queryTokenCustomerCached(java.lang.String tokenCustomerId)
Query a token customer and map card name/number/expiry.
|
JSONObject |
queryTransaction(java.lang.String transactionId)
GET
/Transaction/{TransactionID}. |
static JSONArray |
rapidErrorCodes(java.lang.String raw)
Rapid codes in a comma/space-separated
Errors string. |
static JSONObject |
redactCardFields(JSONObject source) |
JSONObject |
refund(java.lang.String transactionId,
int totalAmountCents)
Refund a Rapid transaction.
|
static java.lang.String |
returnAmount(JSONObject response) |
static EwayRapidClient |
sandbox() |
static EwayRapidClient |
sandbox(java.lang.String merchant) |
static java.lang.String |
tokenCustomerId(JSONObject response) |
JSONObject |
tokenPayment(java.lang.String tokenCustomerId,
int totalAmountCents,
java.lang.String invoiceNumber,
java.lang.String invoiceDescription)
Charge an existing token.
|
JSONObject |
tokenPayment(java.lang.String tokenCustomerId,
int totalAmountCents,
java.lang.String invoiceNumber,
java.lang.String invoiceDescription,
java.lang.String cvn)
Charge an existing token, optionally with CVN (Rapid
TokenPayment). |
static boolean |
transactionApproved(JSONObject response) |
static java.lang.String |
transactionId(JSONObject response) |
JSONObject |
updateTokenCustomer(java.lang.String tokenCustomerId,
java.lang.String title,
java.lang.String firstName,
java.lang.String lastName,
java.lang.String address,
java.lang.String suburbName,
java.lang.String state,
java.lang.String postcode,
java.lang.String country,
java.lang.String email,
java.lang.String phone,
java.lang.String mobile,
java.lang.String customerRef,
java.lang.String cardNumber,
java.lang.String cardName,
java.lang.String expiryMonth,
java.lang.String expiryYear,
java.lang.String cvn)
Update a token customer without charging.
|
public static final java.lang.String CSE_PREFIX
public EwayRapidClient(EwayRapidConfig config)
config - resolved Rapid credentials and hostpublic EwayRapidClient(EwayRapidEnvironment environment, java.lang.String apiKey, java.lang.String apiPassword, java.lang.String cseKey)
environment - Rapid hostapiKey - Rapid API keyapiPassword - Rapid API passwordcseKey - CSE public key, or blank@CheckReturnValue @Nonnull public static EwayRapidClient sandbox()
@CheckReturnValue @Nonnull public static EwayRapidClient sandbox(java.lang.String merchant)
@CheckReturnValue @Nonnull public static EwayRapidClient production()
@CheckReturnValue @Nonnull public static EwayRapidClient production(java.lang.String merchant)
@CheckReturnValue @Nonnull public static EwayRapidClient forCurrentArea()
@CheckReturnValue @Nonnull public static EwayRapidClient forCurrentArea(java.lang.String merchant)
@CheckReturnValue @Nonnull public static EwayRapidClient forTestMode(boolean testMode)
@CheckReturnValue @Nonnull public static EwayRapidClient forTestMode(boolean testMode, java.lang.String merchant)
@CheckReturnValue @Nonnull public static EwayRapidClient from(EwayRapidEnvironment environment)
@CheckReturnValue @Nonnull public static EwayRapidClient from(EwayRapidEnvironment environment, java.lang.String merchant)
@CheckReturnValue @Nonnull public EwayRapidEnvironment getEnvironment()
@CheckReturnValue @Nonnull public java.lang.String getTransactionUrl()
POST /Transaction URLpublic JSONObject createTokenCustomer(java.lang.String firstName, java.lang.String lastName, java.lang.String email, java.lang.String cardName, java.lang.String cardNumber, java.lang.String expiryMonth, java.lang.String expiryYear, java.lang.String cvn) throws java.io.IOException
Payment.TotalAmount must be 0.firstName - Rapid FirstNamelastName - Rapid LastNameemail - Rapid EmailcardName - cardholder namecardNumber - PAN (CSE-encrypted when a key is configured)expiryMonth - two-digit monthexpiryYear - two-digit yearcvn - CVN (CSE-encrypted when a key is configured)java.io.IOException - Rapid transport or non-JSON HTTP errorpublic JSONObject createTokenCustomer(java.lang.String title, java.lang.String firstName, java.lang.String lastName, java.lang.String address, java.lang.String suburbName, java.lang.String state, java.lang.String postcode, java.lang.String country, java.lang.String email, java.lang.String phone, java.lang.String mobile, java.lang.String customerRef, java.lang.String cardNumber, java.lang.String cardName, java.lang.String expiryMonth, java.lang.String expiryYear, java.lang.String cvn) throws java.io.IOException
EwayManager
previously sent to SOAP createCustomer.title - Rapid titlefirstName - Rapid FirstNamelastName - Rapid LastNameaddress - streetsuburbName - citystate - e.g. NSWpostcode - postcodecountry - ISO countryemail - emailphone - phonemobile - mobilecustomerRef - Rapid Customer.ReferencecardNumber - PANcardName - cardholder nameexpiryMonth - two-digit monthexpiryYear - two-digit yearcvn - CVNjava.io.IOException - Rapid transport or non-JSON HTTP errorpublic JSONObject updateTokenCustomer(java.lang.String tokenCustomerId, java.lang.String title, java.lang.String firstName, java.lang.String lastName, java.lang.String address, java.lang.String suburbName, java.lang.String state, java.lang.String postcode, java.lang.String country, java.lang.String email, java.lang.String phone, java.lang.String mobile, java.lang.String customerRef, java.lang.String cardNumber, java.lang.String cardName, java.lang.String expiryMonth, java.lang.String expiryYear, java.lang.String cvn) throws java.io.IOException
tokenCustomerId - existing Rapid TokenCustomerIDtitle - Rapid titlefirstName - Rapid FirstNamelastName - Rapid LastNameaddress - streetsuburbName - citystate - e.g. NSWpostcode - postcodecountry - ISO countryemail - emailphone - phonemobile - mobilecustomerRef - Rapid Customer.ReferencecardNumber - PANcardName - cardholder nameexpiryMonth - two-digit monthexpiryYear - two-digit yearcvn - CVNjava.io.IOException - Rapid transport or non-JSON HTTP error@CheckReturnValue @Nonnull public JSONObject queryTokenCustomer(java.lang.String tokenCustomerId) throws java.io.IOException
/Customer/{TokenCustomerID}.tokenCustomerId - Rapid TokenCustomerIDjava.io.IOException - Rapid transport or non-JSON HTTP error@CheckReturnValue @Nonnull public EwayRapidTokenFields queryTokenCustomerCached(java.lang.String tokenCustomerId)
tokenCustomerId - Rapid TokenCustomerIDEwayRapidTokenFields.none() on failure)public JSONObject tokenPayment(java.lang.String tokenCustomerId, int totalAmountCents, java.lang.String invoiceNumber, java.lang.String invoiceDescription) throws java.io.IOException
totalAmountCents is the lowest currency unit (AUD 1.18 = 118).tokenCustomerId - Rapid TokenCustomerIDtotalAmountCents - amount in centsinvoiceNumber - invoice numberinvoiceDescription - invoice descriptionjava.io.IOException - Rapid transport or non-JSON HTTP errorpublic JSONObject tokenPayment(java.lang.String tokenCustomerId, int totalAmountCents, java.lang.String invoiceNumber, java.lang.String invoiceDescription, java.lang.String cvn) throws java.io.IOException
TokenPayment).tokenCustomerId - Rapid TokenCustomerIDtotalAmountCents - amount in centsinvoiceNumber - invoice numberinvoiceDescription - invoice descriptioncvn - optional CVNjava.io.IOException - Rapid transport or non-JSON HTTP errorpublic JSONObject processPayment(java.lang.String firstName, java.lang.String lastName, java.lang.String email, java.lang.String address, java.lang.String postcode, java.lang.String country, java.lang.String cardName, java.lang.String cardNumber, java.lang.String expiryMonth, java.lang.String expiryYear, java.lang.String cvn, int totalAmountCents, java.lang.String invoiceNumber, java.lang.String invoiceDescription) throws java.io.IOException
ProcessPayment).firstName - Rapid FirstNamelastName - Rapid LastNameemail - emailaddress - streetpostcode - postcodecountry - ISO countrycardName - cardholder namecardNumber - PANexpiryMonth - two-digit monthexpiryYear - two-digit yearcvn - CVNtotalAmountCents - amount in centsinvoiceNumber - invoice numberinvoiceDescription - invoice descriptionjava.io.IOException - Rapid transport or non-JSON HTTP error@CheckReturnValue @Nonnull public JSONObject queryTransaction(java.lang.String transactionId) throws java.io.IOException
/Transaction/{TransactionID}. Used after a refund timeout to
read MaxRefund before retrying.transactionId - Rapid TransactionIDjava.io.IOException - Rapid transport or non-JSON HTTP error@CheckReturnValue
public static int maxRefundCents(@Nullable
JSONObject query)
Transactions[0].MaxRefund in cents, or -1 when missing.query - queryTransaction(String) JSON-1public JSONObject refund(java.lang.String transactionId, int totalAmountCents) throws java.io.IOException
transactionId - Rapid TransactionIDtotalAmountCents - refund amount in centsjava.io.IOException - Rapid transport or non-JSON HTTP errorpublic JSONObject createAccessCode(JSONObject body) throws java.io.IOException
POST /AccessCodes.body - Rapid create-AccessCode JSONjava.io.IOException - Rapid transport or non-JSON HTTP errorpublic JSONObject createAccessCodeShared(JSONObject body) throws java.io.IOException
POST /AccessCodesShared.body - Rapid create-AccessCode JSONjava.io.IOException - Rapid transport or non-JSON HTTP errorpublic JSONObject queryAccessCode(java.lang.String accessCode) throws java.io.IOException
GET /AccessCode/{AccessCode}.accessCode - Rapid AccessCodejava.io.IOException - Rapid transport or non-JSON HTTP error@CheckReturnValue @Nonnull public java.lang.String lookupErrorText(java.lang.String codes)
POST /APICodeLookup. Each code
becomes CODE - English message. On any lookup failure the original
codes string is returned unchanged.codes - Rapid Errors / ResponseMessage, or nullcode - message list, or codes when lookup fails@CheckReturnValue @Nonnull public static JSONArray rapidErrorCodes(java.lang.String raw)
Errors string.raw - Rapid Errors, or nullpublic static boolean isRapidErrorCode(java.lang.String token)
V6110, D4401).token - a split Errors piece, or nulltoken is a Rapid code@CheckReturnValue
@Nonnull
public static java.lang.String formatCodeLookup(java.lang.String originalCodes,
JSONObject response)
CODE - DisplayMessage from a Code Lookup JSON body.
Missing or empty CodeDetails returns originalCodes.originalCodes - Rapid Errors as returned by the payment callresponse - Rapid POST /APICodeLookup JSON, or nulloriginalCodes when lookup is unusablepublic JSONObject postTransaction(JSONObject body) throws java.io.IOException
POST /Transaction.body - Rapid transaction JSONjava.io.IOException - Rapid transport or non-JSON HTTP errorpublic static boolean hasErrors(JSONObject response)
Errors may be null while
ResponseMessage holds V*, D*, F*, or
S* (invalid card V6110 does this). An A* code,
or a blank message, is not a failure: a $0 card update is
TransactionStatus false with no failure code.response - Rapid JSON, or null@CheckReturnValue @Nonnull public static java.lang.String errorText(JSONObject response)
Errors plus ResponseMessage when they differ.response - Rapid JSON, or nullpublic static boolean transactionApproved(JSONObject response)
response - Rapid JSON, or nullTransactionStatus is true@CheckReturnValue @Nonnull public static java.lang.String tokenCustomerId(JSONObject response)
response - Rapid JSON, or nullCustomer.TokenCustomerID, or empty@CheckReturnValue @Nonnull public static java.lang.String transactionId(JSONObject response)
response - Rapid JSON, or null@CheckReturnValue @Nonnull public static java.lang.String authorisationCode(JSONObject response)
response - Rapid JSON, or null@CheckReturnValue @Nonnull public static java.lang.String returnAmount(JSONObject response)
response - Rapid JSON, or null@Nullable public static JSONObject firstCustomer(JSONObject response)
GET /Customer response (Customers[0]).response - Rapid JSON, or nullnull@CheckReturnValue @Nonnull public static JSONObject redactCardFields(JSONObject source)
source - Rapid JSON, or null@CheckReturnValue @Nonnull public static java.lang.String countryCode(java.lang.String country)
country - ISO code or Australiaau)public static java.lang.String encryptCse(java.lang.String plaintext,
java.lang.String cseKey)
eCrypt.encryptValue does.
cseKey is the MyEway Client Side Encryption key (modulus base64,
or an X509/PEM public key). Already-prefixed values are returned unchanged.plaintext - PAN or CVNcseKey - MyEway CSE public keyeCrypted: plus base64 ciphertextjava.lang.IllegalArgumentException - when cseKey is blank or cannot be parsedstSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.