PayPal Plus - Webhook - to change payment status in database PayPal Plus - Webhook - to change payment status in database curl curl

PayPal Plus - Webhook - to change payment status in database


Getting the data you need, is easy.You are calling PP and a json_encoded variable ($json) is the result.

Now you have access to these value like:

$webhooks[0]->id

But to get the data you need (here transaction_id and new status), you use the wrong call.

payment/payments/PAYMENT_ID

is the service you need for this.


Don't call! Wait for a call and process.

public function webhook() {    $body = file_get_contents('php: //input');    $data = json_decode($body, true);    //Validate and verify webhook here.    if ($data['event_type'] == 'PAYMENT.AUTHORIZATION.CREATED') {        //Payment authorization created.    } else if ($data['event_type'] == 'PAYMENT.AUTHORIZATION.VOIDED') {        //Payment authorization voided.    } else if ($data['event_type'] == 'PAYMENT.CAPTURE.COMPLETED') {        //Payment capture completed.    } else if ($data['event_type'] == 'PAYMENT.CAPTURE.DENIED') {        //Payment capture denied.    } else if ($data['event_type'] == 'PAYMENT.CAPTURE.PENDING') {        //Payment capture pending.    } else if ($data['event_type'] == 'PAYMENT.CAPTURE.REFUNDED') {        //Payment capture refunded.    } else if ($data['event_type'] == 'PAYMENT.CAPTURE.REVERSED') {        //Payment capture reversed.    } else {        //Handle other webhooks    }}