This function allows merchant to cancel the Automated rebilling. When automated rebilling is set, the system automatically performs future rebill transactions.
To setup automated rebilling, the merchant needs to send information defining rebill amount and period when performing the initial transaction via a Sale request.
Important Note about the cancellation date
The codes in the range 0000-1004 cause the subscription to be canceled immediately.
For other codes, we wait the end of the last paid period. This mean that, for a monthly subscription, if John Smith made the payment for March (typically on March 1st), his subscription will end after March 31st. If on the other hand the current date is March 5th, and the payment for March hasn’t arrived yet, then the subscription for March is canceled (the cancellation date is set to March 1st).
API Url
Environment | Url | Method | Version |
---|---|---|---|
Production | https://api.payxpert.com/subscription/{subscriptionID}/cancel | POST | >= 0200 |
Cancel Subscription Request
Field | Type | Max Length | Requirement | Description | Version |
---|---|---|---|---|---|
cancelReason | N | 4 | M | Only codes in the range 1000-1099 are allowed. See CancelReason for possible values |
Cancel Subscription Response
Field | Type | Max Length | Requirement | Description | Version |
---|---|---|---|---|---|
errorCode | D | 3 | M | See Messages and error codes | |
errorMessage | S | 100 | M | See Messages and error codes | |
subscription | O | M | The subscription object |
PHP Gateway Client
Transaction name : CancelSubscription
PHP Methods
Method name | Requirement |
---|---|
setSubscriptionID | M |
setCancelReason | M |
PHP Example
<?php
$client = new GatewayClient();
$transaction = $client->newTransaction('CancelSubscription', 'testMerchant', 'testPassword');
$transaction->setSubscriptionID($subscriptionID);
$transaction->setCancelReason(1001);
$response = $transaction->send();
if ('000' === $response->errorCode) {
$subscription = $response->subscription;
} else {
echo "Error {$response->errorCode} with message {$response->errorMessage}";
}
?>
Java Gateway Client
Java Methods
Connector method | doCancelSubscription |
---|---|
Request class | SubscriptionCancelRequest |
Response class | SubscriptionCancelResponse |
Java Examples
PaymentGatewayConnector connector = new PaymentGatewayConnector(API_URL, ORIGINATOR, PASSWORD);
SubscriptionCancelResponse response = null;
SubscriptionCancelRequest request = new SubscriptionCancelRequest();
request.setSubscriptionId(1234567L);
request.setCancelReason(SubscriptionCancelReason.BANK_DENIAL);
try {
response = connector.doCancelSubscription(request);
} catch (Exception e) {
e.printStackTrace();
}
if (response != null) {
if (TransactionResultCode.TRANSACTION_SUCCESSFULLY.equals(response.getErrorCode()) {
System.out.println("Success: " + response.getErrorMessage());
} else {
System.out.println("Failure: " + response.getErrorMessage());
}
}