Query Subscription Status

This function allows merchant to query the current status of a subscription.

Endpoints

HTTP Method API URL API Version
GET https://api.payzone.ma/subscription/{subscriptionID} >= 002

Accepted parameters

No field are needed in the request. The subscription ID is in the URI.


Code samples

Note: Gateway API transactions are done with a different library than payment-page API. See the code sample comments for more info:

   
    /*
    *   Transaction name is 'StatusSubscription', once you create a new transaction passing this as parameter, 
    *   you need to set the mandatory data using the following method:
    *    setSubscriptionID()
    */

    $client = new GatewayClient();

    $transaction = $client->newTransaction('StatusSubscription', 'testMerchant', 'testPassword');
    $transaction->setSubscriptionID($subscriptionID);

    $response = $transaction->send();

    if ('000' === $response->errorCode) {
        $subscription    = $response->subscription;
        $transactionList = $response->transactionList;
    } else {
        echo "Error {$response->errorCode} with message {$response->errorMessage}";
    }
                      
   
    PaymentGatewayConnector connector = new PaymentGatewayConnector(API_URL, ORIGINATOR, PASSWORD);

    SubscriptionStatusResponse response = null;
    SubscriptionStatusRequest request = new SubscriptionStatusRequest();
    request.setSubscriptionId(1234567L);

    try {
        response = connector.getSubscriptionStatus(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());
        }
    }
                      
   
    const gateway = require("payxpert")("123456", "GreatP4ssw0rd").gateway;

    let responseQuerySubscription = await gateway.querySubscription("111....");

    if (responseQuerySubscription.code == "000") {
        // Success
        // two fields inside response:
        // subscription - with subscription details
        // transactionList - with list of related transactions
    }

        
   
    var client = new GatewayClient(OriginatorConfig.ORIGINATOR_ID, OriginatorConfig.ORIGINATOR_PASSWORD);
    var querySubscriptionTransaction = client.QuerySubscriptionTransaction(subscriptionID);

    var response = await querySubscriptionTransaction.Send();

    if (response.IsSuccessfull())
    {
        // response object consists of two fields
        // subscription - with subscription details
        // List<Transaction> transactionList - with list of related transactions
    }
                        
                        

Response

The body of the response is in JSON format.

The following fields are present in the response :


Name Type Description
errorCode String See API Response Codes
errorMessage String See API Response Codes
subscription Object The subscription object
transactionList Object List (array) of Transaction objects (see Transaction object)

© Payzone | 2022