Stripe subscriptions

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

Stripe subscriptions

Post by Travin » 24 Dec 2017, 19:07

Hey guys!
I need to use Stripe subscriptions. So I decided to install ai-payments. I faced problems.
1) There are no subscriptions, only single products for Stripe as I understood
2) There are no onepage checkout. I set onepage checkout:

Code: Select all

'checkout' => [
    'standard' => [
        'onepage' =>['address','delivery','payment','summary']
    ]
]
It works fine, but if we check stripe payment, we will fill card data at another page. I need all in one page.

So I started to create my own extension and Payment Provider.
I added js and card form at /checkout page. When we click Buy Now it sending data to Stripe and taking token, then submit form. Now I want to use process() function to fetch all the data, and create an order.

Is it the right way to do full one page checkout?

p.s. After that i would create new order type- subscription
Last edited by Travin on 13 Jan 2018, 12:59, edited 1 time in total.
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Stripe subscriptions

Post by aimeos » 25 Dec 2017, 13:57

Yes, the default Stripe implementation asks for the payment data at the end and sends them to the Stripe server directly. By implementing your own payment service provider, you can do payment handling differently.

Embed the Stripe JS into the page (using the HTML client template for the checkout payment part) to get the token and store it as service attribute here: https://github.com/aimeos/ai-client-htm ... d.php#L227

After the order has been created by Aimeos, the process() method of your payment service provider is called where you can finish the payment based on your stored token.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

Re: Stripe subscriptions

Post by Travin » 21 Jan 2018, 20:11

I am added some fields at my private $feConfig. So now it's new field at a payment form. Can you please tell me how can i take data from these fields at my process() function?
I tried

Code: Select all

print_r($feConfig = $this->feConfig);
print_r($this->getConfigFE($order));
It does not work for me. My getConfigFE() is:

Code: Select all

public function getConfigFE( \Aimeos\MShop\Order\Item\Base\Iface $basket )
    {
        $list = array();

        foreach( $this->feConfig as $key => $config ) {
            $list[$key] = new \Aimeos\MW\Criteria\Attribute\Standard( $config );
        }

        return $list;
    }
So is it possible to place fields with card data at the 1st checkout page, not at the second page how it is works at ai-payments Stripe, yes?
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Stripe subscriptions

Post by aimeos » 21 Jan 2018, 22:11

The data is stored as order service attribute items:
https://github.com/aimeos/aimeos-core/b ... e.php#L560

You can retrieve them using something like (<code> is the code of the service payment option):

Code: Select all

$orderBaseItem->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT, '<code>' )->getAttributes();
Here's are the interfaces:
https://aimeos.org/api/latest/class-Aim ... Attributes
https://aimeos.org/api/latest/class-Aim ... Iface.html
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

Re: Stripe subscriptions

Post by Travin » 23 Jan 2018, 19:26

aimeos wrote:Embed the Stripe JS into the page (using the HTML client template for the checkout payment part) to get the token
I am creating my first Stripe payment integration. When i'm trying to use Omnipay without token, it responds me message from Stripe:
"Sending credit card numbers directly to the Stripe API is generally unsafe. We suggest you use test tokens that map to the test card you are using, see https://stripe.com/docs/testing.
Guys I don't understand how ai-payments works with Stripe without taking token :?
Anyway, I'm creating my solution with token and all-in-one page

First, I need to separate Stripe view and another Providers view. Because I need to show string for Stripe only: <script src="https://js.stripe.com/v3/"></script> and some other Stripe specific code.
So I decided to do something like that:
a) at my \client\html\templates\checkout\standard\payment-body-default.php http://joxi.ru/52anRkYUGRVK1A
b) at my config: http://joxi.ru/gmvY7qgfxV6kNr
Is it a good solution? How can I take Provider name instead of $id ?

Second, I need to handle purchase button click. By click on Purchase button I need to send request to Stripe first, then submit form. So I am creating something like

Code: Select all

$('body').on('click','#purchase-order-btn',function(e){
                    e.preventDefault();
                   // Some Stripe code before submit form
                });
But here a problem. What if user select not Stripe but Paypal? What if Paypal need another JS before submit form, or don't need it at all? I need to separate JS, if there are some code for Stripe, we run it. If there are no specific JS code for Paypal, we just submit the form.
Here is my solution. Is it okay? :? :? :?

http://joxi.ru/YmEyNnDFZkdMPm

http://joxi.ru/xAeY510fY13bJA
Last edited by Travin on 23 Jan 2018, 20:48, edited 3 times in total.
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

Re: Stripe subscriptions

Post by Travin » 23 Jan 2018, 19:30

The main idea is to separate html code from diferent Providers, and separate JS code from diferent Providers :?
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Stripe subscriptions

Post by aimeos » 23 Jan 2018, 23:05

My idea would be to add a method to the form helper object so providers can return specific HTML that is included into the template including JS code: https://github.com/aimeos/aimeos-core/b ... andard.php
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

Re: Stripe subscriptions

Post by Travin » 27 Jan 2018, 06:42

aimeos wrote:The data is stored as order service attribute items:
https://github.com/aimeos/aimeos-core/b ... e.php#L560

You can retrieve them using something like (<code> is the code of the service payment option):

Code: Select all

$orderBaseItem->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT, '<code>' )->getAttributes();
Here's are the interfaces:
https://aimeos.org/api/latest/class-Aim ... Attributes
https://aimeos.org/api/latest/class-Aim ... Iface.html
I want to explain this answer for Aimeos users here:
https://aimeos.org/docs/Developers/Libr ... figuration
Is it will be okay?
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Stripe subscriptions

Post by aimeos » 28 Jan 2018, 17:45

Sure, feel free to add more documentation. That's always welcome! :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

Re: Stripe subscriptions

Post by Travin » 06 Feb 2018, 18:47

Hey guys
I understood one thing about that row

Code: Select all

$var = $orderBaseItem->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT, '<code>' );
The second parameter Code does not matter at my 2017.10. It always returns me Aimeos\MShop\Order\Item\Base\Service\Standard Object

But at 2018.1 if I don't pass Code, I'm recieving data from several relative Providers. It returns me an ARRAY of Aimeos\MShop\Order\Item\Base\Service\Standard Object
If I pass current Service Provider code, it returns me just one object (one element of the array). Like at 2017.10

I think it's somehow relative to a new feature of 2018.1 about having more than one service provider.

And now I know I can recieve a code of current provider by this expression
$code = $this->getServiceItem()->getCode();

I want to explain it at the docs :idea:
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

Post Reply