Closed kesavanselvakani closed 1 year ago
Hi @kesavanselvakani,
You should implement a try / catch in order to get more details about the error. What you're looking for is :
$e->GetErrorDetails()->Message
$e->GetErrorDetails()->Errors
Hi @H4wKs
try{
// create instance of MangoPayApi
$mangoPayApi = new \MangoPay\MangoPayApi();
$mangoPayApi->Config->ClientId = config('app.project.MangoPay.ClientId');
$mangoPayApi->Config->ClientPassword = config('app.project.MangoPay.ClientPassword');
$mangoPayApi->Config->TemporaryFolder = config('app.project.MangoPay.TemporaryFolder');
$mangoPayApi->Config->BaseUrl = config('app.project.MangoPay.URL');
// dd($mangoPayApi->Config->BaseUrl);
$total_pay = isset($transaction_inp['total_pay']) ? $transaction_inp['total_pay'] : 0;
$cost_website_commission = isset($transaction_inp['cost_website_commission']) ? $transaction_inp['cost_website_commission'] : 0;
// for JPY currency we don't need to multiple by 100
if($transaction_inp['currency_code']!='JPY'){
$total_pay = $total_pay*100;
$cost_website_commission = $cost_website_commission*100;
}
if($transaction_inp != null){
$transfer = new \MangoPay\Transfer();
$transfer->Tag = $transaction_inp['tag'];
$transfer->AuthorId = $transaction_inp['debited_UserId'];
$transfer->CreditedUserId = $transaction_inp['credited_UserId'];
$transfer->DebitedFunds = new \MangoPay\Money();
$transfer->DebitedFunds->Currency = $transaction_inp['currency_code'];
$transfer->DebitedFunds->Amount = $total_pay;
$transfer->Fees = new \MangoPay\Money();
$transfer->Fees->Currency = $transaction_inp['currency_code'];
$transfer->Fees->Amount = $cost_website_commission;
$transfer->DebitedWalletId = $transaction_inp['debited_walletId'];
$transfer->CreditedWalletId = $transaction_inp['credited_walletId'];
// dd($transfer);
$result = $mangoPayApi->Transfers->Create($transfer);
// dd($result);
return $result;
}else{
// dd('hi');
return false;
}
}catch(MangoPay\Libraries\ResponseException $e){
// dd($e);
if($is_contest_refund_cron == '1'){
return $e;
}
//dd($e);
// handle/log the response exception with code $e->GetCode(), message $e->GetMessage() and error(s) $e->GetErrorDetails()
return "Exception : ".$e->GetCode()."| Message: ".$e->GetMessage()."| Error(s) ".$e->GetErrorDetails();
} catch(MangoPay\Libraries\Exception $e) {
// dd($e);
if($is_contest_refund_cron == '1'){
return $e;
}
return "Message: ".$e->GetMessage();
}catch(\Exception $e){
// dd($e);
if($is_contest_refund_cron == '1'){
return $e;
}
return $e->getMessage();
}
}
This is my code..
You should just put a try on what may fail.
use MangoPay\Libraries\ResponseException;
try {
$result = $mangoPayApi->Transfers->Create($transfer);
} catch (ResponseException $e) {
/*
Here you handle the error the way you want.
*/
}
And in the catch, what you want to get as information is what I write earlier
$e->GetErrorDetails()->Message
$e->GetErrorDetails()->Errors
I don't remember which one of them have the detailed error message you are looking for, but it's part of one of them.
Hello @kesavanselvakani, did you fix your issue ?
@fredericdelordm Yes i have fixed the issue.. Thank you
Transfer {#2596 ▼ +DebitedWalletId: "153589518" +CreditedWalletId: "71953670" +AuthorId: "153589517" +CreditedUserId: "71953669" +DebitedFunds: Money {#2595 ▶} +CreditedFunds: Money {#2548 ▶} +Fees: Money {#2594 ▶} +Status: null +ResultCode: null +ResultMessage: null +ExecutionDate: null +Type: null +Nature: null +Id: null +Tag: "INV20221209BA6AC8- Job Service fee" +CreationDate: null }
I am try to transfer the money in my wallet to admin wallet. but this type of error display