Skip to main content

Documentación

Delete Discount from Customer

Delete the discount that has been assigned to a customer through a coupon.

This action does not affect the coupon that the discount was derived from.

This method triggers the Customer Discount Deleted webhook.

Nota

Code Samples
    • .NET

      • using System;
        
        namespace RapydApiRequestSample
        {
            class Program
            {
                static void Main(string[] args)
                {
                    try
                    {
                        string customerId = "cus_217f61d6757465a9716666ccf4d3ec73";
        
                        string result = RapydApiRequestSample.Utilities.MakeRequest("DELETE", $"/v1/customers/{customerId}/discount");
        
                        Console.WriteLine(result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error completing request: " + e.Message);
                    }
                }
            }
        }
        
    • JavaScript

      • const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest;
        
        async function main() {
          try {
            const result = await makeRequest(
              'DELETE',
              '/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/discount'
            );
        
            console.log(result);
          } catch (error) {
            console.error('Error completing request', error);
          }
        }
        
    • PHP

      • <?php
        $path = $_SERVER['DOCUMENT_ROOT'];
        $path .= "/<path-to-your-utility-file>/utilities.php";
        include($path);
        
        try {
            $object = make_request('delete', "/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/discount");
            var_dump($object);
        } catch (Exception $e) {
            echo "Error: $e";
        }
        ?>
    • Python

      • from pprint import pprint
        
        from utilities import make_request
        
        # Delete Discount from Customer
        result = make_request(method='delete', path='/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/discount')
        pprint(result)
        
  • /v1/customers/:customer/discount

  • Delete Discount from Customer

  • curl -X delete 'https://sandboxapi.rapyd.net/v1/customers/cus_9f4965b9807bc1aeae67b47a0ae5b081/discount' \
    -H 'access_key: your-access-key-here' \
    -H 'Content-Type: application/json' \
    -H 'salt: your-random-string-here' \
    -H 'signature: your-calculated-signature-here' \
    -H 'timestamp: your-unix-timestamp-here'
    
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "24d73cc4-c34d-43dc-8b91-8230375af712"
        },
        "data": {
            "id": "dis_d41d8cd98f00b204e9800998ecf8427e",
            "deleted": true
        }
    }
  • Bad Request - Discount Not Found

  • curl -X delete 'https://sandboxapi.rapyd.net/v1/customers/cus_e942934d553ca9c1215f4f5201f1fddd/discount' \
    -H 'access_key: your-access-key-here' \
    -H 'Content-Type: application/json' \
    -H 'salt: your-random-string-here' \
    -H 'signature: your-calculated-signature-here' \
    -H 'timestamp: your-unix-timestamp-here'
    
  • {
        "status": {
            "error_code": "ERROR_DELETE_CUSTOMER_DISCOUNT",
            "status": "ERROR",
            "message": "The request tried to delete a discount from a customer, but the operation failed. Corrective action: Determine whether the discount was already deleted, and why there were multiple requests to delete it.",
            "response_code": "ERROR_DELETE_CUSTOMER_DISCOUNT",
            "operation_id": "e526ea22-03f9-4642-b21a-533189bb91f7"
        }
    }
  • Bad Request - Customer Not Found

  • curl -X delete 'https://sandboxapi.rapyd.net/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/discount' \
    -H 'access_key: your-access-key-here' \
    -H 'Content-Type: application/json' \
    -H 'salt: your-random-string-here' \
    -H 'signature: your-calculated-signature-here' \
    -H 'timestamp: your-unix-timestamp-here'
  • {
        "status": {
            "error_code": "ERROR_GET_CUSTOMER",
            "status": "ERROR",
            "message": "The request attempted an operation that requires the ID of a customer, but the customer was not found. The request was rejected. Corrective action: Use the correct ID of the customer, a string starting with 'cus_'.",
            "response_code": "ERROR_GET_CUSTOMER",
            "operation_id": "1e04fad4-0969-46bf-a71e-1089736b27e8"
        }
    }
  • Unauthorized

  • curl -X delete 'https://sandboxapi.rapyd.net/v1/customers/cus_217f61d6757465a9716666ccf4d3ec73/discount' \
    -H 'access_key: your-access-key-here' \
    -H 'Content-Type: application/json' \
    -H 'salt: your-random-string-here' \
    -H 'signature: your-calculated-signature-here' \
    -H 'timestamp: your-unix-timestamp-here'
  • {
        "status": {
            "error_code": "UNAUTHENTICATED_API_CALL",
            "status": "ERROR",
            "message": "The request was rejected due to an authentication issue. Corrective action: Check the status of your account in the 'Account Details' page of the Client Portal.",
            "response_code": "UNAUTHENTICATED_API_CALL",
            "operation_id": "7d6de716-13c1-4859-a437-61ca8abf2e37"
        }
    }