<?php // # Delete PaymentForward // This sample code demonstrate how to use this call to delete a PaymentForward, as documented here at: // <a href="http://dev.blockcypher.com/#delete-payment-endpoint">Delete Payment Endpoint</a> // // API used: DELETE /v1/btc/main/payments/PaymentForward-Id // ## Create PaymentForward Instance // This step is not necessarily required. We are creating a PaymentForward for sample purpose only, // so that we would not get an empty list at any point. // In real case, you do not need to create any PaymentForward to make this API call. /** @var \BlockCypher\Api\PaymentForward $paymentForward */ $paymentForward = (require 'CreatePaymentForward.php'); $paymentForwardClient = new \BlockCypher\Client\PaymentForwardClient($apiContexts['BTC.main']); try { $output = $paymentForwardClient->delete($paymentForward->getId()); } catch (Exception $ex) { ResultPrinter::printError("Delete a PaymentForward", "PaymentForward", null, $paymentForward->getId(), $ex); exit(1); } ResultPrinter::printResult("Delete a PaymentForward", "PaymentForward", $paymentForward->getId(), null, null); return $output;
<?php // # List All PaymentForwards // Use this call to list all the PaymentForwards, as documented here at: // <a href="http://dev.blockcypher.com/#list-payments-endpoint">List Payments Endpoint</a> // // API used: GET /v1/btc/main/payments?token=<Your-Token> // ## Create one PaymentForward // This step is not necessarily required. We are creating a PaymentForward for sample purpose only, // so that we would not get an empty list at any point. // In real case, you do not need to create any PaymentForward to make this API call. /** @var \BlockCypher\Api\PaymentForward $paymentForward */ $paymentForward = (require 'CreateForwardingAddress.php'); $paymentForwardClient = new \BlockCypher\Client\PaymentForwardClient($apiContexts['BTC.main']); try { $output = $paymentForwardClient->listForwardingAddresses(); } catch (Exception $ex) { ResultPrinter::printError("List Forwarding Addresses", "PaymentForward[]", null, null, $ex); exit(1); } ResultPrinter::printResult("List Forwarding Addresses", "PaymentForward[]", null, null, $output); return $output;
<?php // # Get Multiple PaymentForwards // This sample code demonstrate how you can get multiple PaymentForwards at once. // // API used: GET /v1/btc/main/payments/PaymentForward-Id;PaymentForward-Id // ## Get PaymentForward ID // In samples we are using CreateForwardingAddress.php sample to get the created instance of PaymentForward. // However, in real case scenario, we could use just the ID. /** @var \BlockCypher\Api\PaymentForward $paymentForward */ $paymentForward = (require 'CreateForwardingAddress.php'); $paymentForwardId01 = $paymentForward->getId(); $paymentForwardId02 = $paymentForward->getId(); $paymentForwardClient = new \BlockCypher\Client\PaymentForwardClient($apiContexts['BTC.main']); try { /// Get Multiple Forwarding Addresses $paymentForwardList = array($paymentForwardId01, $paymentForwardId02); $output = $paymentForwardClient->getMultiple($paymentForwardList); } catch (Exception $ex) { ResultPrinter::printError("Get Multiple Forwarding Addresses", "PaymentForward[]", null, implode(';', $paymentForwardList), $ex); exit(1); } ResultPrinter::printResult("Get Multiple Forwarding Addresses", "PaymentForward[]", implode(';', $paymentForwardList), null, $output); return $output;
<?php // # Delete All PaymentForwards // This is a sample helper method, to delete all existing PaymentForwards. // To properly use the sample, change the token from bootstrap.php file with your own app token. // ## Get All PaymentForwards // We use ListPaymentForwards sample to get a PaymentForward list. /** @var \BlockCypher\Api\PaymentForward[] $paymentForwardList */ $paymentForwardList = (require 'ListForwardingAddresses.php'); $paymentForwardClient = new \BlockCypher\Client\PaymentForwardClient($apiContexts['BTC.main']); // ## Delete All PaymentForwards try { $paymentForwardIdList = array(); /** @var \BlockCypher\Api\PaymentForward $paymentForward */ foreach ($paymentForwardList as $paymentForward) { /// Only for Sample Purposes. List of deleted resources $paymentForwardIdList[] = $paymentForward->getId(); /// Delete PaymentForward $paymentForwardClient->deleteForwardingAddress($paymentForward->getId()); } } catch (Exception $ex) { ResultPrinter::printError("Delete All PaymentForwards", "", implode(';', $paymentForwardIdList), null, $ex); exit(1); } ResultPrinter::printResult("Delete All PaymentForwards", "", implode(';', $paymentForwardIdList), null, null);
<?php // # Get PaymentForward // // This sample code demonstrate how you can get a PaymentForward, as documented here at: // <a href="http://dev.blockcypher.com/#list-payments-endpoint">http://dev.blockcypher.com/#list-payments-endpoint</a> // // API used: GET /v1/btc/main/payments/PaymentForward-Id // ## Get PaymentForward ID // In samples we are using CreateForwardingAddress.php sample to get the created instance of PaymentForward. // However, in real case scenario, we could use just the ID. /** @var \BlockCypher\Api\PaymentForward $paymentForward */ $paymentForward = (require 'CreateForwardingAddress.php'); $paymentForwardId = $paymentForward->getId(); $paymentForwardClient = new \BlockCypher\Client\PaymentForwardClient($apiContexts['BTC.main']); try { /// Get PaymentForward $output = $paymentForwardClient->getForwardingAddress($paymentForwardId); } catch (Exception $ex) { ResultPrinter::printError("Get Forwarding Address", "PaymentForward", null, $paymentForwardId, $ex); exit(1); } ResultPrinter::printResult("Get Forwarding Address", "PaymentForward", $output->getId(), null, $output); return $output;
<?php // # Create a Payment Forwarding Address // // This sample code demonstrate how you can create a payment forwarding address, as documented here at: // <a href="http://dev.blockcypher.com/#create-payment-endpoint">Create Payment Endpoint</a> // // API used: POST /v1/btc/main/payments require __DIR__ . '/../bootstrap.php'; $paymentForwardClient = new \BlockCypher\Client\PaymentForwardClient($apiContexts['BTC.main']); $destination = '15qx9ug952GWGTNn7Uiv6vode4RcGrRemh'; $callbackUrl = 'http://requestb.in/rwp6jirw?uniqid=' . uniqid(); /// For Sample Purposes Only. $paymentForward = new \BlockCypher\Api\PaymentForward(); $paymentForward->setDestination($destination); $paymentForward->setCallbackUrl($callbackUrl); $request = clone $paymentForward; $options = array('callback_url' => $callbackUrl); try { $output = $paymentForwardClient->createForwardingAddress($destination, $options); } catch (Exception $ex) { ResultPrinter::printError("Create Forwarding Address", "PaymentForward", null, $request, $ex); exit(1); } ResultPrinter::printResult("Create Forwarding Address", "PaymentForward", $output->getId(), $request, $output); return $output;