Merx – Plugin to create online shops with Kirby 3

, ,

That wasn’t really an option because my store was already nearly done with lots of changes. But I made the effort, started over with a fresh Starterkit and Kirby install and merged my changes. I’m almost there (not having tested payments yet), but I can’t get my fonts to load anymore. In the former version I added


font-src \'self\';

in the CSP in the config.php and it worked, now even with copying the old part CSP part in the config it doesn’t anymore. But I remember I read somewhere you made changes in that area to make it simpler:) So could you please tell me where to allow fonts now?

I commented out the CSP headers in the route:after hook to avoid issues on local test environments. When you use the config.php from v1.1.0 there should be no issues with CSP.
Can you please check why your fonts are not loaded.

Great, I pasted that part from v1.1.0 into my config and now it works in MAMP. Sorry if that’s a dumb question, but do I then need to uncomment the CSP headers for production and how would I go about fonts then?

I would recommend adding CSP headers as they add another layer of security.

It depends on how you include your fonts (self-hosted or not). I can’t tell you how to do this in your case. MDN always has very good information on such topics: CSP: font-src - HTTP | MDN

Thank you for the ressource, I was able to set the CSP headers and make my fonts work.

Unfortunately, also with the new Starterkit v1.1.0, I’m having the same issue like in the beginning: deleting two payment methods from the collection results in 201 redirect errors.

Just to be sure: when I’m using merx-starterkit from Github and not explicitly v1.1.0, it’s still already the newest version, right?

Update:

I deployed with all five payment options as they seem to work, but couldn’t solve the problem when deleting two methods. I also couldn’t find a solution for my image/thumb problem in the variants, but I’m a photographer, that’s was I was able to achieve based on the Starterkit and it’ll do for now:) Here is the link, in case someone is interested: Prints

Anyway thanks a lot for cooking up Merx, it’s awesome not to be dependent on a subscription based shopware! (very likely I messed up your beautifully clean code though)

Have a nice week!
Carola

@tobiasfabian Is the Stripe Session ID accessible after the checkout process? Preferably on the /success page or within the completePayment:after hook. I’d like to add the customer ID to the user’s Kirby Account for integration with the Stripe Customer Portal. I’ve done this previously with Stripe Checkout like so:

$id = $_GET['session_id'];
$session 	= \Stripe\Checkout\Session::retrieve($id);
$customer 	= \Stripe\Customer::retrieve($session->customer);

Hi,

Sorry for digging up a really old post here, but did you get subscriptions working with Kirby + Merx + Stripe? I have a site already using Merx but need to sell memberships on a recurring basis as well. If you managed it, and have any pointers, that would be awesome.

Thanks!

Hi @mikeharrison,

I realized that I needed a heavily-integrated subscription system and ended up writing a plugin from scratch. I briefly considered extending Merx, but I realized it would require a significant amount of new code that wouldn’t necessarily be relevant to most Merx users.

My suggestion (if you do consider this route) would be to add a new SubscriptionCart class that extends ProductList but supports the concept of products having different subscription terms. It’s highly likely that you will want to allow users to add products to their cart, but dynamically switch whether billing is monthly or yearly (for example). This toggle needs to a core part of the cart implementation. Finally, you would need to extend Payment to support a Stripe subscription checkout. Subscription checkouts have their own options and cannot be mixed with regular product checkouts.

Hope that’s helpful and I’m sorry I can’t be of more help.

Of course, it will vary depending on each subscription setup/process. If your subscription packages are not complex, it can be easily integrated. I integrated subscription packages by matching them with Stripe price_id, it works great.

I’m trying to get a basic webshop up and running locally. After downloading the starter kit and adding Kirby 3.9.6.1, I get a debugger screen saying: Class “OrderPageAbstract” not found. I couldn’t find anything in search results for this problem.

After trying out the set-up guide, it seems the Order Page Model already exists?

<?php
 
/**
 * It is required to create an Order Page Model
 * https://merx.wagnerwagner.de/docs/getting-started/set-up#order-page-model
 *
 * @author Tobias Wolf
 */
 
class OrderPage extends OrderPageAbstract
{
    public function title(): \Kirby\Cms\Field
    {
        return new Field($this, 'title', t('order.invoice') . ' ' . $this->invoiceNumber());
    }
}
 

How can I solve this?

Hello. Do you have an order.php in site/models/order.php ?

Edit: Never mind. I was under the impression that the startedpack already included a version of the Merx plugin but just figured out I had to put it in manually. This solved the problem:)

hey @tobiasfabian, how did you do the VAT connected country-list dropdown on your checkout?
https://merx.wagnerwagner.de/buy

Thanks, Max

Hi @tobiasfabian,
Hi Forum,

I have a problem in my completePaytment:after hook.
I do a few things like creating a PDF, sending it via email and sending the data to a shipping platform for further operations and saving some IDs.
The Problem I face, that Kirby blocks completely also for other visitors on the website until all things are done. Which is too long. We are talking about 3-5 seconds. For someone ordering and paying I think it is ok, but for someone on the website at the same time, just browsing, it is way too long.
Do you have any ideas how I can solve this?

 'ww.merx.completePayment:after' => function (OrderPage $orderPage) {
// Stock updates
            if (option('debug') !== true) {
                foreach($orderPage->cart() as $cartItem) {
                    $productPage = page($cartItem['id']);
                    if ($productPage && $productPage->stock()->isNotEmpty()) {
                        $stock = $productPage->stock()->toFloat();
                        $productPage->update([
                            'stock' => $stock - (float)$cartItem['quantity'],
                        ]);
                    }
                }
            }

// Creates PDF ans sends an email to the customer
            createPDF($orderPage, 'email');

//adds the user to Mailchimp if user checked with the required data
            $mailchimp = kirby()->session()->get('mailchimp', 'string');
            if($mailchimp == 'accepted'){
                $uuid = $orderPage->uuid();
                mailchimp($uuid);
            }

//Facebook Coversion API
            $uuid = $orderPage->uuid();
            fb_capi($uuid, 'Purchase', kirby()->session()->get('event_id'));


//Send Data to the Shipping Platform and receiving ID, storing it with the order
            kirby()->impersonate('kirby');
            if ($orderPage->paymentComplete()->toBool()) {
                $uuid = $orderPage->uuid();
                $data = parcel($uuid);
                $orderPage = $orderPage->update([
                    'parcel_id' => $data
                ]);
            }


//Add user ID, if user is logged in
            kirby()->impersonate();
            if( kirby()->user() ){
                $orderPage = $orderPage->update([
                    'userID' => kirby()->user()->id(),
                ]);
            }
        },

Everything else works great. Just the delay for all users gives me a headache.

Thanks,
Simon

Hey, how is the completeCheckout with the Stripe-hosted page variant managed in MERX (Customize redirect behavior with a Stripe-hosted page | Stripe Documentation). Cannot find a payment method for this or is it solvable with credit-card-sca? Thanks in advance!

Hey i have installed merx with Composer and create the Order Page Model. But now i became the Error: Declaration of OrderPageAbstract::title(): Kirby\Cms\Field must be compatible with Kirby\Cms\Page::title(): Kirby\Content\Field

Hey @maximiliankiepe1,

Stripe-hosted pages are not supported by Merx. If you want to use Stripe-hosted pages, you may not need Merx at all, as everything related to the shop (shopping cart, payment) is managed by Stripe – as far as I understand.

Hey @RobinBirr,

I have not been able to reproduce this problem. Have you used the latest version of Kirby 4? If the problem still exists, could you please create a new issue on GitHub (Issues · wagnerwagner/merx · GitHub)?

Additional context: This refers to the change of the namespace of the Field class. As mentioned in the Refactoring changelog a compatibility alias is provided.

Moved the Content, ContentTranslation and Field classes into the new namespace (compatibility aliases are provided for now)
Kirby 4 | Kirby CMS

Hi there,

i have a Kirby4-Page and tried to install MERX via composer (I’m really new at working with composer. Do I have to use it or could I simply drop the folder under site/pugins?)
the installation worked, but composer downgraded my kirby to 3.10 in the installation routine.
the Kirby-plugin-page says Merx is kompatible with Kirby4.

So please tell me how I can install Merx with Kirby 4.

Thanks a lot,
Matthias