payment rysgala
This commit is contained in:
parent
a5c87fa592
commit
3c39bb4760
|
|
@ -144,10 +144,15 @@ class Checkout extends CheckoutController
|
||||||
|
|
||||||
$cart = Cart::getCart();
|
$cart = Cart::getCart();
|
||||||
|
|
||||||
if ($redirectUrl = Payment::getRedirectUrl($cart)) {
|
$payment = Config::get('paymentmethods.' . $cart->payment->method);
|
||||||
return response([
|
|
||||||
'redirect_url' => $redirectUrl,
|
if (isset($payment['api_url']))
|
||||||
]);
|
{
|
||||||
|
$paymentClass = app($payment['class']);
|
||||||
|
|
||||||
|
$result = $paymentClass->registerOrder();
|
||||||
|
|
||||||
|
return response($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
$order = $orderRepository->create(Cart::prepareDataForOrder());
|
$order = $orderRepository->create(Cart::prepareDataForOrder());
|
||||||
|
|
|
||||||
|
|
@ -52,14 +52,38 @@ class AltynAsyr extends Payment
|
||||||
'orderNumber' =>$cart->id . Carbon::now()->timestamp,
|
'orderNumber' =>$cart->id . Carbon::now()->timestamp,
|
||||||
'currency' => 934,
|
'currency' => 934,
|
||||||
'language' => 'ru',
|
'language' => 'ru',
|
||||||
'description'=> "bagisto multivendor {$cart->grand_total}m.",
|
'description'=> "Elektronika sowda: {$cart->grand_total}m.",
|
||||||
'amount' =>$cart->grand_total * 100,// amount w kopeykah
|
'amount' => $cart->grand_total * 100,// amount w kopeykah
|
||||||
'returnUrl' => route('paymentmethod.altynasyr.success'),
|
'returnUrl' => route('paymentmethod.altynasyr.success',['cart_id'=>$cart->id]),
|
||||||
'failUrl' => route('paymentmethod.altynasyr.cancel')
|
'failUrl' => route('paymentmethod.altynasyr.cancel')
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
try {
|
||||||
|
$result = json_decode($client->post('register.do',$params)->getBody(),true);
|
||||||
|
|
||||||
return json_decode($client->post('register.do',$params)->getBody(),true);
|
if($result['errorCode'] == 0){
|
||||||
|
return [
|
||||||
|
"success" => $this->registerOrderId($result['orderId']),
|
||||||
|
"url" => $result['formUrl'],
|
||||||
|
"message" => "unable to save order id"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
else{//if already registered or otkazana w dostupe
|
||||||
|
return [
|
||||||
|
"success" => false,
|
||||||
|
"message" => $result['errorMessage']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch(\Exception $e){
|
||||||
|
// Log::info($result);
|
||||||
|
// Log::error($e);
|
||||||
|
return [
|
||||||
|
"success" => false,
|
||||||
|
"message" => $e->getMessage()
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,18 +96,47 @@ class AltynAsyr extends Payment
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrderStatus(){
|
public function getOrderStatus(){
|
||||||
$client = $this->getApiClient();
|
try{
|
||||||
$payment = $this->getCart()->payment;
|
$client = $this->getApiClient();
|
||||||
|
|
||||||
$params = [
|
$payment = $this->getCart()->payment;
|
||||||
'form_params' => [
|
|
||||||
'userName' => $this->getConfigData('business_account'),//'103161020074',
|
|
||||||
'password' => $this->getConfigData('account_password'),//'E12wKp7a7vD8',
|
|
||||||
'orderId' => $payment->order_id,
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
return json_decode($client->post('getOrderStatus.do',$params)->getBody(),true);
|
$orderId = request()->get('orderId');
|
||||||
|
|
||||||
|
if($payment && $payment->order_id === $orderId){
|
||||||
|
$params = [
|
||||||
|
'form_params' => [
|
||||||
|
'userName' => $this->getConfigData('business_account'),
|
||||||
|
'password' => $this->getConfigData('account_password'),
|
||||||
|
'orderId' => $payment->order_id,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$result = json_decode($client->post('getOrderStatus.do',$params)->getBody(),true);
|
||||||
|
|
||||||
|
if($result['ErrorCode'] == 0 && $result['OrderStatus'] == 2){
|
||||||
|
return [
|
||||||
|
"success" => true,
|
||||||
|
"message" => "Payment successful"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
"success" => false,
|
||||||
|
"message" => $result['ErrorMessage']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
"success" => false,
|
||||||
|
"message" => "Malformed request"
|
||||||
|
];
|
||||||
|
}catch(\Exception $e){
|
||||||
|
return [
|
||||||
|
"success" => false,
|
||||||
|
"message" => $e->getMessage()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue