I am trying to implement PayPal payment using the access token. For this, I obtained the token and refresh token from our customer's PayPal account, when they are connected. I have successfully created the token using the refresh token and trying to create the payment with that token. I am not sure how to set the token in the Paypal PHP SDK.
$access_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
// obtained using refresh token
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$amount = new Amount();
$amount->setCurrency("GBP")
->setTotal(1);
$transaction = new Transaction();
$transaction->setAmount($amount);
$baseUrl = base_url();
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("$baseUrl/customer/paypal/complete?success=true")
->setCancelUrl("$baseUrl/paypal/complete?success=false");
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
$request = clone $payment;
try {
$payment->create($apiContext);
} catch (Exception $ex) {
}
Here I have the access token, But I don't get any method to apply this access token in this code. Does anyone know how to make payment using the access token?