Instant Conversion Transaction

This function allows merchant to instantly upgrade an existing subscription. By “upgrade” we explicitly mean bring forward the rebilling date immediately, perform a transaction and start the rebilling period from now. The initial trial period for the item will no longer be valid.

This is only available on items that have an initial trial period that has been defined in the initial transaction via Sale request. If there is no initial period, the request will be rejected. Instant upgrade is only available for credit card transactions. Alternate payments are not supported.

Endpoints

HTTP Method API URL API Version
POST https://api.payzone.ma/subscription/{subscriptionID}/instantconversion >= 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 'InstantConversion', 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('InstantConversion', 'testMerchant', 'testPassword');
    $transaction->setSubscriptionID($subscriptionID);

    $response = $transaction->send();

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

    SubscriptionInstantConversionResponse response = null;
    SubscriptionInstantConversionRequest request = new SubscriptionInstantConversionRequest();
    request.setSubscriptionId(1234567L);

    try {
        response = connector.doSubscriptionInstantConversion(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;

    // At first we will make "Sale" transaction with subscription

    const body = {
        customerIP: "1.2.3.4",
        amount: amountForTest,
        currency: "EUR",
        orderID: "HELLO NODEJS",

        cardNumber: "4111111111111111",
        cardSecurityCode: "000",
        cardHolderName: "CARDHOLDER NAME",
        cardExpireMonth: "10",
        cardExpireYear: "2024",

        shopperName: "NodeJS Test",
        shopperAddress: "NA",
        shopperZipcode: "NA",
        shopperCity: "NA",
        shopperState: "NA",
        shopperCountryCode: "NA",
        shopperPhone: "NA",
        shopperEmail: "NA",

        // Details for subscription

        subscriptionType: "normal",
        rebillAmount: 1000,
        rebillPeriod: "P5D",
        rebillMaxIteration: 5,
        trialPeriod: "P1D"
    };

    let responseSale = await gateway.creditCardSale(body);

    if (responseSale.code == "000") {
        // Success. Now will make instant conversion

        let responseInstantConversion = await gateway.instantConversion(responseSale.subscriptionID);

        if (responseInstantConversion.code == "000") {
            // Success
            // ...
        }
    }
        
   
    var client = new GatewayClient(OriginatorConfig.ORIGINATOR_ID, OriginatorConfig.ORIGINATOR_PASSWORD);

    // At first we will make normal "Sale" transaction

    var transaction = client.NewSaleTransaction();

    var amount = 2500;

    transaction.SetTransactionInformation(amount, "EUR", "50", customerIP);
    transaction.SetCardInformation("4111111111111111", "000", "CSHARP SDK", "10", "2024");
    transaction.SetShopperInformation("CSHARP SDK", "MICROSOFT CUSTOMER", "666", "REDMOND", "WA", "US", "12445", "x@x.rr");

    // Set the subscription information

    transaction.SetSubscriptionInformation(SubscriptionType.NORMAL, 1000, "P5D", 5, "P1D");

    var response = await transaction.Send();

    if (response.IsSuccessfull())
    {
        Console.WriteLine("Sale operation ok. Transaction ID: " + response.transactionID + ", subscription ID: " + response.subscriptionID);
        Console.WriteLine("Performing instant subscription conversion ...");

        var instantConversionTransaction = client.NewSubscriptionInstantConversionTransaction(response.subscriptionID);
        var instantConversionResponse = await instantConversionTransaction.Send();

        if (instantConversionResponse.IsSuccessfull())
        {
            Console.WriteLine("Conversion is ok: " + instantConversionResponse.errorMessage);
        }
        else
        {
            Console.WriteLine("Error while converting subscription: " + instantConversionResponse.errorMessage);
        }
    }

                        

Response

The body of the response is in JSON format.

The following fields are present in the response :


Name Type Description
transactionID String Transaction reference returned by the system
errorCode String See API Response Codes
errorMessage String See API Response Codes
subscription Object The subscription object

© Payzone | 2022