很遗憾,PayPal 尚不支持多种货币。 See supported currency code.
无论如何,如果您想实现必须使用货币转换器的东西,您可以使用 Google API 或 Yahoo API。
您可以访问here 并与您的后端开发人员讨论此事,他会以更好、更简单的方式为您提供帮助,
我在Android原生应用雅虎汇率之类的,
中使用过一次
第 1 步:
private String fromCurrency = "QAR";
private String toCurrency = "USD";
private String urlString = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Ffinance.yahoo.com%2Fd%2Fquotes.csv%3Fe%3D.csv%26f%3Dc4l1%26s%3D" + fromCurrency + toCurrency + "%3DX%22%3B&format=json";
第 2 步:
private void apiCallCurrencyConversion() {
//Don't mind you can you retrofit call too,
OkHttpClient client = new OkHttpClient();
final Request request = new Request.Builder()
.url(urlString)
.build();
client.newCall(request).enqueue(new okhttp3.Callback() {
@Override
public void onFailure(@NonNull okhttp3.Call call, @NonNull IOException e) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this,"Fail", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onResponse(@NonNull okhttp3.Call call, @NonNull okhttp3.Response response) throws IOException {
runOnUiThread(new Runnable() {
@Override
public void run() {
}
});
if (response.code() == 200 && response.isSuccessful()) {
final CurrencyYahooApiJSON currencyYahooApiJSON = new Gson().fromJson(response.body().string(), CurrencyYahooApiJSON.class);
Log.d(TAG, currencyYahooApiJSON.getQuery().getResults().getRow().getConvertedValue());
runOnUiThread(new Runnable() {
@Override
public void run() {
proceedToPay(currencyYahooApiJSON);
}
});
}
}
});
}
你可以从here下载ResponseJsonObject pojo
现在您可以使用 USD 换算后的价值了,
第 3 步:
private void proceedToPay(CurrencyYahooApiJSON currencyYahooApiJSON) {
//Getting the amount from editText
String paymentAmount = "100";
Row row = currencyYahooApiJSON.getQuery().getResults().getRow();
double val = Double.valueOf(paymentAmount);
double convertedAmount = val * Double.valueOf(row.getConvertedValue());
// convertedAmount here will us get is near about 27.41
//PayPal Configuration & payment process ahead.
}
干杯