PayPal Integration / Javascript issue

Hey there,

I’m trying to integrate PayPal in my Kirby project.

Simply I want a customer to pay a predefined amount via PayPal and store the information about the purchase in an kirby user’s field.

The payment process works quite fine.

When the payment process is done and approved by PayPal, following js script runs:

onApprove: function(data, actions) {
    return actions.order.capture().then(function(details) {
      // action belongs here

Now I struggle with running a php function from here on. I want to store an information about the payment in kirby.

'balance' => /* former balance + update amount */


Do you have some ideas or snippets for me?

Thank you so much!

Hi, welcome to the community!

I think you probably need to use PayPal webhooks here and an API endoint on the Kirby side. That way when something happens on the PayPal side like a succesful pay, the webhook will ping a message back to the Kirby site and you can then run some PHP when the endpoint gets hit from paypal.

Ive never actually done, and im sure someone will correct me if i point you to the wrong places here but i think you need to set the webhook up to pass back the user that paid and then hit the user update endpoint in the Kiirby API

From your script you could call a custom endpoint (aka route) via Ajax that then does the server side stuff.

1 Like