Re: Complete checkout - set delivery method and mark as paid

Complete checkout - set delivery method and mark as paid

Gooner
Tourist
4 0 0

Hi there,

 

I want to complete checkout and create order using Storefront API. I can create checkout with line Items and shipping address. In order to complete order I will have to set shipping line and pay. Can someone tell me how I can mark order as paid and choose delivery method? How can I complete this checkout and create new order? What mutation should I use??

 

Currently I'm using the following code to set line items:

mutation {
  checkoutCreate(input: {
    lineItems: [{lineItems}]
  }) {
  checkout {
    id
    webUrl
completedAt
lineItems(first: 5)
{
  edges {
    node {
      title
      quantity
  }
}
}
}
}
}

 

And this for setting address and getting shipping methods:

 

"mutation
checkoutShippingAddressUpdate {
checkoutShippingAddressUpdate(shippingAddress: {shippingAddress}, checkoutId: ""{checkoutId}"") {
userErrors {
field
message
}
checkout {
id
webUrl
shippingAddress {
firstName
lastName
address1
province
country
zip
}
availableShippingRates{
ready
shippingRates{
title
priceV2{
amount
currencyCode
}
}
}
shippingLine {
title
priceV2{
amount
currencyCode
}
}
}
}
}

 

 

 

Replies 5 (5)

Alex
Shopify Staff
1561 81 342

Her @Gooner.

 

To complete a checkout you've started by creating it via the storefront API, you need to redirect the customer to that checkout's webUrl property, since we don't allow of checkout processing/completion via the storefront API as it is. Let me know if I'm misunderstanding the question though.

 

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Gooner
Tourist
4 0 0

Hi Alex,

Thank you for reply. Seems you understood me properly. I have several additional questions. 

1) If I use Storefront API I am not able to complete checkout programmatically (without redirecting to webUrl property). Can you confirm this?

2) If I use  REST API, can I complete checkout programmatically (without redirecting to webUrl property)? Now I am using Checkout API. I Am able to create checkout, specify lineItems and shippingLine. As far as I see this API allows to complete checkout and transform this into order using https://{shopAddress}/admin/checkouts/{token}/complete.json. I'm getting an error - Cannot complete the checkout without any transactions.

Is there possibility to complete checkout and create order based on this?

3) Also I want to use custom payment method. I want to pay for goods on my side(for instance, I have paid this using paypal) and just mark checkout or order as paid (with amount). Can I do this using REST API (Checkout API) without redirecting to Shopify checkout?

 

Many thanks!

Alex
Shopify Staff
1561 81 342

To answer your questions in order:

 

1. You are correct. You cannot programatically complete checkouts using the storefront API. You must redirect to the webUrl.

2. If you use the Admin REST API you can create and complete checkouts programatically only if you are a sales channel integration. To become a sales channel integration it has to make business sense for your app and it must function as a market place. This is something you would apply for in your partner dashboard. After a review of your request from our end, your app will or will not be converted to a sales channel integration. More on that here.

3. Related to point 2, here's information on payment processing, which is also a part of the sales channel SDK.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Gooner
Tourist
4 0 0

Alex, thank you for reply!

I have an app that was created as Sales channel. According to Payment Processing documentation I can choose the following methods:

Is there a way to use Paypal and FPay payment methods to create payment transaction and complete checkout??

Alex
Shopify Staff
1561 81 342

The only way we support payment processing ultimately involves using our card vaulting servers in the flow of processing the transactions. If you intend to process checkouts with a service like PayPal or FPay, you could consider instead using order resources instead, which I see you created a new thread asking about. It's worth noting though that I don't think you're going to be able to get published on the app store this way. I personally don't handle submissions, but I do think I recall not bypassing our checkout as a requirement during the application process.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog