Marking all milestones as completed using Escrow API

  0 comments
Share

 

Marking a transaction and all of its items as completed is a simple patch request to the transaction endpoint with the action attribute set to ship.

 

 

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

In above code CURLOPT_URL, 1944203 is transaction ID and 2472773 is milestone item ID.
If the API call is successful, it will return the updated transaction object.

stdClass Object ( [description] => Map customization on Contact us page [fees] => Array ( [0] => stdClass Object ( [amount] => 3.33 [amount_without_taxes] => 3.33 [payer_customer] => client@drupalchamp.org [split] => 1.0 [type] => escrow ) ) [id] => 2472773 [inspection_period] => 1296000 [quantity] => 1 [schedule] => Array ( [0] => stdClass Object ( [amount] => 90.00 [beneficiary_customer] => worker@drupalchamp.org [payer_customer] => client@drupalchamp.org [status] => stdClass Object ( [disbursed_to_beneficiary] => [secured] => 1 ) ) ) [status] => stdClass Object ( [accepted] => [accepted_returned] => [canceled] => [in_dispute] => [received] => [received_returned] => [rejected] => [rejected_returned] => [shipped] => 1 [shipped_returned] => ) [title] => Map customization on Contact us page [type] => milestone )

Add new comment