This function processes a cash or credit-card sale.
Request
Add the following code where you would like to start Payanywhere payment processing (i.e., on button click):
private static final String PAYMENT_URL = "payanywhere://payment/";
private static final int PAYMENT_REQUEST_CODE = 123;
Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(PAYMENT_URL + "?chargeAmount=2.73"));
startActivityForResult(intent, PAYMENT_REQUEST_CODE);
123 is the unique requestCode for this intent. When this code is executed, Payanywhere starts and will be ready to process a credit card transaction. If required, connect a credit-card reader and swipe/EMV/NFC/key the credit card. Payanywhere will handle the processing and ask for a signature. Proceed with the signature.
Additional flags may also be used, such as “payanywhere://payment/chargeAmount=2.73&customerTransactionId=123456& invoiceNumber=654321&externalNotification=true"
For more information, please refer to the "Example values for SDK" table on the Integration Guide page.
To process a cash transaction, include "payanywhere://payment/?chargeAmount=0.01&acceptCash=true". This will display the option "Accept Cash Sale" on the SDK Payment screen. Once the transaction is approved, if Receipt Share is enabled, proceed with sharing. Otherwise the transaction result will be sent to the client application.
Response
To receive the transaction result on your app, add the following code to your activity:
After the transaction is approved or declined, Payanywhere will send the result to the calling activity with intent extra. The value of “transactionResult” will be one of the following:
"Approved" when a transaction is approved. You will also receive a “transactionUniqueId”. You can use this unique ID to track your transaction in the future. "recurringPeriod" and "recurringLength" extra will contain the recurring details that you requested. "authorizedAmount" extra contains the authorized charged amount that was applied on this transaction. "authCode" extra contains the authorization code for the transaction.
"Declined" when a transaction is declined.
"Cancelled" when a transaction is cancelled.
If a transaction is a partial auth, you will also receive "isPartialAuth" boolean extra. A partial authorization occurs when a lower amount than the transaction amount is authorized on one card, and the remainder of the payment can be processed using another method.
Parameters
chargeAmount required
string
Example:
2.73
Loading...
itemName
string
Example:
Magazine
Loading...
ccDetails
boolean
Loading...
externalNotification
boolean
Loading...
cancelNotification
boolean
Loading...
customerTransactionId
integer
Example:
12345
Loading...
returnExtras
boolean
Loading...
closeOnDecline
boolean
Loading...
primaryColor
string
Example:
00a6e8
Loading...
contrastColor
string
Example:
10d625
Loading...
autoCancelTimeOut
integer
Default:
300
Example:
60
Loading...
hideSendAsInvoice
boolean
Loading...
receiptScreen
boolean
Loading...
sendBRIC
boolean
Loading...
signOnPaper
boolean
Loading...
allowCategorySelection
boolean
Loading...
receiptNotes
string
Example:
Example Note
Loading...
payMode
string
Example:
debit
Loading...
Start Recurring Payment
post /payment
This function enables you to start accepting a recurring payment. An initial sale will be processed and subsequent payments will be set to recur for a custom length of time at a given interval. Recurring payments are available only for merchants processing with EPX.
Request
Add the following code where you would like to start Payanywhere payment processing (i.e., on button click):
private static final String PAYMENT_URL = "payanywhere://payment/";
private static final int PAYMENT_REQUEST_CODE = 123;
Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(PAYMENT_URL + "?chargeAmount=25.00&recurringPeriod=months&recurringLength=4&firstName=John&lastName=Smith&email=johnsmith@example.com"));
startActivityForResult(intent, PAYMENT_REQUEST_CODE);
In this example, 123 is the unique requestCode for this intent. When this code is executed, Payanywhere starts and will be ready to process a credit card transaction. The initial sale in this example is for $25.00 and the subsequent sales will occur every 4 months with an amount of $25.00.
If required, connect a credit card reader and swipe/EMV/NFC/key the credit card. Payanywhere will handle the processing and ask for a signature. Proceed with the signature.
Response
To receive the transaction result on your app, add the following code to your activity:
After the transaction is approved or declined, Payanywhere will send the result to the calling activity with intent extra. The value of “transactionResult” will be one of the following:
"Approved" when a transaction is approved. You will also receive a “transactionUniqueId”. You can use this unique ID to track your transaction in the future. "recurringPeriod" and "recurringLength" extra will contain the recurring details that you requested. "authorizedAmount" extra contains the authorized charged amount that was applied on this transaction.
"Declined" when a transaction is declined.
"Cancelled" when a transaction is cancelled.
If a transaction is a partial auth, you will also receive "isPartialAuth" boolean extra. A partial authorization occurs when a lower amount than the transaction amount is authorized on one card, and the remainder of the payment can be processed using another method.
Parameters
firstName
string
Example:
John
Loading...
lastName
string
Example:
Smith
Loading...
email
string
Example:
johnsmith@gmail.com
Loading...
itemName
string
Example:
Magazine
Loading...
chargeAmount required
string
Example:
2.73
Loading...
recurringLength
string
Example:
4
Loading...
recurringPeriod
string
Enum:
months
days
weeks
years
Example:
months
Loading...
Update Recurring Payment
post /recurring_payment_update
This function changes an existing recurring payment. Recurring payments are available only for merchants processing with EPX.
Request
Recurring payment frequency may be updated, i.e. period and length, as well as the credit card sale to be used for the recurring payment.
To update the frequency of a recurring payment, pass recurringPaymentId, recurringLength, and recurringPeriod.
To update the credit card sale that will be used to perform a recurring payment, pass recurringPaymentId and recurringPaymentCCSId, i.e. credit card sale unique ID (CCSID). When the CCSID is passed, the following happens:
The current recurring payment object is deactivated and a new recurring payment object is created, pointing to the specified credit card sale object.
The new recurring payment object ID will be returned to you.
Add the following code to update a recurring payment:
private static final String RECURRING_PAYMENT_UPDATE_URL = "payanywhere://recurring_payment_update/";
private static final int RECURRING_PAYMENT_UPDATE_REQUEST_CODE = 227;
public static final String EXTRA_RECURRING_PAYMENT_ID ="recurringPaymentId";
public static final String EXTRA_RECURRING_PAYMENT_CCS_ID ="recurringPaymentCCSId";
public static final String EXTRA_RECURRING_AMOUNT ="recurringAmount";
public static final String EXTRA_RECURRING_PERIOD ="recurringPeriod";
public static final String EXTRA_RECURRING_LENGTH ="recurringLength";
long recurringPaymentId = 1234;
int recurringLength = 1;
String recurringPeriod = "months";
String recurringCCSId = "ccs_123456";
StringBuilder paramBuilder = new StringBuilder();
paramBuilder.append("&" + EXTRA_RECURRING_LENGTH + "=" + recurringLength);
paramBuilder.append("&" + EXTRA_RECURRING_PERIOD + "=" + recurringPeriod);
paramBuilder.append("&" + EXTRA_RECURRING_PAYMENT_CCS_ID + "=" + recurringCCSId);
String params = paramBuilder.toString();
Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(RECURRING_PAYMENT_UPDATE_URL + "?" + EXTRA_RECURRING_PAYMENT_ID + "=" + recurringPaymentId + params));
startActivityForResult(intent, RECURRING_PAYMENT_UPDATE_REQUEST_CODE);
You will receive an updated recurringPaymentId or a new recurringPaymentId if a new recurring object was created due to a new CCSID. Please note that currently there is no verification that the card is still valid until a recurring payment charge is attempted.
Parameters
recurringLength
string
Example:
4
Loading...
recurringPeriod
string
Enum:
months
days
weeks
years
Example:
months
Loading...
recurringPaymentId
string
Example:
123456
Loading...
recurringPaymentCCSId
string
Loading...
Deactivate Recurring Payment
get /recurring_payment_deactivate
This function deactivates an existing recurring payment. Recurring payments are available only for merchants processing with EPX.
Request
To deactivate a recurring payment, provide the recurringPaymentId and add the following code:
private static final String RECURRING_PAYMENT_DEACTIVATE_URL = "payanywhere://recurring_payment_deactivate";
private static final int RECURRING_PAYMENT_DEACTIVATE_REQUEST_CODE = 347;
long recurringPaymentId = 1234;
Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(RECURRING_PAYMENT_DEACTIVATE_URL + "?" + EXTRA_RECURRING_PAYMENT_ID + "=" + recurringPaymentId);
startActivityForResult(intent, RECURRING_PAYMENT_DEACTIVATE_REQUEST_CODE);
This function pre-authorizes a payment on a customer's card and does not capture it.
Request
Add the following code where you would like to start Payanywhere payment processing (i.e., on button click):
private static final String PREAUTH_URL = "payanywhere://preauth/";
private static final int PREAUTH_REQUEST_CODE = 456;
Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(PREAUTH_URL + "?chargeAmount=2.73"));
startActivityForResult(intent, PREAUTH_REQUEST_CODE);
456 is the unique requestCode for this intent. When this code is executed, Payanywhere starts and will be ready to process a pre-auth credit card transaction.
This function adjusts the amount of a Pre-Auth transaction. It will increase or decrease the pre-authorized amount by the amount provided in the request. For example, if a pre-auth was created for $10.00 and and an adjust amount of $15.00 is requested, the new amount for the pre-auth will be $25.00.
Request
Add the following code where you would like to start Payanywhere payment processing (i.e., on button click):
private static final String PREAUTH_ADJUST_URL = "payanywhere://preauth_adjust/";
private static final int PREAUTH_ADJUST_REQUEST_CODE = 457;
private String transactionUniqueId = "ccs_1234567";
private String adjustAmount = "25.00"; // This can be negative as well
private long receiptId = 317748502;
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(
PREAUTH__ADJUST_URL
+ "?transactionUniqueId=" + transactionUniqueId
+ "d&receiptId=" + receiptId
+ "&adjustAmount=" + adjustAmount)
);
startActivityForResult(intent, PREAUTH_ADJUST_REQUEST_CODE);
Response
To receive the activity result:
private static final String EXTRA_TRANSACTION_ACTION = "transactionAction";
private static final String EXTRA_TRANSACTION_RESULT = "transactionResult";
private static final String EXTRA_TRANSACTION_UNIQUE_ID = "transactionUniqueId";
private static final String EXTRA_INVOICE_NUMBER = "invoiceNumber";
private static final String EXTRA_RECEIPT_ID = "receiptId";
private static final String EXTRA_PARTIAL_AUTH = "isPartialAuth";
private static final String EXTRA_REQUESTED_AMOUNT = "requestedAmount";
private static final String EXTRA_TOTAL_AUTHORIZED_AMOUNT = "totalAuthorizedAmount";
private static final String EXTRA_CUSTOMER_NAME = "customerName";
public static final String EXTRA_TRANSACTION_ACTION = "transactionAction";
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG,"onActivityResult requestCode " + requestCode + " resultCode " + resultCode);
if( requestCode == PREAUTH_ADJUST_REQUEST_CODE) {
if (resultCode == RESULT_OK){
Log.d(TAG,"result ok");
showTransactionResponses(requestCode, resultCode, data);
} else if (resultCode == RESULT_CANCELED){
Log.d(TAG,"result cancelled");
showTransactionResponses(requestCode, resultCode, data);
}
}
}
private void showTransactionResponses(int requestCode, int resultCode, Intent data) {
if (data != null) {
String transactionAction = data.getString(EXTRA_TRANSACTION_ACTION);
String transactionResult = data.getStringExtra(EXTRA_TRANSACTION_RESULT);
String transactionUniqueId = data.getStringExtra(EXTRA_TRANSACTION_UNIQUE_ID);
String invoiceNumber = data.getStringExtra(EXTRA_INVOICE_NUMBER);
String customerName = data.getStringExtra(EXTRA_CUSTOMER_NAME);
long receiptId = data.getLongExtra(EXTRA_RECEIPT_ID, 0);
BigDecimal totalAuthorizedAmount = null;
if (data.getSerializableExtra(EXTRA_TOTAL_AUTHORIZED_AMOUNT) != null){
totalAuthorizedAmount = (BigDecimal)data.getSerializableExtra(EXTRA_TOTAL_AUTHORIZED_AMOUNT);
}
}
}
Parameters
adjustAmount
string
Example:
25.00
Loading...
transactionUniqueId
string
Loading...
receiptId
string
Loading...
Capture
post /preauth_complete
This function captures an existing authorization.
Request
Add the following code where you would like to start Payanywhere payment processing (i.e., on button click):
private static final String PREAUTH_COMPLETE_URL = "payanywhere://preauth_complete/";
private static final int PREAUTH_COMPLETE_REQUEST_CODE = 789;
Intent intent = new Intent(Intent.ACTION_VIEW , Uri.parse(PREAUTH_COMPLETE_URL + "?transactionUniqueId=pap_123456&receiptId=123456&preAuthCompleteAmount=43.46"));
startActivityForResult(intent, PREAUTH_COMPLETE_REQUEST_CODE);