public function transactionNotification(Order $order, Request $request, Locator $service)
 {
     $notificationType = $request->notificacationType;
     $notificationCode = $request->notificationCode;
     if ($notificationType == 'transaction') {
         $transactionDetails = $service->getByNotification($notificationCode)->getDetails();
         if ($transactionDetails->getStatus() != 4) {
             $order->where('payment_transaction_code', $transactionDetails->getCode())->update(['status' => $transactionDetails->getStatus()]);
         }
     }
 }
예제 #2
0
 public function testGetByNotificationShouldDoAGetRequestAddingCredentialsData()
 {
     $credentials = $this->getMock(Credentials::class, [], [], '', false);
     $client = $this->getMock(CLient::class, [], [], '', false);
     $decoder = $this->getMock(Decoder::class, [], [], '', false);
     $locator = new Locator($credentials, $client, $decoder);
     $wsUrl = 'https://ws.test.com/v2/transactions?token=xxxxx';
     $credentials->expects($this->once())->method('getWsUrl')->with('/v2/pre-approvals/notifications/abcd', [])->willReturn($wsUrl);
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><transaction/>');
     $client->expects($this->once())->method('get')->with($wsUrl)->willReturn($xml);
     $transaction = $this->getMock(Transaction::class, [], [], '', false);
     $decoder->expects($this->once())->method('decode')->with($xml)->willReturn($transaction);
     $this->assertEquals($transaction, $locator->getByNotification('abcd'));
 }