当前位置: 首页>>代码示例>>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;未经允许,请勿转载。