本文整理汇总了PHP中ResultPrinter::printError方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultPrinter::printError方法的具体用法?PHP ResultPrinter::printError怎么用?PHP ResultPrinter::printError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResultPrinter
的用法示例。
在下文中一共展示了ResultPrinter::printError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: credit_card
public function credit_card()
{
return "Hello?";
$card = new CreditCard();
$card->setType("visa")->setNumber("4148529247832259")->setExpireMonth("11")->setExpireYear("2019")->setCvv2("012")->setFirstName("Joe")->setLastName("Shopper");
$fi = new FundingInstrument();
$fi->setCreditCard($card);
$payer = new Payer();
$payer->setPaymentMethod("credit_card")->setFundingInstruments(array($fi));
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')->setDescription('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setTax(0.3)->setPrice(7.5);
$item2 = new Item();
$item2->setName('Granola bars')->setDescription('Granola Bars with Peanuts')->setCurrency('USD')->setQuantity(5)->setTax(0.2)->setPrice(2);
$itemList = new ItemList();
$itemList->setItems(array($item1, $item2));
$details = new Details();
$details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5);
$amount = new Amount();
$amount->setCurrency("USD")->setTotal(20)->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description")->setInvoiceNumber(uniqid());
$payment = new Payment();
$payment->setIntent("sale")->setPayer($payer)->setTransactions(array($transaction));
$request = clone $payment;
try {
$payment->create($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError('Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.', 'Payment', null, $request, $ex);
exit(1);
}
ResultPrinter::printResult('Create Payment Using Credit Card', 'Payment', $payment->getId(), $request, $payment);
return $payment;
}
示例2: CreateTransaction
function CreateTransaction($transactionType, $itemArray, $details)
{
$payer = new Payer();
$payer->setPaymentMethod($GLOBALS['PAYPAL']['payment_method']);
$itemList = new ItemList();
$itemList->setItems($itemArray);
$amount = new Amount();
$amount->setCurrency($GLOBALS['PAYPAL']['currency'])->setTotal(GetDetailsTotal($details))->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)->setItemList($itemList)->setDescription($GLOBALS['TRANSACTION_TYPE']['DONATION']['payment_desc'])->setInvoiceNumber(uniqid());
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($GLOBALS['TRANSACTION_TYPE']['DONATION']['return_url'])->setCancelUrl($GLOBALS['TRANSACTION_TYPE']['DONATION']['cancel_url']);
$payment = new Payment();
$payment->setIntent($GLOBALS['TRANSACTION_TYPE']['DONATION']['intent'])->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction));
$request = clone $payment;
try {
$payment->create($GLOBALS['PAYPAL']['api_context']);
} catch (Exception $ex) {
ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
return false;
}
$approvalUrl = $payment->getApprovalLink();
echo $approvalUrl;
return array('request' => $request, 'payment' => $payment, 'approvalUrl' => $approvalUrl);
}
示例3: getInvoiceDetails
function getInvoiceDetails($invoiceNumber, $apiContext, $paypal)
{
try {
$invoice = Invoice::get($invoiceNumber, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Get Invoice", "Invoice", $invoice->getId(), $invoiceId, $ex);
exit(1);
}
$taxSum = 0;
foreach ($invoice->getItems() as $item) {
if ($item->getTax()) {
$taxSum += $item->getTax()->getAmount()->getValue();
}
}
$tID = 0;
//This is the key value to hook up with the classis paypal API
$tID = $paypal->request($invoice->getPayments()['0']->getTransactionId())['L_TRANSACTIONID0'];
return array('date' => $invoice->getPayments()['0']->getDate(), 'memo' => $invoice->getMerchantMemo(), 'number' => $invoice->getNumber(), 'tax' => $taxSum, 'tID' => $tID);
}
示例4: catch
$output = $webhook->create($apiContext);
} catch (Exception $ex) {
// ^ Ignore workflow code segment
if ($ex instanceof \PayPal\Exception\PayPalConnectionException) {
$data = $ex->getData();
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Created Webhook Failed. Checking if it is Webhook Number Limit Exceeded. Trying to delete all existing webhooks", "Webhook", "Please Use <a style='color: red;' href='DeleteAllWebhooks.php' >Delete All Webhooks</a> Sample to delete all existing webhooks in sample", $request, $ex);
if (strpos($data, 'WEBHOOK_NUMBER_LIMIT_EXCEEDED') !== false) {
require 'DeleteAllWebhooks.php';
try {
$output = $webhook->create($apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Created Webhook", "Webhook", null, $request, $ex);
exit(1);
}
} else {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Created Webhook", "Webhook", null, $request, $ex);
exit(1);
}
} else {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Created Webhook", "Webhook", null, $request, $ex);
exit(1);
}
// Print Success Result
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Created Webhook", "Webhook", $output->getId(), $request, $output);
return $output;
示例5: filter_input
<?php
// # Create Wallet
// This sample code demonstrate how you can create a wallet, as documented here at:
// <a href="http://dev.blockcypher.com/#wallet_api">http://dev.blockcypher.com/#wallet_api</a>
//
// API used: POST /v1/btc/main/wallets
require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
$walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
$walletName = 'alice';
// Default wallet name for samples
}
$wallet = new \BlockCypher\Api\Wallet();
$wallet->setName($walletName);
$wallet->setAddresses(array("1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"));
/// For Sample Purposes Only.
$request = clone $wallet;
$walletClient = new \BlockCypher\Client\WalletClient($apiContexts['BTC.main']);
try {
$output = $walletClient->create($wallet);
} catch (Exception $ex) {
ResultPrinter::printError("Created Wallet", "Wallet", null, $request, $ex);
exit(1);
}
ResultPrinter::printResult("Created Wallet", "Wallet", $output->getName(), $request, $output);
return $output;
示例6: Amount
<?php
// ##Reauthorization Sample
// This sample code demonstrates how you can reauthorize a PayPal
// account payment.
// API used: v1/payments/authorization/{authorization_id}/reauthorize
/** @var Authorization $authorization */
$authorization = (require 'AuthorizePayment.php');
use PayPal\Api\Authorization;
use PayPal\Api\Amount;
// ### Reauthorization
// Reauthorization is available only for PayPal account payments
// and not for credit card payments.
// You can reauthorize a payment only once 4 to 29
// days after the 3-day honor period for the original authorization
// has expired.
try {
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal(1);
// ### Reauthorize with amount being reauthorized
$authorization->setAmount($amount);
$reAuthorization = $authorization->reauthorize($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Reauthorize Payment", "Payment", null, null, $ex);
exit(1);
}
ResultPrinter::printResult("Reauthorize Payment", "Payment", $authorization->getId(), null, $reAuthorization);
示例7: CancelNotification
<?php
// # Cancel Invoice Sample
// This sample code demonstrate how you can cancel
// an invoice.
/** @var Invoice $invoice */
$invoice = (require 'SendInvoice.php');
use PayPal\Api\CancelNotification;
use PayPal\Api\Invoice;
try {
// ### Cancel Notification Object
// This would send a notification to both merchant as well
// the payer about the cancellation. The information of
// merchant and payer is retrieved from the invoice details
$notify = new CancelNotification();
$notify->setSubject("Past due")->setNote("Canceling invoice")->setSendToMerchant(true)->setSendToPayer(true);
// ### Cancel Invoice
// Cancel invoice object by calling the
// static `cancel` method
// on the Invoice class by passing a valid
// notification object
// (See bootstrap.php for more on `ApiContext`)
$cancelStatus = $invoice->cancel($notify, $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Cancel Invoice", "Invoice", null, $notify, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Cancel Invoice", "Invoice", $invoice->getId(), $notify, null);
示例8: filter_input
<?php
// # Generate New Address for a Wallet
//
// This sample code demonstrate how you can generate new addresses and associate them to a wallet,
// as documented here at: <a href="http://dev.blockcypher.com/#wallets">http://dev.blockcypher.com/#wallets</a>
//
// API used: GET /v1/btc/main/wallets/Wallet-Name/addresses/generate
// In samples we are using CreateWallet.php sample to get the created instance of wallet.
// You have to run that sample before running this one or there will be no wallets
require __DIR__ . '/../bootstrap.php';
if (isset($_GET['wallet_name'])) {
$walletName = filter_input(INPUT_GET, 'wallet_name', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
$walletName = 'alice';
// Default wallet name for samples
}
$walletClient = new \BlockCypher\Client\WalletClient($apiContexts['BTC.main']);
try {
/// Generate address in Wallet
$output = $walletClient->generateAddress($walletName);
} catch (Exception $ex) {
ResultPrinter::printError("Add Addresses to a Wallet", "WalletGenerateAddressResponse", $walletName, null, $ex);
exit(1);
}
ResultPrinter::printResult("Add Addresses to a Wallet", "WalletGenerateAddressResponse", $walletName, null, $output);
return $output;
示例9: catch
<?php
// # Get Payout Batch Status Sample
//
// This sample code demonstrate how you can get the batch payout status of a created batch payout, as documented here at:
// https://developer.paypal.com/docs/api/#get-the-status-of-a-batch-payout
// API used: GET /v1/payments/payouts/<Payout-Batch-Id>
/** @var \PayPal\Api\PayoutBatch $payoutBatch */
$payoutBatch = (require 'CreateBatchPayout.php');
// ## Payout Batch ID
// You can replace this with your Payout Batch Id on already created Payout.
$payoutBatchId = $payoutBatch->getBatchHeader()->getPayoutBatchId();
// ### Get Payout Batch Status
try {
$output = \PayPal\Api\Payout::get($payoutBatchId, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Get Payout Batch Status", "PayoutBatch", null, $payoutBatchId, $ex);
exit(1);
}
ResultPrinter::printResult("Get Payout Batch Status", "PayoutBatch", $output->getBatchHeader()->getPayoutBatchId(), null, $output);
return $output;
开发者ID:maherelgamil,项目名称:Small-store-for-books-with-Laravel-5.1,代码行数:21,代码来源:GetPayoutBatchStatus.php
示例10: Plan
// Please note that the plan Id should be only set in this case.
$plan = new Plan();
$plan->setId($createdPlan->getId());
$agreement->setPlan($plan);
// Add Payer
$payer = new Payer();
$payer->setPaymentMethod('credit_card')->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com')));
// Add Credit Card to Funding Instruments
$creditCard = new CreditCard();
$creditCard->setType('visa')->setNumber('4491759698858890')->setExpireMonth('12')->setExpireYear('2017')->setCvv2('128');
$fundingInstrument = new FundingInstrument();
$fundingInstrument->setCreditCard($creditCard);
$payer->setFundingInstruments(array($fundingInstrument));
//Add Payer to Agreement
$agreement->setPayer($payer);
// Add Shipping Address
$shippingAddress = new ShippingAddress();
$shippingAddress->setLine1('111 First Street')->setCity('Saratoga')->setState('CA')->setPostalCode('95070')->setCountryCode('US');
$agreement->setShippingAddress($shippingAddress);
// For Sample Purposes Only.
$request = clone $agreement;
// ### Create Agreement
try {
// Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.
$agreement = $agreement->create($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $ex);
exit(1);
}
ResultPrinter::printResult("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $agreement);
return $agreement;
开发者ID:maherelgamil,项目名称:Small-store-for-books-with-Laravel-5.1,代码行数:31,代码来源:CreateBillingAgreementWithCreditCard.php
示例11: array
// # Retrieve QR Code for Invoice Sample
// Specify an invoice ID to get a QR code (image) that corresponds to the invoice ID. A QR code for an invoice can be added to a paper or PDF invoice. When a customer uses their mobile device to scan the QR code, the customer is redirected to the PayPal mobile payment flow, where they can pay online with PayPal or a credit card.
/** @var Invoice $invoice */
$invoice = (require 'SendInvoice.php');
use PayPal\Api\Invoice;
try {
// ### Retrieve QR Code of Sent Invoice
// Retrieve QR Code of Sent Invoice by calling the
// `qrCode` method
// on the Invoice class by passing a valid
// notification object
// (See bootstrap.php for more on `ApiContext`)
$image = Invoice::qrCode($invoice->getId(), array('height' => '300', 'width' => '300'), $apiContext);
// ### Optionally Save to File
// This is not a required step. However, if you want to store this image as a file, you can use
// 'saveToFile' method with proper file name.
// This will save the image as /samples/invoice/images/sample.png
$path = $image->saveToFile("images/sample.png");
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $image);
// ### Show the Image
// In PHP, there are many ways to present an images.
// One of the ways, you could directly inject the base64-encoded string
// with proper image information in front of it.
echo '<img src="data:image/png;base64,' . $image->getImage() . '" alt="Invoice QR Code" />';
示例12: array
<?php
// # Get List of Plan Sample
//
// This sample code demonstrate how you can get a list of billing plan, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#list-plans
// API used: /v1/payments/billing-plans
// Retrieving the Plan object from Create Plan Sample to demonstrate the List
/** @var Plan $createdPlan */
$createdPlan = (require 'CreatePlan.php');
use PayPal\Api\Plan;
try {
// Get the list of all plans
// You can modify different params to change the return list.
// The explanation about each pagination information could be found here
// at https://developer.paypal.com/webapps/developer/docs/api/#list-plans
$params = array('page_size' => '2');
$planList = Plan::all($params, $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("List of Plans", "Plan", null, $params, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("List of Plans", "Plan", null, $params, $planList);
return $planList;
示例13: filter_input
<?php
// # Get UTXOs
// Get only unspent transaction outputs.
// This method allows you to retrieve details about an Address only with the unspent transactions.
//
// API called: '/v1/btc/main/addrs/1DEP8i3QJC...62aGvhD?unspentOnly=true'
require __DIR__ . '/../bootstrap.php';
/// override default sample address with GET parameter
if (isset($_GET['address'])) {
$sampleAddress = filter_input(INPUT_GET, 'address', FILTER_SANITIZE_SPECIAL_CHARS);
} else {
$sampleAddress = '1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD';
// Default address for samples
}
$addressClient = new \BlockCypher\Client\AddressClient($apiContexts['BTC.main']);
try {
$params = array('unspentOnly' => 'true');
$address = $addressClient->get($sampleAddress, $params);
} catch (Exception $ex) {
ResultPrinter::printError("Get Address", "Address", $sampleAddress, null, $ex);
exit(1);
}
ResultPrinter::printResult("Get Address", "Address", $address->getAddress(), null, $address);
return $address;
示例14: header
// Add Shipping Address
//$shippingAddress = new ShippingAddress();
//$shippingAddress->setLine1('111 First Street')
// ->setCity('Saratoga')
// ->setState('CA')
// ->setPostalCode('95070')
// ->setCountryCode('US');
//$agreement->setShippingAddress($shippingAddress);
//$merchant_override_pref = new \PayPal\Api\MerchantPreferences();
//$merchant_override_pref->setReturnUrl(getBaseUrl(). "pp/billing/UpdateBillingAgreement.php?user_id=$user_id");
//$agreement->setOverrideMerchantPreferences($merchant_override_pref);
// For Sample Purposes Only.
$request = clone $agreement;
// ### Create Agreement
try {
// Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.
$agreement = $agreement->create($apiContext);
// ### Get redirect url
// The API response provides the url that you must redirect
// the buyer to. Retrieve the url from the $agreement->getApprovalLink()
// method
$approvalUrl = $agreement->getApprovalLink();
header('Content-Type: application/json');
echo $agreement->toJSON(128);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Created Billing Agreement.", "Agreement", null, $request, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
// ResultPrinter::printResult("Created Billing Agreement. Please visit the URL to Approve.", "Agreement", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $agreement);
示例15: catch
<?php
// # Get WebHook
// This sample code demonstrate how you can get a webhook, as documented here at:
// <a href="http://dev.blockcypher.com/#webhooks">Using webhooks</a>
//
// API used: GET /v1/btc/main/hooks/WebHook-Id
// ## Create Sample WebHook
// In samples we are using CreateWebHook.php sample to get the created instance of webhook.
// However, in real case scenario, we could use just the ID.
/** @var \BlockCypher\Api\WebHook $webHook */
$webHook = (require 'CreateWebHook.php');
$webHookId = $webHook->getId();
$webHookClient = new \BlockCypher\Client\WebHookClient($apiContexts['BTC.main']);
// ## Get WebHook by Id
try {
/// Get WebHook by Id
$output = $webHookClient->get($webHookId);
} catch (Exception $ex) {
ResultPrinter::printError("Get a WebHook", "WebHook", null, $webHookId, $ex);
exit(1);
}
ResultPrinter::printResult("Get a WebHook", "WebHook", $output->getId(), null, $output);
return $output;