Mark Order as Paid vs Capture Payment

421 views
Skip to first unread message

Dave

unread,
Oct 4, 2011, 11:06:42 AM10/4/11
to shopify-api
Hi,

I have a request to "mark orders as paid" with the API. The problem is
the Shopify admin option on authorized orders to Capture Payments does
not seem to do anything. I notice that the only thing I can do with
the Transactions resource is to mark an order as captured.

So it Capture Payments does not mark an order as paid, how can I use
the API to mark an order as paid?

Any explanation most welcome!

Thanks

Dave

unread,
Oct 4, 2011, 2:38:20 PM10/4/11
to shopify-api
C'mon, is it really that hard to answer this question???

Yan Sarazin

unread,
Oct 4, 2011, 3:08:59 PM10/4/11
to shopi...@googlegroups.com
I think your answer is in the API docs.

Change an Order’s note, note-attributes, email, and buyer-accepts-marketing state (the only attributes modifiable through the API)

David Underwood

unread,
Oct 4, 2011, 3:24:06 PM10/4/11
to shopi...@googlegroups.com
Hey Dave,

Creating a transaction on the order with the 'kind' set to 'capture'  as described in the API will mark the order as paid in these cases.

-David Underwood
 Developer Advocate, Shopify
 1-888-746-7439 x771

Dave

unread,
Oct 4, 2011, 3:25:41 PM10/4/11
to shopify-api
Hi Yan,

I think you're missing the point of my original question... it has to
do with the Transaction Resource... not Order... You apply
transactions to orders.

I want to know how to MARK AN ORDER AS PAID with a transaction... so
is it using "capture" or something else... because using "capture"
does not seem to do it.

Thanks

On Oct 4, 3:08 pm, Yan Sarazin <yan.sara...@gmail.com> wrote:
> I think your answer is in the API docs.
>
> Change an Order’s note, note-attributes, email, and buyer-accepts-marketing state (the only attributes modifiable through the API)
>
> --  
> Yan
>
> http://statikpulse.comhttp://twitter.com/statikpulse
>
>
>
>
>
>
>
> On Tuesday, 4 October, 2011 at 2:38 PM, Dave wrote:
> > C'mon, is it really that hard to answer this question???
>

Dave

unread,
Oct 4, 2011, 7:20:19 PM10/4/11
to shopify-api
Ok.. Thanks for explaining Mr. Underwood.. I will get back to the
client and see what he says about this. The contradiction remains
though, that when you use the Capture Payments on the Shop Admin order
screen, it does not mark orders as paid, hence the whole question of
murkiness about the use of the capture...

I will write the code to transact the capture.. and see what happens!!

Thanks!

David Speake

unread,
Oct 4, 2011, 8:49:43 PM10/4/11
to shopi...@googlegroups.com
This is the Rails code that I use to mark an order as paid on Shopify:

def mark_as_paid
require 'shopify_api'
ShopifyAPI::Base.site = order.site.get_site
ShopifyAPI::Order.find(order.id).open
ShopifyAPI::Order.new(:id => order.id, :readonly => false).capture
return true
end

The third 'ShopifyAPI' line creates a new transaction on the order with type 'capture' and that marks a pending order as paid.

Dave

unread,
Oct 5, 2011, 2:19:20 AM10/5/11
to shopify-api
Interesting.

Your code is puzzling to me for many reasons. I guess it's because I
so rarely write code for Rails.

How does your method mark_as_paid know what an order even is?

An order has a site method? And further a get_site method?

And then you find the order, and open it?

and then you use ShopifyAPI::Order.new(:id => order.id, :readonly =>
false).capture

which seems to create a new instance of an order, based on the order,
which you capture.

I was just thinking of using the Transaction resource directly ie)
ShopifyAPI::Transaction with an order ID... I guess I will have to
experiment some... :)

David Speake

unread,
Oct 5, 2011, 6:32:25 AM10/5/11
to shopi...@googlegroups.com
Sorry Dave, that wasn't quite the right code. It was missing the params:

def mark_as_paid(order)

end

I originally thought the same thing as you, that that code would create a new order. But in fact it is a new transaction on the order specified by the :id param. We've never used the ShopifyAPI::Transaction for anything, so I'm not sure about that.

I'm not sure if the open call is necessary by the way. We just like to close pending orders as otherwise we end up with thousands. This just makes sure that the order is open when/after the order is marked off.

John Duff

unread,
Oct 5, 2011, 6:48:32 AM10/5/11
to shopi...@googlegroups.com
If you take a look at the api gem you'll see that all order.capture
does is create a transaction for that order
https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/resources/order.rb

Creating a new instance of an object with ActiveResource doesn't
actually try to create a new order until you to save it, really all it
is doing is setting the id of the order so that capture can use it
when creating the Transaction for the Order.

John Duff
Developer @ Shopify

David Speake

unread,
Oct 5, 2011, 6:52:40 AM10/5/11
to shopi...@googlegroups.com
Oh right. So an alternative to my code would be:

ShopifyAPI::Order.find(order.id).capture

?

John Duff

unread,
Oct 5, 2011, 7:06:16 AM10/5/11
to shopi...@googlegroups.com
Yes, this is also equivalent:

ShopifyAPI::Transaction.create(:kind => "capture", :order_id => id)

You can also capture a partial amount by include :amount =>
amount_to_capture as a parameter to the transaction.

John Duff
Developer @ Shopify

On Wed, Oct 5, 2011 at 6:52 AM, David Speake

Dave

unread,
Oct 5, 2011, 9:36:24 AM10/5/11
to shopify-api
Thanks for the observations here guys... most helpful.



On Oct 5, 7:06 am, John Duff <john.d...@jadedpixel.com> wrote:
> Yes, this is also equivalent:
>
> ShopifyAPI::Transaction.create(:kind => "capture", :order_id => id)
>
> You can also capture a partial amount by include :amount =>
> amount_to_capture as a parameter to the transaction.
>
> John Duff
> Developer @ Shopify
>
> On Wed, Oct 5, 2011 at 6:52 AM, David Speake
>
>
>
>
>
>
>
> <da...@verycleverstuff.co.uk> wrote:
> > Oh right. So an alternative to my code would be:
>
> > ShopifyAPI::Order.find(order.id).capture
>
> > ?
>
> > On 5 Oct 2011, at 21:48, John Duff wrote:
>
> >> If you take a look at the api gem you'll see that all order.capture
> >> does is create a transaction for that order
> >>https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/re...
Reply all
Reply to author
Forward
0 new messages