App reviews, troubleshooting, and recommendations
Hi guys!
I want to set my order to be Pending (Unpaid) and try to do it like this:
// $id is known and I only set the follow variables:
$pendingExpiresAt = '2024-06-21T13:55:13+00:00'; // php Iso 8601
$reason = "PARTNER_ACTION_REQUIRED";
postQueryWithVariablesAsync( 'mutation paymentSessionPending($id: ID!, $pendingExpiresAt: DateTime!, $reason: PaymentSessionStatePendingReason!) { paymentSessionPending(id: $id, pendingExpiresAt: $pendingExpiresAt, reason: $reason) { paymentSession { id state nextAction { action context { ... on PaymentSessionActionsRedirect { redirectUrl } } } } userErrors { field message } } }', [ 'id' => "gid://shopify/PaymentSession/$id", 'reason' => [ 'code' => $reason, 'merchantMessage' => 'Waiting payment to be approved.', ], ], $this->rateLimits->graphqlSleepFunction(queryCost: 13) );
And as result I got strange response:
"message": "Variable $pendingExpiresAt of type DateTime! was provided invalid value",
"explanation": "Expected value to not be null"
"message":"Variable $reason of type PaymentSessionStatePendingReason! was provided invalid value",
"explanation":"Expected "{
"code"=>"PARTNER_ACTION_REQUIRED",
"merchantMessage"=>"Waiting payment to be approved."
}" to be one of: BUYER_ACTION_REQUIRED, PARTNER_ACTION_REQUIRED, NETWORK_ACTION_REQUIRED"}]}}]}
Any ideas what I am doing wrong?
Regards!
Solved! Go to the solution
This is an accepted solution.
I found my mistake - typical copy-paste error. I need to pass the expire time in the second parameter - the array. Also the reason is not an array but simple string:
// $id is known and I only set the follow variables:
$pendingExpiresAt = '2024-06-21T13:55:13+00:00'; // php Iso 8601
$reason = "PARTNER_ACTION_REQUIRED";
postQueryWithVariablesAsync(
'mutation paymentSessionPending($id: ID!, $pendingExpiresAt: DateTime!, $reason: PaymentSessionStatePendingReason!) {
paymentSessionPending(id: $id, pendingExpiresAt: $pendingExpiresAt, reason: $reason) {
paymentSession {
id
state
nextAction {
action
context {
... on PaymentSessionActionsRedirect {
redirectUrl
}
}
}
}
userErrors {
field
message
}
}
}',
[
'id' => "gid://shopify/PaymentSession/$id",
'pendingExpiresAt' => $pendingExpiresAt,
'reason' => $reason,
],
$this->rateLimits->graphqlSleepFunction(queryCost: 13)
);
The paymentSessionPending mutation in Shopify is typically used to update the state of a payment session to indicate that it is pending further action, such as completion or validation. Problems with this mutation can arise from various issues, such as incorrect input data, permissions, or integration errors.
Here's a detailed guide to help you troubleshoot and solve this issue:
Ensure you are using the latest version of the API and check the Shopify GraphQL API documentation for any updates related to the paymentSessionPending mutation.
Ensure that you are providing the correct input parameters for the mutation. The required parameters usually include:
Example mutation:
graphql
mutation {
paymentSessionPending(
id: "gid://shopify/PaymentSession/{session-id}",
amount: {
amount: "10.00",
currencyCode: USD
}
) {
paymentSession {
id
state
}
userErrors {
field
message
}
}
}
Check the userErrors field in the mutation response. This field will provide information about what went wrong if the mutation fails.
Example response with user errors:
json
{
"data": {
"paymentSessionPending": {
"paymentSession": null,
"userErrors": [
{
"field": ["id"],
"message": "The provided ID is invalid."
}
]
}
}
}
If you see errors here, correct the issues mentioned.
Ensure that your API key or access token has the necessary permissions to perform the mutation. You might need write_payments permissions.
Verify the current status of the payment session. If the session is already completed or canceled, you might not be able to update it to pending.
Check your application's logs or Shopify's API logs to see if there are more details about the request failure.
Check the Shopify Support for any similar issues or solutions.
graphql
query {
paymentSession(id: "gid://shopify/PaymentSession/{session-id}") {
id
state
amount {
amount
currencyCode
}
}
}
Update to Pending State:
graphql
mutation {
paymentSessionPending(
id: "gid://shopify/PaymentSession/{session-id}",
amount: {
amount: "10.00",
currencyCode: USD
}
) {
paymentSession {
id
state
}
userErrors {
field
message
}
}
}
Тhanks for the response!
In Documentation Shopify do not mention amount, but expire date:
mutation paymentSessionPending($id: ID!, $pendingExpiresAt: DateTime!, $reason: PaymentSessionStatePendingReason!) {
paymentSessionPending(id: $id, pendingExpiresAt: $pendingExpiresAt, reason: $reason) {
paymentSession {
# PaymentSession fields
}
userErrors {
field
message
}
}
}
but I will try you solution also.
Regards!
This is an accepted solution.
I found my mistake - typical copy-paste error. I need to pass the expire time in the second parameter - the array. Also the reason is not an array but simple string:
// $id is known and I only set the follow variables:
$pendingExpiresAt = '2024-06-21T13:55:13+00:00'; // php Iso 8601
$reason = "PARTNER_ACTION_REQUIRED";
postQueryWithVariablesAsync(
'mutation paymentSessionPending($id: ID!, $pendingExpiresAt: DateTime!, $reason: PaymentSessionStatePendingReason!) {
paymentSessionPending(id: $id, pendingExpiresAt: $pendingExpiresAt, reason: $reason) {
paymentSession {
id
state
nextAction {
action
context {
... on PaymentSessionActionsRedirect {
redirectUrl
}
}
}
}
userErrors {
field
message
}
}
}',
[
'id' => "gid://shopify/PaymentSession/$id",
'pendingExpiresAt' => $pendingExpiresAt,
'reason' => $reason,
],
$this->rateLimits->graphqlSleepFunction(queryCost: 13)
);
Great
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024