mirror of
https://github.com/therootcompany/paypal-checkout.js.git
synced 2025-12-24 06:18:46 +00:00
Compare commits
No commits in common. "main" and "v0.3.0" have entirely different histories.
36
README.md
36
README.md
@ -135,13 +135,10 @@ here's the gist of what you need to do:
|
||||
});
|
||||
```
|
||||
|
||||
4. [Set](https://developer.paypal.com/developer/applications) and Handle the
|
||||
[`PAYMENT.CAPTURE.COMPLETED`, `PAYMENT.CAPTURE.REVERSED`, and `CUSTOMER.DISPUTE.CREATED`](https://developer.paypal.com/docs/api-basics/notifications/webhooks/event-names/)
|
||||
WebHooks
|
||||
4. Handle the PAYMENT.CAPTURE.COMPLETED WebHook
|
||||
|
||||
```js
|
||||
// Set webhook at https://developer.paypal.com/developer/applications
|
||||
// Descriptions at https://developer.paypal.com/docs/api-basics/notifications/webhooks/event-names/
|
||||
app.get("/api/webhooks/paypal-checkout/:secret", async function (req, res) {
|
||||
let crypto = require("crypto");
|
||||
let secret = process.env.PAYPAL_WEBHOOK_SECRET || "";
|
||||
@ -157,30 +154,13 @@ here's the gist of what you need to do:
|
||||
|
||||
let event = req.body;
|
||||
switch (event.event_type) {
|
||||
case "PAYMENT.CAPTURE.COMPLETED":
|
||||
{
|
||||
let orderId = event.supplementary_data.related_ids.order_id;
|
||||
let localDbId = event.custom_id;
|
||||
console.info(
|
||||
`Confirm that PayPal Order ${orderId} for ${localDbId} has been paid.`
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "PAYMENT.CAPTURE.REVERSED":
|
||||
{
|
||||
// deduct from user's account
|
||||
}
|
||||
break;
|
||||
case "CUSTOMER.DISPUTE.CREATED":
|
||||
{
|
||||
// TODO send email to merchant (myself) to check out the dispute
|
||||
}
|
||||
break;
|
||||
case "CUSTOMER.DISPUTE.CREATED":
|
||||
{
|
||||
// TODO send email to merchant (myself) to review the dispute status
|
||||
}
|
||||
break;
|
||||
case "PAYMENT.CAPTURE.COMPLETED": {
|
||||
let orderId = event.supplementary_data.related_ids.order_id;
|
||||
let localDbId = event.custom_id;
|
||||
console.info(
|
||||
`Confirm that PayPal Order ${orderId} for ${localDbId} has been paid.`
|
||||
);
|
||||
}
|
||||
default:
|
||||
console.log("Ignoring", event.event_type);
|
||||
res.json({ sucess: true });
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@root/paypal-checkout",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@root/paypal-checkout",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.0",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"dependencies": {
|
||||
"@root/request": "^1.7.0"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@root/paypal-checkout",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.0",
|
||||
"description": "A more sensible, human-generated wrapper for the PayPal Checkout REST API",
|
||||
"main": "paypal-checkout.js",
|
||||
"files": [
|
||||
|
||||
@ -441,7 +441,6 @@ Subscription.payee_preferences = {
|
||||
IMMEDIATE_PAYMENT_REQUIRED: "IMMEDIATE_PAYMENT_REQUIRED",
|
||||
};
|
||||
|
||||
// See https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create
|
||||
Subscription.createRequest = async function _createSubscription({
|
||||
request_id,
|
||||
plan_id,
|
||||
@ -450,8 +449,6 @@ Subscription.createRequest = async function _createSubscription({
|
||||
shipping_amount,
|
||||
subscriber,
|
||||
application_context,
|
||||
custom_id,
|
||||
plan,
|
||||
}) {
|
||||
return await PayPal.request({
|
||||
method: "POST",
|
||||
@ -499,8 +496,6 @@ Subscription.createRequest = async function _createSubscription({
|
||||
}
|
||||
*/
|
||||
application_context: application_context,
|
||||
custom_id: custom_id,
|
||||
plan: plan,
|
||||
},
|
||||
})
|
||||
.then(must201or200)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user