Accept PayPal payments without website

Viewed 80

I do not have a website and I would like to just send a link to the user and get the appropriate response whether they paid or not on the PayPal website and handle the rest.

Basically I dont want to redirect the user anywhere.

After configuring my PayPal credentials I have the following

var create_payment_json = {
    "intent": "sale",
    "payer": {
        "payment_method": "paypal"
    },
    // I WANT TO REMOVE THAT BUT IF I DO I GET AN ERROR IN RESPONSE
    "redirect_urls": {
        "return_url": "http://return.url",
        "cancel_url": "http://cancel.url"
    },
    "transactions": [{
        "item_list": {
            "items": [{
                "name": "item",
                "sku": "item",
                "price": "1.00",
                "currency": "USD",
                "quantity": 1
            }]
        },
        "amount": {
            "currency": "USD",
            "total": "1.00"
        },
        "description": "This is the payment description."
    }]
};


paypal.payment.create(create_payment_json, function (error, payment) {
    if (error) {
        throw error;
    } else {
        console.log("Create Payment Response");
        console.log(payment);
    }
});

var paymentId = 'PAYMENT id created in previous step';

//check if user payed or not
paypal.payment.execute(paymentId, execute_payment_json, function (error, payment) {
    if (error) {
        console.log(error.response);
        throw error;
    } else {
        console.log("Get Payment Response");
        console.log(JSON.stringify(payment));
    }
});
0 Answers
Related