$posData); if ($bpOptions['verifyPos']) $pos['hash'] = crypt(serialize($posData), $options['apiKey']); $options['posData'] = json_encode($pos); $options['orderID'] = $orderId; $options['price'] = $price; $postOptions = array('orderID', 'itemDesc', 'itemCode', 'notificationEmail', 'notificationURL', 'redirectURL', 'posData', 'price', 'currency', 'physical', 'fullNotifications', 'transactionSpeed', 'buyerName', 'buyerAddress1', 'buyerAddress2', 'buyerCity', 'buyerState', 'buyerZip', 'buyerEmail', 'buyerPhone'); foreach($postOptions as $o) if (array_key_exists($o, $options)) $post[$o] = $options[$o]; $post = json_encode($post); $response = bpCurl('https://bitpay.com/api/invoice/', $options['apiKey'], $post); return $response; } // Call from your notification handler to convert $_POST data to an object containing invoice data function bpVerifyNotification($apiKey = false) { global $bpOptions; if (!$apiKey) $apiKey = $bpOptions['apiKey']; $post = file_get_contents("php://input"); if (!$post) return 'No post data'; $json = json_decode($post, true); if (is_string($json)) return $json; // error if (!array_key_exists('posData', $json)) return 'no posData'; $posData = json_decode($json['posData'], true); if($bpOptions['verifyPos'] and $posData['hash'] != crypt(serialize($posData['posData']), $apiKey)) return 'authentication failed (bad hash)'; $json['posData'] = $posData['posData']; return $json; } // $options can include ('apiKey') function bpGetInvoice($invoiceId, $apiKey=false) { global $bpOptions; if (!$apiKey) $apiKey = $bpOptions['apiKey']; $response = bpCurl('https://bitpay.com/api/invoice/'.$invoiceId, $apiKey); if (is_string($response)) return $response; // error $response['posData'] = json_decode($response['posData'], true); $response['posData'] = $response['posData']['posData']; return $response; } ?>