I am trying to integrate paypal, but stuck with this error.
We’re sorry. This seller doesn’t accept payments in your currency. Please return to the seller and choose another way to pay.
The currency I am setting is USD. I have not blocked it and I have added it into my account.
Here is the code, I am using PHP.
$transaction_value = $this->payment_detail['amount'];
// $this->response($transaction_value);
$apiContext = new \PayPal\Rest\ApiContext(new \PayPal\Auth\OAuthTokenCredential(PAYPAL_CLIENTID,PAYPAL_SECRET));
$payer = new \PayPal\Api\Payer();
$payer->setPaymentMethod('paypal');
$amount = new \PayPal\Api\Amount();
$amount->setTotal($transaction_value);
$amount->setCurrency($this->payment_detail['currency']);
// $amount->setCurrency('INR');
$transaction = new \PayPal\Api\Transaction();
$transaction->setAmount($amount);
$redirectUrls = new \PayPal\Api\RedirectUrls();
$redirectUrls->setReturnUrl(PROTOCOL.base_url().'pay/api/process')
->setCancelUrl(PROTOCOL.base_url().'home');
$payment = new \PayPal\Api\Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setTransactions(array($transaction))
->setRedirectUrls($redirectUrls);
try {
$payment->create($apiContext);
// $this->response(array("paymentId" => $payment->id));
header('Location: '.$payment->getApprovalLink());
exit(0);
// echo $payment;
// echo "\n\nRedirect user to approval_url: " . $payment->getApprovalLink() . "\n";
}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
// This will print the detailed information on the exception.
//REALLY HELPFUL FOR DEBUGGING
echo $ex->getData();
}