当前位置: 首页>>代码示例>>PHP>>正文


PHP ResultPrinter::printResult方法代码示例

本文整理汇总了PHP中ResultPrinter::printResult方法的典型用法代码示例。如果您正苦于以下问题:PHP ResultPrinter::printResult方法的具体用法?PHP ResultPrinter::printResult怎么用?PHP ResultPrinter::printResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ResultPrinter的用法示例。


在下文中一共展示了ResultPrinter::printResult方法的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;
 }
开发者ID:2ppaamm,项目名称:kudotsu,代码行数:33,代码来源:PaypalController.php

示例2: catch

<?php

// # VoidAuthorization
// This sample code demonstrates how you can
// void an authorized payment.
// API used: /v1/payments/authorization/<{authorizationid}>/void"
/** @var Authorization $authorization */
$authorization = (require 'AuthorizePayment.php');
// Replace $authorizationid with any static Id you might already have. It will do a void on it
$authorizationId = '1BF65516U6866543H';
// $authorization->getId();
use PayPal\Api\Authorization;
// ### VoidAuthorization
// You can void a previously authorized payment
// by invoking the $authorization->void method
// with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
try {
    // Lookup the authorization
    $authorization = Authorization::get($authorizationId, $apiContext);
    // Void the authorization
    $voidedAuth = $authorization->void($apiContext);
} catch (Exception $ex) {
    ResultPrinter::printError("Void Authorization", "Authorization", null, null, $ex);
    exit(1);
}
ResultPrinter::printResult("Void Authorization", "Authorization", $voidedAuth->getId(), null, $voidedAuth);
return $voidedAuth;
开发者ID:maherelgamil,项目名称:Small-store-for-books-with-Laravel-5.1,代码行数:27,代码来源:VoidAuthorization.php

示例3: AgreementStateDescriptor

<?php

// # Suspend an agreement
//
// This sample code demonstrate how you can suspend a billing agreement, as documented here at:
// https://developer.paypal.com/webapps/developer/docs/api/#suspend-an-agreement
// API used: /v1/payments/billing-agreements/<Agreement-Id>/suspend
// Retrieving the Agreement object from Create Agreement Sample to demonstrate the List
/** @var Agreement $createdAgreement */
$createdAgreement = (require 'CreateBillingAgreementWithCreditCard.php');
use PayPal\Api\Agreement;
use PayPal\Api\AgreementStateDescriptor;
//Create an Agreement State Descriptor, explaining the reason to suspend.
$agreementStateDescriptor = new AgreementStateDescriptor();
$agreementStateDescriptor->setNote("Suspending the agreement");
try {
    $createdAgreement->suspend($agreementStateDescriptor, $apiContext);
    // Lets get the updated Agreement Object
    $agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("Suspended the Agreement", "Agreement", null, $agreementStateDescriptor, $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Suspended the Agreement", "Agreement", $agreement->getId(), $agreementStateDescriptor, $agreement);
return $agreement;
开发者ID:Roc4rdho,项目名称:app,代码行数:27,代码来源:SuspendBillingAgreement.php

示例4: SimpleTokenCredential

<?php

// Run on console:
// php -f .\sample\wallet-api\GenerateAddressInHDWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\HDWalletClient;
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'));
$walletClient = new HDWalletClient($apiContext);
$hdWalletGenerateAddressResponse = $walletClient->generateAddress('bob');
ResultPrinter::printResult("Generate Address in a HDWallet", "HDWalletGenerateAddressResponse", $walletName, null, $hdWalletGenerateAddressResponse);
开发者ID:toneloc,项目名称:php-client,代码行数:12,代码来源:GenerateAddressInHDWalletEndpoint.php

示例5: Amount

// # AuthorizationCapture
// This sample code demonstrates how you can capture
// a previously authorized payment.
// API used: /v1/payments/payment
// https://developer.paypal.com/webapps/developer/docs/api/#capture-an-authorization
/** @var Authorization $authorization */
$authorization = (require 'GetAuthorization.php');
use PayPal\Api\Amount;
use PayPal\Api\Capture;
use PayPal\Api\Authorization;
// ### Capture Payment
// You can capture and process a previously created authorization
// by invoking the $authorization->capture method
// with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
try {
    $authId = $authorization->getId();
    $amt = new Amount();
    $amt->setCurrency("USD")->setTotal(1);
    ### Capture
    $capture = new Capture();
    $capture->setAmount($amt);
    // Perform a capture
    $getCapture = $authorization->capture($capture, $apiContext);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("Capture Payment", "Authorization", null, $capture, $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Capture Payment", "Authorization", $getCapture->getId(), $capture, $getCapture);
return $getCapture;
开发者ID:omasterdesign,项目名称:omasterdefault,代码行数:31,代码来源:AuthorizationCapture.php

示例6: catch

// You need to get a permanent refresh token from the authorization code, retrieved from the mobile sdk.
// authorization code from mobile sdk
$authorizationCode = 'EJfRuAqXEE95pdVMmOym_mftTbeJD03RBX-Zjg9pLCAhdLqLeRR6YSKTNsrbQGX7lFoZ3SxwFyxADEZbBOxpn023W9SA0JzSQAy-9eLdON5eDPAyMyKlHyNVS2DqBR2iWVfQGfudbd9MDoRxMEjIZbY';
// Client Metadata id from mobile sdk
// For more information look for PayPal-Client-Metadata-Id in https://developer.paypal.com/docs/api/#authentication--headers
$clientMetadataId = '123123456';
try {
    // Exchange authorization_code for long living refresh token. You should store
    // it in a database for later use
    $refreshToken = FuturePayment::getRefreshToken($authorizationCode, $apiContext);
    // Update the access token in apiContext
    $payment->updateAccessToken($refreshToken, $apiContext);
    // For Sample Purposes Only.
    $request = clone $payment;
    // ### Create Future Payment
    // Create a payment by calling the 'create' method
    // passing it a valid apiContext.
    // (See bootstrap.php for more on `ApiContext`)
    // The return object contains the state and the
    // url to which the buyer must be redirected to
    // for payment approval
    // Please note that currently future payments works only with PayPal as a funding instrument.
    $payment->create($apiContext, $clientMetadataId);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("Future Payment", "Payment", null, $request, $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Future Payment", "Payment", $payment->getId(), $request, $payment);
return $payment;
开发者ID:namnv609,项目名称:PayPal-PHP-SDK,代码行数:31,代码来源:CreateFuturePayment.php

示例7: catch

$billingInfo = $invoice->getBillingInfo()[0];
$billingInfo->setAddress(null);
$invoice->getPaymentTerm()->setDueDate(null);
try {
    // ### Update Invoice
    // Update an invoice by calling the invoice->update() method
    // with a valid ApiContext (See bootstrap.php for more on `ApiContext`)
    $invoice->update($apiContext);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("Invoice Updated", "Invoice", null, $request, $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Invoice Updated", "Invoice", $invoice->getId(), $request, $invoice);
// ### Retrieve Invoice
// Retrieve the invoice object by calling the
// static `get` method
// on the Invoice class by passing a valid
// Invoice ID
// (See bootstrap.php for more on `ApiContext`)
try {
    $invoice = Invoice::get($invoice->getId(), $apiContext);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $invoice);
return $invoice;
开发者ID:Roc4rdho,项目名称:app,代码行数:31,代码来源:UpdateInvoice.php

示例8: catch

<?php

// # List Invoices Sample
// This sample code demonstrate how you can get
// all invoice from history.
/** @var Invoice $invoice */
$invoice = (require 'CreateInvoice.php');
use PayPal\Api\Invoice;
try {
    // ### Retrieve Invoices
    // Retrieve the Invoice History object by calling the
    // static `get_all` method on the Invoice class.
    // Refer the method doc for valid values for keys
    // (See bootstrap.php for more on `ApiContext`)
    $invoices = Invoice::getAll(array('page' => 0, 'page_size' => 4, 'total_count_required' => "true"), $apiContext);
} catch (Exception $ex) {
    // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
    ResultPrinter::printError("Lookup Invoice History", "Invoice", null, null, $ex);
    exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Lookup Invoice History", "Invoice", null, null, $invoices);
开发者ID:Roc4rdho,项目名称:app,代码行数:22,代码来源:ListInvoice.php

示例9: SimpleTokenCredential

<?php

// Run on console:
// php -f .\sample\transaction-api\PushRawTransactionEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\TXClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('test3', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$txClient = new TXClient($apiContext);
$hexRawTx = "01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000";
$tx = $txClient->push($hexRawTx);
// For Sample Purposes Only.
$txHex = new \BlockCypher\Api\TXHex();
$txHex->setTx($hexRawTx);
ResultPrinter::printResult("Push Raw Transaction", "TX", null, $txHex, $tx);
开发者ID:toneloc,项目名称:php-client,代码行数:16,代码来源:PushRawTransactionEndpoint.php

示例10: 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

示例11: 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

示例12: 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" />';
开发者ID:paypal,项目名称:rest-api-sdk-php,代码行数:30,代码来源:RetrieveQRCode.php

示例13: 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;
开发者ID:paypal,项目名称:rest-api-sdk-php,代码行数:26,代码来源:ListPlans.php

示例14: 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;
开发者ID:toneloc,项目名称:php-client,代码行数:25,代码来源:GetAddressWithUnspentOnly.php

示例15: filter_input

<?php

// # Derive New Address in a HD Wallet
//
// This sample code demonstrate how you can derive new addresses in a hd wallet,
// as documented here at <a href="http://dev.blockcypher.com/#derive-address-in-wallet-endpoint">docs</a>
//
// API used: GET /v1/btc/main/wallets/hd/Wallet-Name/addresses/derive
// In samples we are using CreateHDWallet.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 = 'bob';
    // Default hd wallet name for samples
}
$walletClient = new \BlockCypher\Client\HDWalletClient($apiContexts['BTC.main']);
try {
    /// Generate new address
    $output = $walletClient->deriveAddress($walletName);
} catch (Exception $ex) {
    ResultPrinter::printError("Derive Address in a HDWallet", "HDWallet", $walletName, null, $ex);
    exit(1);
}
ResultPrinter::printResult("Derive Address in a HDWallet", "HDWallet", $walletName, null, $output);
return $output;
开发者ID:blockcypher,项目名称:php-client,代码行数:27,代码来源:DeriveAddressInHDWallet.php


注:本文中的ResultPrinter::printResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。