Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP 2.0 / Stripe Payment Integration

I'm new-ish to Cake. I'm building a site in 2.1 and trying to implement the Stripe payment gateway.

I've found a couple plugins/components but their documentation isn't really clear for me.

Here's one: https://github.com/jeremyharris/stripe/blob/master/README.md

I've added the folder to my plugins folder, loaded the plugin via bootstrap.php, configured the database.php file, and created a new model named Authorize.php with the code in the Readme.

I'm just stuck now, not sure what to do. I added a very basic form to a test page but I'm not sure where to go from here.

Here's my testpayment.ctp in my Pages controller:

echo $this->Form->create('Authorize');
echo $this->Form->input('Card Number');
echo $this->Form->input('Expiration');
echo $this->Form->input('CCV');
echo $this->Form->end('Send');

Any help is VERY appreciated.

like image 972
Melissa L Avatar asked Nov 27 '25 14:11

Melissa L


2 Answers

I also struggled while trying the above Plugin. I had it setup nice and it kept throwing whole sorts of warnings and errors. One thing you need to understand is the Stripe payment flow. I was lucky to find this simple plugin which took me less than half an hour to have Stripe working. If you are still newish to Cake, read through the official docs, both for Stripe and CakePHP.

like image 83
jkoech Avatar answered Nov 29 '25 11:11

jkoech


None of the existing components were good enough for me, so I just finished my component, which contains all the methods

https://github.com/hashmode/CakePHP-Stripe-Component-Full

The usage is very simple, if you read the Stripe docs, for example lets consider adding credit card: According to API docs, we need the customer's id and and the card data as an array or as a token. So, the usage will be

$customerId = 'cus_asdfasdfasdf';
$cardData = array('number' => '1111111111111', 'exp_month' => '10',
    'exp_year' => 2022, 'cvc' => 123);
$response = $this->Stripe->createCard($customerId, $cardData);

The same logic is used for the rest of the methods.

like image 23
hashmode Avatar answered Nov 29 '25 13:11

hashmode



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!