Skip to main content

Documentación

Pay Invoice

Make a payment against an invoice.

This method triggers the following webhooks:

The following asynchronous webhooks provide information about later changes to the Invoice object:

Depending on the request values, some of these webhooks are triggered synchronously.

Nota

  • Before you pay an invoice with a token for a payment method, verify that the value of is_tokenizable is true.

  • If the payment method category is card, certain operations require 3DS authentication. To simulate this authentication in the sandbox, use the URL from the redirect_url field that appears in the response and in Invoice Payment Created Webhook and Payment Succeeded Webhook. See Simulating 3DS Authentication.

  • A card payment that requires 3DS authentication must be authenticated within 15 minutes.

    • invoice

    • ID of the invoice you want to pay. String starting with invoice_.

    • payment_method

    • ID of the payment method for paying the invoice. If not included in the body, then the customer's default payment method is used.

Code Samples
    • .NET

      • using System;
        
        namespace RapydApiRequestSample
        {
            class Program
            {
                static void Main(string[] args)
                {
                    try
                    {
                        string invoice = "invoice_f387777eaa23ff864e2a8fced2455ef6";
        
                        string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/invoices/{invoice}/pay");
        
                        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(
              'POST',
              '/v1/invoices/invoice_f387777eaa23ff864e2a8fced2455ef6/pay'
            );
        
            console.log(result);
          } catch (error) {
            console.error('Error completing request', error);
          }
        }
    • PHP

      • <?php
        $path .= "/<path-to-your-utility-file>/utilities.php";
        include($path);
        
        try {
            $object = make_request('post', "/v1/invoices/invoice_f387777eaa23ff864e2a8fced2455ef6/pay");
            var_dump($object);
        } catch(Exception $e) {
            echo "Error => $e";
        }
        ?>
    • Python

      • from pprint import pprint
        
        from utilities import make_request
        
        result = make_request(method='post', path='/v1/invoices/invoice_f387777eaa23ff864e2a8fced2455ef6/pay')
        pprint(result)
  • /v1/invoices/:invoice/pay

  • Pay Invoice

  • curl -X post  'https://sandboxapi.rapyd.net/v1/invoices/invoice_3c69b5228f548953a4da8cb5f80d79b8/pay' \
    -H 'access_key: your-access-key-here' \
    -H 'Content-Type: application/json' \
    -H 'idempotency: your-idempotency-parameter-here' \
    -H 'salt: your-random-string-here' \
    -H 'signature: your-calculated-signature-here' \
    -H 'timestamp: your-unix-timestamp-here' \
    --data-raw ''
  • {
        "status": {
            "error_code": "",
            "status": "SUCCESS",
            "message": "",
            "response_code": "",
            "operation_id": "4a9ddcbf-0ed4-4441-8af3-eeaaeb7bfdbd"
        },
        "data": {
            "id": "invoice_3c69b5228f548953a4da8cb5f80d79b8",
            "attempt_count": 0,
            "billing": "pay_automatically",
            "billing_reason": "manual",
            "created_at": 1764745257,
            "currency": "USD",
            "customer": "cus_4e25112ac20e144ad073a614dc46934b",
            "description": "",
            "discount": null,
            "due_date": 1767337257,
            "days_until_due": 30,
            "metadata": {},
            "payment_method": "card_b9548d9b53a565b2315fecdc6c87f158",
            "payment": null,
            "payout": null,
            "payment_fields": null,
            "period_end": 0,
            "period_start": 0,
            "lines": [],
            "statement_descriptor": "",
            "subscription": "",
            "discount_amount": 0,
            "subtotal": 0,
            "tax": 0,
            "tax_percent": 0,
            "total": 0,
            "status": "paid",
            "payout_fields": null,
            "type": "payment"
        }
    }