Agreeing to a transaction using Escrow API

  0 comments
Share

In the previous blog https://bit.ly/2uQ5qDL, we had covered on Creating a milestone based transaction with broker commission using Escrow API. This blog is about Agreeing to a transaction using Escrow API.

When the Escrow transaction is created by broker, the terms of the transaction are automatically agreed to by the broker. But, it is required that the buyer and seller in the transaction agree to the transaction before the transaction can move ahead.

Agreeing to a transaction is done by calling the transaction endpoint with action set to agree.

<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.escrow-sandbox.com/2017-09-01/transaction/1780385', CURLOPT_RETURNTRANSFER => 1, CURLOPT_USERPWD => 'broker@drupalchamp.org:233_57fgvc5vIpiqwp6B8Z2986vc4dsfsdftwxHlgpEtOeE5gRPuyzw', //broker email:api key(api key must be generated from broker account) CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'As-Customer: client@drupalchamp.org' //pass worker or seller email here ), CURLOPT_CUSTOMREQUEST => 'PATCH', CURLOPT_POSTFIELDS => json_encode( array( 'action' => 'agree', //action set to agree ) ) )); $output = curl_exec($curl); print_r($output); curl_close($curl); ?>

If the API call is successful, it will return the updated transaction object.

Example Response:-- { "close_date": null, "creation_date": "2019-04-03T11:01:38.880000+00:00", "currency": "usd", "description": "Website Header Development tasks", "id": 1780385, //unique transaction ID generated by Escrow.com "items": [ { "description": "Website Header Development", "fees": [ { "amount": "17.88", "amount_without_taxes": "17.88", //Escrow service fee "payer_customer": "client@drupalchamp.org", "split": "1.0", "type": "escrow" } ], "id": 2302550, "inspection_period": 259200, "quantity": 1, "schedule": [ { "amount": "500.00", "beneficiary_customer": "worker@drupalchamp.org", "payer_customer": "client@drupalchamp.org", "status": { "disbursed_to_beneficiary": false, "secured": false } } ], "status": { "accepted": false, "accepted_returned": false, "canceled": false, "received": false, "received_returned": false, "rejected": false, "rejected_returned": false, "shipped": false, "shipped_returned": false }, "title": "Website Header Development", "type": "milestone" }, { "fees": [ ], "parent_item_id": 2302550, "quantity": 1, "schedule": [ { "amount": "50.00", "beneficiary_customer": "broker@drupalchamp.org", "payer_customer": "client@drupalchamp.org", "status": { "disbursed_to_beneficiary": false, "secured": false } } ], "title": "Broker Fee", "type": "broker_fee" }, { "fees": [ ], "parent_item_id": 2302550, "quantity": 1, "schedule": [ { "amount": "40.00", "beneficiary_customer": "broker@drupalchamp.org", "payer_customer": "worker@drupalchamp.org", "status": { "disbursed_to_beneficiary": false, "secured": false } } ], "title": "Broker Fee", "type": "broker_fee" } ], "parties": [ { "agreed": true, /// Client agreement done by Above API call "customer": "client@drupalchamp.org", "id": 4559907, "initiator": false, "role": "buyer" }, { "agreed": false, "customer": "worker@drupalchamp.org", "disbursement_method_selected": false, "id": 4618359, "initiator": false, "next_step": "https://www.escrow-sandbox.com/agree?tid=1780385&token=9d146cbc-cb17-4ed5-9164-145528bebcc8", //worker/seller can be agree to the transaction by this link "role": "seller" }, { "agreed": true, "customer": "broker@drupalchamp.org", "disbursement_method_selected": false, "id": 4618360, "initiator": true, "role": "broker" }, { "agreed": true, "customer": "broker@drupalchamp.org", "id": 4618361, "role": "partner" } ] }

Add new comment