/** * @dataProvider mockProvider * @param PaymentForward $obj */ public function testDelete($obj, $mockApiContext) { $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock(); $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(true)); $result = $obj->delete($mockApiContext, $mockBlockCypherRestCall); $this->assertNotNull($result); }
/** * Obtain multiple PaymentForwards resources for the given identifiers. * * @param string[] $array * @param array $params Parameters * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls * @return PaymentForward[] */ public function getMultiple($array, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($array, 'array'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array('token' => 1); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $paymentForwardList = implode(";", $array); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall("{$chainUrlPrefix}/payments/{$paymentForwardList}?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall); return PaymentForward::getList($json); }
/** * Obtain all PaymentForward resources for the provided token. * * @deprecated since version 1.2. Use PaymentForwardClient. * @param array $params Parameters. Options: token * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls * @return PaymentForward[] */ public static function getAll($params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array('token' => 1); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall("{$chainUrlPrefix}/payments?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall); return PaymentForward::getList($json); }
<?php // Run on console: // php -f .\sample\payment-api\CreatePaymentEndpoint.php require __DIR__ . '/../bootstrap.php'; use BlockCypher\Api\PaymentForward; use BlockCypher\Auth\SimpleTokenCredential; use BlockCypher\Client\PaymentForwardClient; use BlockCypher\Rest\ApiContext; $apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG')); $paymentForwardClient = new PaymentForwardClient($apiContext); $options = array('callback_url' => 'http://requestb.in/rwp6jirw?uniqid=' . uniqid()); $paymentForward = $paymentForwardClient->createForwardingAddress('15qx9ug952GWGTNn7Uiv6vode4RcGrRemh', $options); // For Sample Purposes Only. $request = new PaymentForward(); $request->setDestination('15qx9ug952GWGTNn7Uiv6vode4RcGrRemh'); $request->setCallbackUrl('http://requestb.in/rwp6jirw?uniqid=' . uniqid()); ResultPrinter::printResult("Create Payment Endpoint", "PaymentForward", $paymentForward->getId(), $request, $paymentForward);