Hanley Soilsmith
Hanley Soilsmith

Reputation: 629

How to use a PayPal Webhook properly? Simulator works, App does not

I see that much has been asked about PayPal Webhooks, but few threads have answers, and the people with a similar question as mine have not been answered. So maybe this will land with someone!

I want a Webhook that sends all payment information to my server. If I simulate a Webhook to the following server, it works properly:

const express = require("express");
app = express();
app.use(express.json());
const bodyParser = require("body-parser");

app.post("/", (req, res, next) => {
 console.log(req.body);
  res.status(200);
 res.send("on");
 next();
});

app.listen(3000, () => console.log("server started"));

I am using the pay button made for react. It works in that it successfully executes the payment and logs payment info to the console. Code is:

import React from "react";
import PaypalExpressBtn from "react-paypal-express-checkout";

export default class Pay extends React.Component {
  render() {
    const onSuccess = payment => {
      console.log(payment);
    };

    let env = "sandbox"; 
    let currency = "USD"; 
    let total = 3.29; 

    const client = {
      sandbox:
        "ID_FROM_MY_API_WITH_WEBHOOKS_ENABLED",
      production: "YOUR-PRODUCTION-APP-ID"
    };

    return (
      <div>
        <PaypalExpressBtn
          onSuccess={onSuccess}
        />
      </div>
    );
  }
}

I have an API with webhooks enabled, and am using the clientID given in that API. Any ideas? Thanks!

Upvotes: 0

Views: 72

Answers (1)

Hanley Soilsmith
Hanley Soilsmith

Reputation: 629

This issue was solved by using the node SDK implementation for adding and verifying webhooks. The dashboard did not work.

Upvotes: -1

Related Questions