Problem when set currency in MercadopagoSDK

398 Views Asked by At

I'm using the Mercado pago API to get paid. The code itself is working normally, the problem is that I can not set a coin manually. He already creates the transaction with the local currency for the MercadoPago account I am using.

I tried to set the currency manually as follows: $payment->currency = "USD";

I used var_dump to see how it returned the payment object and he returned me: string(58) "The name of the following parameters is wrong : [currency]"

When I do not put the coin the transaction is normally done and the $payment-> currency it returns is from my local currency in this case as I am in Brazil, it is the "BRL"

<?php  
MercadoPago\SDK::setAccessToken("TEST-6879657297193510-042902-edae012a62c69ecf8d30230b8496817d-426624866");
//...
$payment = new MercadoPago\Payment();
$payment->transaction_amount = 168;
$payment->token = "ff8080814c11e237014c1ff593b57b4d";
$payment->description = "Small Cotton Shirt";
$payment->installments = 1;
$payment->payment_method_id = "visa";
$payment->currency = "USD";
$payment->payer = array(
"email" => "[email protected]"
);
// Save and posting the payment
$payment->save();
//...
// Print the payment status
echo var_dump($payment);
//...
?>

My questions is: is it possible to receive payments in other currencies with Mercado pago API? and if yes how do xD

Note: I already looked a lot in the documentation but I did not find anything if anyone can help me thank you very much

1

There are 1 best solutions below

0
dobau On

Edited.

Yes, you can. You should use currency_id instead of currency.