當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FileData::setFromFile方法代碼示例

本文整理匯總了PHP中FileData::setFromFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileData::setFromFile方法的具體用法?PHP FileData::setFromFile怎麽用?PHP FileData::setFromFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在FileData的用法示例。


在下文中一共展示了FileData::setFromFile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: dirname

require_once dirname(__FILE__) . "/../../PaygateApiClient.class.php";
require_once dirname(__FILE__) . "/../config.php";
$client = new PaygateApiClient(INVIPAY_API_URL, INVIPAY_API_KEY, INVIPAY_SIGNATURE_KEY);
$repository = dirname(__FILE__) . "/repository/";
$payments = scandir($repository);
Logger::info('Scanning payments repository');
foreach ($payments as $paymentFile) {
    if ($paymentFile != '.' && $paymentFile != '..') {
        Logger::info('Found payment data {0}', $paymentFile);
        $paymentData = unserialize(file_get_contents($repository . $paymentFile));
        $paymentId = $paymentData->getPaymentId();
        Logger::info('Payment {0} has status {1}', $paymentId, $paymentData->getStatus());
        if ($paymentData->getStatus() == PaymentRequestStatus::COMPLETED) {
            Logger::info('Finalizing payment {0}', $paymentId);
            $request = new PaymentManagementData();
            $request->setPaymentId($paymentId);
            $request->setDoConfirmDelivery(true);
            $conversionData = new OrderToInvoiceData();
            $conversionData->setInvoiceDocumentNumber("TestInvoice/1/2/3/" . uniqid());
            $conversionData->setIssueDate(date('Y-m-d', time()));
            $conversionData->setDueDate(date('Y-m-d', time() + 14 * 24 * 60 * 60));
            $request->setConversionData($conversionData);
            $document = new FileData();
            $document->setFromFile(dirname(__FILE__) . '/../test.pdf');
            $request->setDocument($document);
            $result = $client->managePayment($request);
            Logger::info('Result is: {0}', $result);
        }
    }
}
開發者ID:invipay,項目名稱:invipay-php-api,代碼行數:30,代碼來源:Manage.example.php

示例2: TransactionsFilter

Logger::info('Searching for an order transaction');
$filter = new TransactionsFilter();
$filter->setSide(TransactionSide::SALE);
$filter->setType(TransactionType::ORDER);
$result = $client->listTransactions($filter);
$ordersCount = count($result);
Logger::info('Found {0} orders', $ordersCount);
if ($ordersCount > 0) {
    $orderId = $result[0]->getId();
    Logger::info('Using order {0} for further processing', $orderId);
}
// Convert order to invoice
if ($orderId !== null) {
    Logger::info('Converting order {0} into invoice', $orderId);
    $pdf = new FileData();
    $pdf->setFromFile(dirname(__FILE__) . '/../test.pdf');
    $data = new OrderConversionData();
    $data->setTransactionId($orderId);
    $data->setInvoiceDocumentNumber("Converted from order " . uniqid());
    $data->setIssueDate(date('Y-m-d', time()));
    $data->setDueDate(date('Y-m-d', time() + 30 * 24 * 60 * 60));
    $data->setInvoiceDocument($pdf);
    $result = $client->convertOrderToInvoice($data);
    Logger::info('Result is: {0}', $result);
}
// Confirm delivery
if ($orderId !== null) {
    Logger::info('Confirming delivery for transaction {0}', $orderId);
    $result = $client->confirmDelivery($orderId);
    Logger::info('Result is: {0}', $result);
}
開發者ID:invipay,項目名稱:invipay-php-api,代碼行數:31,代碼來源:Manage.example.php


注:本文中的FileData::setFromFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。