Ejemplo n.º 1
0
 public function payRequest($data)
 {
     $order = $this->prepareOrder($data);
     $alipayRequest = $this->getRequestData($order);
     $alipayRequest['sign'] = $this->rsaSign($alipayRequest);
     $order->setOrderData('alipay_request', $alipayRequest)->setPaymentGatewayUrl($this->createGatewayUrl($alipayRequest));
     $order->save();
     return Result::create(['order' => $order]);
 }
Ejemplo n.º 2
0
 public function testInvalidResult()
 {
     $e = null;
     try {
         Result::create(['foo' => 'bar']);
     } catch (ResultException $e) {
     }
     $this->assertInstanceOf(ResultException::class, $e);
     $this->assertEquals(ResultException::INVALID_RESULT_FORMAT, $e->getCode());
 }
Ejemplo n.º 3
0
 public function callback($data)
 {
     try {
         $this->verifyCallbackParameters($data);
         $this->verifyCallbackSign(null, $data, fnGet($data, 'sign'));
         $order = $this->getCallbackOrder(fnGet($data, 'out_trade_no'));
         $status = fnGet($data, 'trade_status');
         // Processing
         if ($status == 'WAIT_BUYER_PAY') {
             if ($order->canConfirm()) {
                 $order->confirm(__('Alipay callback status %status%', ['status' => $status]));
                 $order->save();
             }
             return Result::create(['order' => $order, 'response' => 'success']);
         }
         // Success
         if ($status == 'TRADE_FINISHED' || $status == 'TRADE_SUCCESS') {
             if ($order->canComplete()) {
                 $this->verifyCallbackAmount($order, fnGet($data, 'total_fee'));
                 $order->complete('Test Callback');
                 $order->save();
             }
             return Result::create(['order' => $order, 'response' => 'success']);
         }
         // Failure
         if ($order->canFail()) {
             $order->fail(__('Alipay callback status %status%', ['status' => $status]));
             $order->save();
         }
         return Result::create(['order' => $order, 'response' => 'success']);
     } catch (CallbackException $e) {
         return Result::create(['error' => $e, 'response' => 'FAILED']);
     } catch (Exception $e) {
         Log::exception($e);
         return Result::create(['error' => $e, 'response' => 'FAILED']);
     }
     // @codeCoverageIgnoreEnd
 }
Ejemplo n.º 4
0
 public function payRequest($data)
 {
     $order = $this->prepareOrder($data);
     $order->save();
     return Result::create(['order' => $order]);
 }