Class MidtransCoreApiImpl

    • Constructor Detail

      • MidtransCoreApiImpl

        public MidtransCoreApiImpl​(Config config)
        CoreAPI constructor
        Parameters:
        config - Midtrans configuration
    • Method Detail

      • apiConfig

        public Config apiConfig()
        Description copied from interface: MidtransCoreApi
        Do re-set config Class like clientKey, serverKey, isProduction
        Specified by:
        apiConfig in interface MidtransCoreApi
        Returns:
        Config.class
      • chargeTransaction

        public org.json.JSONObject chargeTransaction​(Map<String,​Object> body)
                                              throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do /charge API request to Core API
        Specified by:
        chargeTransaction in interface MidtransCoreApi
        Parameters:
        body - Map Object parameter, object of Core API JSON body as parameter, will be converted to JSON (more params detail refer to: https://api-docs.midtrans.com)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • checkTransaction

        public org.json.JSONObject checkTransaction​(String param)
                                             throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do /{orderId}/status API request to Core API
        Specified by:
        checkTransaction in interface MidtransCoreApi
        Parameters:
        param - {String} of the transaction (more detail refer to: https://api-docs.midtrans.com/#get-transaction-status)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • approveTransaction

        public org.json.JSONObject approveTransaction​(String param)
                                               throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/{orderId}/approve` API request to Core API
        Specified by:
        approveTransaction in interface MidtransCoreApi
        Parameters:
        param - {String} of the transaction (more detail refer to: https://api-docs.midtrans.com/#approve-transaction)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • cancelTransaction

        public org.json.JSONObject cancelTransaction​(String param)
                                              throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/{orderId}/cancel` API request to Core API
        Specified by:
        cancelTransaction in interface MidtransCoreApi
        Parameters:
        param - {String} of the transaction (more detail refer to: https://api-docs.midtrans.com/#cancel-transaction)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • expireTransaction

        public org.json.JSONObject expireTransaction​(String param)
                                              throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/{orderId}/expire` API request to Core API
        Specified by:
        expireTransaction in interface MidtransCoreApi
        Parameters:
        param - {String} of the transaction (more detail refer to: https://api-docs.midtrans.com/#expire-transaction)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • refundTransaction

        public org.json.JSONObject refundTransaction​(String param,
                                                     Map<String,​String> body)
                                              throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/{orderId}/refund` API request to Core API
        Specified by:
        refundTransaction in interface MidtransCoreApi
        Parameters:
        param - {String} of the transaction (more detail refer to: https://api-docs.midtrans.com/#refund-transaction)
        body - {Map Object} object of Core API JSON body as parameter, will be converted to JSON
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • cardToken

        public org.json.JSONObject cardToken​(Map<String,​String> params)
                                      throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/token` API request to Core API
        Specified by:
        cardToken in interface MidtransCoreApi
        Parameters:
        params - {Map Object} object of Core API JSON body as parameter, will be converted to JSON (more params detail refer to: https://api-docs.midtrans.com/#get-token)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • registerCard

        public org.json.JSONObject registerCard​(Map<String,​String> params)
                                         throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/card/register` API request to Core API
        Specified by:
        registerCard in interface MidtransCoreApi
        Parameters:
        params - {Map Object} object of Core API JSON body as parameter, will be converted to JSON (more params detail refer to: https://api-docs.midtrans.com/#register-card)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • cardPointInquiry

        public org.json.JSONObject cardPointInquiry​(String tokenId)
                                             throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/point_inquiry/{tokenId}` API request to Core API
        Specified by:
        cardPointInquiry in interface MidtransCoreApi
        Parameters:
        tokenId - {String} of credit card (more detail refer to: https://api-docs.midtrans.com/#point-inquiry)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • captureTransaction

        public org.json.JSONObject captureTransaction​(Map<String,​String> params)
                                               throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/capture API` request to Core API
        Specified by:
        captureTransaction in interface MidtransCoreApi
        Parameters:
        params - {Map Object} object of Core API JSON body as parameter, will be converted to JSON (more params detail refer to: https://api-docs.midtrans.com/#capture-transaction)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • getTransactionStatusB2B

        public org.json.JSONObject getTransactionStatusB2B​(String param)
                                                    throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/point_inquiry/{tokenId}` API request to Core API
        Specified by:
        getTransactionStatusB2B in interface MidtransCoreApi
        Parameters:
        param - {String} of credit card (more detail refer to: https://api-docs.midtrans.com/#get-transaction-status-b2b)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • directRefundTransaction

        public org.json.JSONObject directRefundTransaction​(String param,
                                                           Map<String,​String> requestBody)
                                                    throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/{orderId}/status/b2b` API request to Core API
        Specified by:
        directRefundTransaction in interface MidtransCoreApi
        Parameters:
        param - {String} of the transaction (more detail refer to: https://api-docs.midtrans.com/#direct-refund-transaction)
        requestBody - {Map Object} object of Core API JSON body as parameter, will be converted to JSON
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • denyTransaction

        public org.json.JSONObject denyTransaction​(String param)
                                            throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/{orderId}/deny` API request to Core API
        Specified by:
        denyTransaction in interface MidtransCoreApi
        Parameters:
        param - {String} of the transaction (more detail refer to: https://api-docs.midtrans.com/#deny-transaction)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • getBIN

        public org.json.JSONObject getBIN​(String binNumber)
                                   throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `v1/bins/{bin}` API request to Core API
        Specified by:
        getBIN in interface MidtransCoreApi
        Parameters:
        binNumber - {String} of the transaction (more detail refer to: https://api-docs.midtrans.com/#bin-api)
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • createSubscription

        public org.json.JSONObject createSubscription​(Map<String,​Object> subscriptionReq)
                                               throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `v1/subscriptions` API request to Core API for Create subscription. (more detail refer to: http://api-docs.midtrans.com/#create-subscription)
        Specified by:
        createSubscription in interface MidtransCoreApi
        Parameters:
        subscriptionReq - {Map Object} object of Subscription request body
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • getSubscription

        public org.json.JSONObject getSubscription​(String subscriptionId)
                                            throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `v1/subscriptions/{subscription_id}` Find subscription by id to see the subscription details. (more detail refer to: http://api-docs.midtrans.com/#get-subscription)
        Specified by:
        getSubscription in interface MidtransCoreApi
        Parameters:
        subscriptionId - {String} Subscription ID given by Midtrans
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • disableSubscription

        public org.json.JSONObject disableSubscription​(String subscriptionId)
                                                throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `v1/subscriptions/{subscription_id}/disable` Make the subscription inactive (the subscription will not create transaction anymore)s. (more detail refer to: http://api-docs.midtrans.com/#disable-subscription)
        Specified by:
        disableSubscription in interface MidtransCoreApi
        Parameters:
        subscriptionId - {String} Subscription ID given by Midtrans
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • enableSubscription

        public org.json.JSONObject enableSubscription​(String subscriptionId)
                                               throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `v1/subscriptions/{subscription_id}/enable` Make the subscription active (the subscription will create periodic transaction) (more detail refer to: http://api-docs.midtrans.com/#enable-subscription)
        Specified by:
        enableSubscription in interface MidtransCoreApi
        Parameters:
        subscriptionId - {String} Subscription ID given by Midtrans
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • updateSubscription

        public org.json.JSONObject updateSubscription​(String subscriptionId,
                                                      Map<String,​Object> subscriptionReq)
                                               throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `v1/subscriptions/{subscription_id}` Update existing subscription details. (more detail refer to: http://api-docs.midtrans.com/#update-subscription)
        Specified by:
        updateSubscription in interface MidtransCoreApi
        Parameters:
        subscriptionId - {String} Subscription ID given by Midtrans
        subscriptionReq - {Map Object} object of Subscription request body
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • linkPaymentAccount

        public org.json.JSONObject linkPaymentAccount​(Map<String,​Object> accountRequest)
                                               throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `/v2/pay/account` to link customer account to be used for specific payment channels (more detail refer to: http://api-docs.midtrans.com/#create-pay-account)
        Specified by:
        linkPaymentAccount in interface MidtransCoreApi
        Parameters:
        accountRequest - {Map Object} object of create payment account request body
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • getPaymentAccount

        public org.json.JSONObject getPaymentAccount​(String accountId)
                                              throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `v2/pay/account/{account_id}` find account by id to see the customer account details (more detail refer to: http://api-docs.midtrans.com/#get-pay-account)
        Specified by:
        getPaymentAccount in interface MidtransCoreApi
        Parameters:
        accountId - {String} Customer account id to be used for payment
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.
      • unlinkPaymentAccount

        public org.json.JSONObject unlinkPaymentAccount​(String accountId)
                                                 throws MidtransError
        Description copied from interface: MidtransCoreApi
        Do `v2/pay/account/{account_id}/unbind` to unbind a linked customer account (more detail refer to: http://api-docs.midtrans.com/#unbind-pay-account)
        Specified by:
        unlinkPaymentAccount in interface MidtransCoreApi
        Parameters:
        accountId - {String} Customer account id to be used for payment
        Returns:
        {JSONObject} - org.json Promise contains Object from JSON decoded response
        Throws:
        MidtransError - when an exception was occurred during executing the request.