Payum / PayumYiiExtension

Rich payment solutions for Yii framework. Paypal, payex, authorize.net, be2bill, omnipay, recurring paymens, instant notifications and many more
https://payum.forma-pro.com/
MIT License
12 stars 16 forks source link

Active record storage #4

Open martynling opened 10 years ago

martynling commented 10 years ago

This is a pretty rough but effective means of implementing ActiveRecord storage. I needed ActiveRecord storage working for Payum in a hurry, so found what seemed the simplest solution to me. I suspect that you may want to implement it in a more elegant way, but I did the following:

It needs some tidying up if it were to be merged in... but I'll hold off on doing that since you may not want to merge it in anyway. If you go ahead with a more elegant solution, I'll probably switch to that further down the line.

Anyway, here it is, just in case it's helpful to you or someone else.

makasim commented 10 years ago

@martynling thanks for sharing! is this working version?

I am not yii expert so it would be hard for me to review, in any case I would do it.

makasim commented 10 years ago

@martynling could you write a chapter how to use it so I can install it on my yii sandbox and play a bit.

makasim commented 10 years ago

here's sandbox repo: https://github.com/makasim/PayumYiiSandbox

martynling commented 10 years ago

@makasim Yes, it's a working version. I'll write the "how to use it" section next week sometime. Glad to share. :-)

makasim commented 10 years ago

For token storage, I extended Payum\Core\Model\Token and gave it an activeRecord property. In the __construct method, when a new object is being created, the activeRecord property is set to a new TokenActiveRecord (an extension of ActiveRecord). Given that Payum is usually expecting a token, I give it a token with the active record more or less hidden within it.

Could it be possible to create TokenActiveRecord that implements TokenInterface? payum expects it.

makasim commented 10 years ago

For payment detail storage, I took a similar approach by extending ArrayObject and giving it an activeRecord property. On __construct it creates a new PaymentActiveRecord (you guessed it, an extension of ActiveRecord).

same here, why should we hide active record inside the other model. Why not create active record model that implements array access interface?

makasim commented 10 years ago

It needs some tidying up if it were to be merged in... but I'll hold off on doing that since you may not want to merge it in anyway.

I am looking forward to merge it (:. indeed we have to clean things up a bit

martynling commented 10 years ago

@makasim Sorry for the delay on this - I moved house last weekend and there's a problem getting connected to the Internet. I should be fully back in action next week and will get to work on this then.

makasim commented 10 years ago

@martynling congrats on moving to new house!

makasim commented 10 years ago

@martynling any news on this?

martynling commented 10 years ago

@makasim Still got connection problems... and there have been 2 days of public holiday so no progress. Once I get connected again, I'll get to it. Next week, hopefully.

martynling commented 10 years ago

@makasim I've added the How to use... chapter this morning. Let me know what you think.

makasim commented 10 years ago

great! I will try it in my sandbox asap.