本文整理汇总了PHP中Pedido::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Pedido::findOrFail方法的具体用法?PHP Pedido::findOrFail怎么用?PHP Pedido::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pedido
的用法示例。
在下文中一共展示了Pedido::findOrFail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createOrderBasico
public function createOrderBasico($id)
{
$pedido = Pedido::findOrFail($id);
$cliente = Auth::user();
if ($pedido->usuario->id != $cliente->id) {
return false;
}
$valor_centavos = $pedido->total * 100;
$input = Input::all();
if ($input['parcelas'] < 1 || $input['parcelas'] > 6) {
return false;
}
$client = new SoapClient('https://transaction.mundipaggone.com/MundiPaggService.svc?wsdl', array('trace' => true, 'exceptions' => true, 'style' => SOAP_DOCUMENT, 'use' => SOAP_LITERAL, 'encoding' => 'UTF-8'));
$createOrderRequest = new stdClass();
$createOrderRequest->createOrderRequest = new stdClass();
//$createOrderRequest->createOrderRequest->AmountInCents = 105172;
$createOrderRequest->createOrderRequest->AmountInCents = $valor_centavos;
$createOrderRequest->createOrderRequest->CurrencyIsoEnum = 'BRL';
$createOrderRequest->createOrderRequest->MerchantKey = self::MerchantKey;
$createOrderRequest->createOrderRequest->OrderReference = $pedido->id;
$createOrderRequest->createOrderRequest->Buyer = new stdClass();
$createOrderRequest->createOrderRequest->Buyer->Email = $cliente->email;
$createOrderRequest->createOrderRequest->Buyer->HomePhone = '(11) 12345678';
$createOrderRequest->createOrderRequest->Buyer->Name = $cliente->nome;
$createOrderRequest->createOrderRequest->Buyer->PersonTypeEnum = 'Person';
$createOrderRequest->createOrderRequest->Buyer->TaxDocumentNumber = $cliente->cpf;
$createOrderRequest->createOrderRequest->Buyer->TaxDocumentTypeEnum = 'CPF';
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection = [];
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0] = new stdClass();
//$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->AmountInCents = 105172;
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->AmountInCents = $valor_centavos;
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->CaptureDelayInMinutes = 0;
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->CreditCardBrandEnum = $input['cartao_marca'];
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->CreditCardNumber = $input['cartao_num'];
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->ExpMonth = $input['mes_exp'];
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->ExpYear = $input['ano_exp'];
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->HolderName = $input['nome_titular'];
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->InstallmentCount = $input['parcelas'];
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->PaymentMethodCode = 1;
$createOrderRequest->createOrderRequest->CreditCardTransactionCollection[0]->SecurityCode = $input['cod_seguranca'];
try {
$auth = $client->CreateOrder($createOrderRequest);
$result = $auth->CreateOrderResult;
$cctResult = $result->CreditCardTransactionResultCollection->CreditCardTransactionResult;
printf("Exemplo de integração Mundipagg com PHP - CreateOrder\n\n");
printf("\t[%s -> %s] %s\n\n", $result->OrderStatusEnum, $cctResult->CreditCardTransactionStatusEnum, $cctResult->AcquirerMessage);
} catch (SoapFault $e) {
printf("Erro[%s]: %s\n%s\n\n", $e->getCode(), $e->getMessage(), $e->getTraceAsString());
}
}
示例2: postSendOrder
public function postSendOrder()
{
$pedido = Pedido::findOrFail(Input::get('pedido_id'));
$input = Input::all();
$mundipagg = new Mundipagg();
$response = $mundipagg->createOrder($input, $pedido);
if (isset($input['cpftitular']) && !empty($input['cpftitular'])) {
$pedido->titular_cpf = $input['cpftitular'];
$pedido->save();
} elseif (isset($input['passaportetitular']) && !empty($input['passaportetitular'])) {
$pedido->titular_passaporte = $input['passaportetitular'];
$pedido->save();
}
if ($response->Success) {
$pedido->pedido_status_id = 25;
$pedido->num_parcelas = isset($input['parcelas']) ? $input['parcelas'] : 1;
$pedido->OrderKey = $response->OrderKey;
$pedido->OrderStatusEnum = $response->OrderStatusEnum;
$pedido->save();
return Redirect::to('cliente/pedido')->with('success', [trans('checkout.sucesso')]);
} else {
$erros = [];
$erros[0] = trans('checkout.erro');
if (isset($response->ErrorReport) && $response->ErrorReport && isset($response->ErrorReport->ErrorItemCollection) && count($response->ErrorReport->ErrorItemCollection) > 0) {
foreach ($response->ErrorReport->ErrorItemCollection as $error) {
if (isset($error->Description) && !empty($error->Description)) {
$erros[] = $error->Description;
}
}
// echo '<hr>';
// echo var_dump($response->ErrorReport->ErrorItemCollection);
}
return Redirect::back()->with('danger', $erros);
}
// echo '<pre>';
// echo var_dump($response);
// echo var_dump($response->ErrorReport);
// echo '</pre>';
}