mutation createPaymentSessionAuthenticated
Creates a payment session used by the checkout process to create a payment.
Returns PaymentSession!
Arguments
| Argument | Type | Description |
|---|---|---|
input | CreatePaymentSessionInput! |
Example request
curl -X POST 'https://graph.clientloop.com/' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{
"query": "mutation CreatePaymentSession($input: CreatePaymentSessionInput!) { createPaymentSession(input: $input) { id orgId status amount currency callbackUrl successUrl link contactId contact { orgId id name givenName familyName email phone createdAt updatedAt } contactRef { contactId contactName contactFirstName contactLastName contactEmail contactPhone address { lines locality administrativeArea postalCode countryCode } } transactionRef invoiceIds invoiceRefs { orderId invoiceId invoiceNumber amount lines { num quantity price productId productSku productName productDescription productImageUrl } billingContact { contactId contactName contactFirstName contactLastName contactEmail contactPhone } shippingContact { contactId contactName contactFirstName contactLastName contactEmail contactPhone } } expirationDate paymentId createdAt updatedAt checkoutConfigurationId invoiceTotal brandLogoUrl brandName } }",
"variables": {
"input": {
"orgId": "abc123",
"amount": "100.00",
"currency": "USD"
}
}
}'const response = await fetch('https://graph.clientloop.com/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer <api-key>',
},
body: JSON.stringify({
query: `
mutation CreatePaymentSession($input: CreatePaymentSessionInput!) {
createPaymentSession(input: $input) {
id
orgId
status
amount
currency
callbackUrl
successUrl
link
contactId
contact {
orgId
id
name
givenName
familyName
email
phone
createdAt
updatedAt
}
contactRef {
contactId
contactName
contactFirstName
contactLastName
contactEmail
contactPhone
address {
lines
locality
administrativeArea
postalCode
countryCode
}
}
transactionRef
invoiceIds
invoiceRefs {
orderId
invoiceId
invoiceNumber
amount
lines {
num
quantity
price
productId
productSku
productName
productDescription
productImageUrl
}
billingContact {
contactId
contactName
contactFirstName
contactLastName
contactEmail
contactPhone
}
shippingContact {
contactId
contactName
contactFirstName
contactLastName
contactEmail
contactPhone
}
}
expirationDate
paymentId
createdAt
updatedAt
checkoutConfigurationId
invoiceTotal
brandLogoUrl
brandName
}
}
`,
variables: {
"input": {
"orgId": "abc123",
"amount": "100.00",
"currency": "USD"
}
},
}),
});
const { data, errors } = await response.json();<?php
$body = <<<'JSON'
{
"query": "mutation CreatePaymentSession($input: CreatePaymentSessionInput!) { createPaymentSession(input: $input) { id orgId status amount currency callbackUrl successUrl link contactId contact { orgId id name givenName familyName email phone createdAt updatedAt } contactRef { contactId contactName contactFirstName contactLastName contactEmail contactPhone address { lines locality administrativeArea postalCode countryCode } } transactionRef invoiceIds invoiceRefs { orderId invoiceId invoiceNumber amount lines { num quantity price productId productSku productName productDescription productImageUrl } billingContact { contactId contactName contactFirstName contactLastName contactEmail contactPhone } shippingContact { contactId contactName contactFirstName contactLastName contactEmail contactPhone } } expirationDate paymentId createdAt updatedAt checkoutConfigurationId invoiceTotal brandLogoUrl brandName } }",
"variables": {
"input": {
"orgId": "abc123",
"amount": "100.00",
"currency": "USD"
}
}
}
JSON;
$ch = curl_init('https://graph.clientloop.com/');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer <api-key>',
],
CURLOPT_POSTFIELDS => $body,
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
var body = """
{
"query": "mutation CreatePaymentSession($input: CreatePaymentSessionInput!) { createPaymentSession(input: $input) { id orgId status amount currency callbackUrl successUrl link contactId contact { orgId id name givenName familyName email phone createdAt updatedAt } contactRef { contactId contactName contactFirstName contactLastName contactEmail contactPhone address { lines locality administrativeArea postalCode countryCode } } transactionRef invoiceIds invoiceRefs { orderId invoiceId invoiceNumber amount lines { num quantity price productId productSku productName productDescription productImageUrl } billingContact { contactId contactName contactFirstName contactLastName contactEmail contactPhone } shippingContact { contactId contactName contactFirstName contactLastName contactEmail contactPhone } } expirationDate paymentId createdAt updatedAt checkoutConfigurationId invoiceTotal brandLogoUrl brandName } }",
"variables": {
"input": {
"orgId": "abc123",
"amount": "100.00",
"currency": "USD"
}
}
}
""";
var request = HttpRequest.newBuilder(URI.create("https://graph.clientloop.com/"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer <api-key>")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());using System.Net.Http;
using System.Text;
var body = """
{
"query": "mutation CreatePaymentSession($input: CreatePaymentSessionInput!) { createPaymentSession(input: $input) { id orgId status amount currency callbackUrl successUrl link contactId contact { orgId id name givenName familyName email phone createdAt updatedAt } contactRef { contactId contactName contactFirstName contactLastName contactEmail contactPhone address { lines locality administrativeArea postalCode countryCode } } transactionRef invoiceIds invoiceRefs { orderId invoiceId invoiceNumber amount lines { num quantity price productId productSku productName productDescription productImageUrl } billingContact { contactId contactName contactFirstName contactLastName contactEmail contactPhone } shippingContact { contactId contactName contactFirstName contactLastName contactEmail contactPhone } } expirationDate paymentId createdAt updatedAt checkoutConfigurationId invoiceTotal brandLogoUrl brandName } }",
"variables": {
"input": {
"orgId": "abc123",
"amount": "100.00",
"currency": "USD"
}
}
}
""";
using var client = new HttpClient();
using var content = new StringContent(body, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("Authorization", "Bearer <api-key>");
var response = await client.PostAsync("https://graph.clientloop.com/", content);
var result = await response.Content.ReadAsStringAsync();Types
input CreatePaymentSessionInput
| Field | Type | Description |
|---|---|---|
orgId | ID! | Organization identifier the payment session belongs to. |
amount | Amount! | Total payment amount. Ex. 100.10 |
currency | Currency! | Three letter ISO currency code. Ex. USD |
callbackUrl | URL | URL to receive payment session events |
successUrl | URL | URL to redirect after a payment session is completed by the customer |
contactId | ID | Optional contact for which this payment session is attached. You cannot provide both a contactId and a contactRef. Note that some features are unavailable if a contactId or contactRef is not provided. |
contactRef | PaymentSessionContactRefInput | Optional merchant supplied reference contact information external to the platform. You cannot provide both a contactId and a contactRef. Note that some features are unavailable if a contactId or contactRef is not provided. |
transactionRef | String | Optional merchant supplied reference ID for the transaction external to the platform. |
invoiceIds | [String!] | Optional array of invoice IDs which this payment session is attached to. You cannot provide both invoiceIds and invoiceRefs. Note that some feature are unavailable unless at least one invoiceId or invoiceRef is provided. |
invoiceRefs | [PaymentSessionInvoiceRefInput!] | Optional array of invoice references which this payment session is attached to. You cannot provide both invoiceIds and invoiceRefs. Note that some features are unavailable unless at least one invoiceId or invoiceRef is provided. |
expirationDate | DateTime | Optional expiration date for the payment session. ISO 8601 format. |
createPendingPayment | Boolean | Optionally create a pending payment record for this payment session. Default is false which means a payment record is created upon payment session completion. Set this to true if you require a pending payment to be visible in the payment list in the dashboard before payments are made. This is useful for use cases involving payment sessions without expirations. This setting may only be set on payment session creation. |
checkoutConfigurationId | ID | The checkout configuration ID to be used for this payment session. If a checkout configuration ID is not provided, the default checkout configuration will be used. |
invoiceTotal | Amount | Optional total amount due across the referenced invoices. When the payment amount exceeds this total (for example because of a surcharge or tip), financing options such as FlexPay are disabled since they cannot finance the additional amount. |
brandLogoUrl | URL | Optional URL to a logo image to display during checkout, overriding the default branding. The caller supplies a URL that is used to render the logo. |
brandName | String | Optional brand or merchant name to display during checkout, overriding the organization name. |
type PaymentSession
Represents a payment session a customer can use to make a payment. This session is used to configuration and setup the payment experience for an individual customer's session during checkout.
| Field | Type | Description |
|---|---|---|
id | ID! | Unique identifier for the payment session. |
orgId | ID! | Organization identifier the payment session belongs to. |
status | PaymentSessionStatus! | Status of the payment session. |
amount | Amount! | Total payment amount. Ex. 100.10 |
currency | Currency! | Three letter ISO currency code. Ex. USD |
callbackUrl | URL | URL to receive payment session events |
successUrl | URL | URL to redirect after a payment session is completed by the customer |
link | URL | Link to the payment session. This will be null if the session is expired or completed. This link is used to redirect the user to the payment page or may be used to embedded payment flow depending on the configuration provided. |
contactId | ID | ID for the contact for which this payment session is attached. |
contact | Contact | Contact for which this payment session is attached. |
contactRef | PaymentSessionContactRef | Optional merchant supplied reference contact information external to the platform. |
transactionRef | String | Optional merchant supplied reference ID for the transaction external to the platform. |
invoiceIds | [String!] | Optional array of invoice IDs which this payment session is attached to. You cannot provide both invoiceIds and invoiceRefs. Note that some feature are unavailable unless at least one invoiceId or invoiceRef is provided. |
invoiceRefs | [PaymentSessionInvoiceRef!] | Optional array of invoice references which this payment session is attached to. You cannot provide both invoiceIds and invoiceRefs. Note that some features are unavailable unless at least one invoiceId or invoiceRef is provided. |
expirationDate | DateTime | Optional expiration date for the payment session. ISO 8601 format. |
paymentId | ID | Payment ID associated with this payment session. If the payment session status is completed, this will be populated. It may also be populated if the payment session was attached to a pre-created payment record. |
createdAt | DateTime! | Date the payment session was created |
updatedAt | DateTime! | Date the payment session was last updated |
checkoutConfigurationId | ID | The checkout configuration ID used for this payment session. |
invoiceTotal | Amount | Optional total amount due across the referenced invoices. When the payment amount exceeds this total (for example because of a surcharge or tip), financing options such as FlexPay are disabled since they cannot finance the additional amount. |
brandLogoUrl | URL | Optional caller-supplied URL to a logo image to display during checkout, overriding the default branding. |
brandName | String | Optional caller-supplied brand or merchant name to display during checkout, overriding the organization name. |
scalar Amount
A monetary amount with up to two decimal places. Ex. 111.11
scalar Currency
Three letter ISO 4217 currency code. Ex. USD
scalar URL
A URL with protocol and port. ex. https://example.com
input PaymentSessionContactRefInput
Merchant provide contact information to use when creating a payment session.
| Field | Type | Description |
|---|---|---|
contactId | ID | |
contactName | String | |
contactFirstName | String | |
contactLastName | String | |
contactEmail | Email | |
contactPhone | Phone | |
address | GlobalAddressInput |
input PaymentSessionInvoiceRefInput
Merchant provided invoice detail used to create a payment session.
| Field | Type | Description |
|---|---|---|
orderId | String | The merchant provided order identifier. |
invoiceId | String | The merchant provided invoice identifier. |
invoiceNumber | String | The merchant provided invoice number. |
amount | Amount | The total amount of the invoice. Ex 999.99 |
lines | [PaymentSessionInvoiceLineItemRefInput!] | The line items inside the merchant provided invoice. |
billingContact | PaymentSessionContactRefInput | Billing contact information associated with the invoice |
shippingContact | PaymentSessionContactRefInput | Shipping contact information associated with the invoice |
scalar DateTime
ISO 8601 formatted date time. Ex. 2023-11-23T14:30:00Z
enum PaymentSessionStatus
ExpiredActiveCompletedCanceled
type Contact
| Field | Type | Description |
|---|---|---|
orgId | ID! | |
id | ID! | |
name | String! | |
givenName | String | |
familyName | String | |
email | Email | |
phone | Phone | |
createdAt | String! | |
updatedAt | String! |
type PaymentSessionContactRef
Merchant provide contact information for use during a payment session.
| Field | Type | Description |
|---|---|---|
contactId | ID | |
contactName | String | |
contactFirstName | String | |
contactLastName | String | |
contactEmail | Email | |
contactPhone | Phone | |
address | GlobalAddress |
type PaymentSessionInvoiceRef
Merchant provided invoice information for use during a payment session.
| Field | Type | Description |
|---|---|---|
orderId | String | The merchant provided order identifier. |
invoiceId | String | The merchant provided invoice identifier. |
invoiceNumber | String | The merchant provided invoice number. |
amount | Amount | The total amount of the invoice. Ex 999.99 |
lines | [PaymentSessionInvoiceLineItemRef!] | The line items inside the merchant provided invoice. |
billingContact | PaymentSessionContactRef | Billing contact information associated with the invoice |
shippingContact | PaymentSessionContactRef | Billing contact information associated with the invoice |
scalar Email
An email address
scalar Phone
E.164 formatted phone number. Ex. +14155554345
input GlobalAddressInput
Address of a physical location
| Field | Type | Description |
|---|---|---|
lines | [String!]! | Street, unit, building number, etc. |
locality | String | City, town or municipality designation |
administrativeArea | String | State, province or area designation |
postalCode | String | Postal code or ZIP code |
countryCode | String! | 2-letter country code. Ex. USA |
input PaymentSessionInvoiceLineItemRefInput
Merchant provided invoice line item detail used to create a payment session.
| Field | Type | Description |
|---|---|---|
num | Int! | Line number in the invoice. This is used to order the line items for display. |
quantity | Float | Number of units of the product. |
price | Amount | The price of the product. Ex. 100.10 Note that the currency used is from the PaymentSession. |
productId | String | The ID of the product. |
productSku | String | The sku of the product. |
productName | String | The name of the product. This may or may not be displayed to the customer depending on the layout templated selected and its configuration. |
productDescription | String | The description of the product. This may or may not be displayed to the customer depending on the layout templated selected and its configuration. |
productImageUrl | URL | The URL to the product image to show to the customer. This may or may not be displayed to the customer depending on the layout templated selected and its configuration. |
type GlobalAddress
Address of a physical location
| Field | Type | Description |
|---|---|---|
lines | [String!]! | Street, unit, building number, etc. |
locality | String | City, town or municipality designation |
administrativeArea | String | State, province or area designation |
postalCode | String | Postal code or ZIP code |
countryCode | String! | 2-letter country code. Ex. USA |
type PaymentSessionInvoiceLineItemRef
Merchant provided invoice line item information for use during a payment session.
| Field | Type | Description |
|---|---|---|
num | Int! | |
quantity | Float | |
price | Amount | |
productId | String | |
productSku | String | |
productName | String | |
productDescription | String | |
productImageUrl | URL |