Payment attempts

A payment request is associated with a list of payment attempts which is basically a consolidated view of payment request events providing information of each step of the payment process. This is the PaymentAttempts property of the payment request and is returned when you get a payment request using paymentrequests/{id} GET endpoint by setting includeEvents parameter to true as follows:

using System.Net.Http.Json;

const string paymentRequestsAPIUrl = "https://api-sandbox.nofrixion.com/api/v1/paymentrequests";

// Payment requests use MERCHANT tokens (remember to keep these safe and secure).
var jwtToken = "<ACCESS_TOKEN>";

var client = new HttpClient();

client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {jwtToken}");

string paymentRequestID = "<PAYMENT_REQUEST_ID_TO_GET>";

try
{
    HttpResponseMessage response = await client.GetAsync($"{paymentRequestsAPIUrl}/{paymentRequestID}?includeEvents=true");
    if (response.IsSuccessStatusCode)
    {
        // returns a JSON object containing payment request details
        var paymentRequest = await response.Content.ReadFromJsonAsync<PaymentRequest>();
        Console.WriteLine(paymentRequest);
    }
    else
    {
        // HTTP error codes will return a MoneyMoov API problem object
        Console.WriteLine(await response.Content.ReadFromJsonAsync<ApiProblem>());
    }
}
catch (Exception e)
{
    Console.WriteLine($"Error: {e.Message}");
}

// type definition for response data
record PaymentRequest(string id, string merchantID, string hostedPayCheckoutUrl, decimal amount, string currency, string customerID,
                string orderID, string paymentMethodTypes, string description, string pispAccountID, string shippingFirstName,
                string shippingLastName, string shippingAddressLine1, string shippingAddressLine2, string shippingAddressCity,
                string shippingAddressCounty, string shippingAddressPostCode, string shippingAddressCountryCode,
                string shippingPhone, string shippingEmail, string baseOriginUrl, string callbackUrl, bool cardAuthorizeOnly,
                bool cardCreateToken, bool ignoreAddressVerification, bool cardIgnoreCVN, string pispRecipientReference);

record ApiProblem(string type, string title, int status, string detail);
const axios = require('axios');

const paymentRequestsAPIUrl = "https://api-sandbox.nofrixion.com/api/v1/paymentrequests";

// Payment requests use MERCHANT tokens (remember to keep these safe and secure).
const jwtToken = "<ACCESS_TOKEN>"; // Replace with your actual access token

// Setting up the headers for the HTTP client
const config = {
    headers: {
        "Accept": "application/json",
        "Authorization": `Bearer ${jwtToken}`
    }
};

const paymentRequestID = "<PAYMENT_REQUEST_ID_TO_GET>"; // Replace with your payment request ID

// Making the GET request
axios.get(`${paymentRequestsAPIUrl}/${paymentRequestID}?includeEvents=true`, config)
    .then(response => {
        if (response.status === 200) {
            // returns a JSON object containing payment request details
            console.log("Payment Request:", response.data);
        }
    })
    .catch(error => {
        if (error.response) {
            // HTTP error codes will return a MoneyMoov API problem object
            console.log("Error:", error.response.data);
        } else {
            console.log("Error:", error.message);
        }
    });

// Assuming an error response format (ApiProblem)
// Adjust according to the actual API response structure

import requests

# URL for the payment requests API
payment_requests_api_url = "https://api-sandbox.nofrixion.com/api/v1/paymentrequests"

# Payment requests use MERCHANT tokens (remember to keep these safe and secure).
jwt_token = "<ACCESS_TOKEN>"  # Replace with your actual access token

# Set up the HTTP headers
headers = {
    "Accept": "application/json",
    "Authorization": f"Bearer {jwt_token}"
}

# The payment request ID you want to get
payment_request_id = "<PAYMENT_REQUEST_ID_TO_GET>"  # Replace with your payment request ID

# Making the GET request
try:
    response = requests.get(f"{payment_requests_api_url}/{payment_request_id}?includeEvents=true", headers=headers)
    
    if response.status_code == 200:
        # Returns a JSON object containing payment request details
        print("Payment Request:", response.json())
    else:
        # HTTP error codes will return a MoneyMoov API problem object
        print("Error:", response.json())
except Exception as e:
    print(f"Error: {e}")

# Assuming an error response format (ApiProblem)
# Adjust according to the actual API response structure

The payment attempts looks like this:

"paymentAttempts": [
        {
            "attemptKey": "pay_xvnyynflynqepjua2idigv7uhu",
            "paymentRequestID": "e5e1659c-b679-4888-ba23-b41ab62dc39d",
            "initiatedAt": "2024-02-23T12:28:37.8081765+00:00",
            "cardAuthorisedAt": "2024-02-23T12:28:37.8081765+00:00",
            "paymentMethod": "card",
            "attemptedAmount": 5.00,
            "authorisedAmount": 0.0,
            "cardAuthorisedAmount": 5.00,
            "settledAmount": 0.0,
            "refundAttempts": [],
            "captureAttempts": [
                {
                    "capturedAt": "2024-02-23T12:28:37.8081765+00:00",
                    "capturedAmount": 5.00
                }
            ],
            "currency": "EUR",
            "paymentProcessor": "Checkout",
            "walletName": "ApplePay",
            "status": "FullyPaid"
        }
    ],

All the information about a payment attempt can be found in this object.

Attempt key

In case of card payment attempt, the attemptKey is the authorization ID of the card payment. While, for pisp payments, the attemptKey is the payment initiation ID. The attempt key will be required in case you want to perform further actions on the payment attempts such as void, refund or capture.

To know about each of the properties of the payment attempt, you can go through the response body of paymentrequests/{id} GET endpoint.