pub fn execute(
bearer: &str,
payment_id: &str,
payer_id: &str,
) -> Result<Payment, Error>
Expand description
Finalizes charging of a previously constructed payment. This usually comes after the payment has been created and approved by the customer.
use paypal::{get_token, payment};
use paypal::{PaymentMethod, PaymentIntent, Transaction, TransactionAmount};
let token = get_token("my_id", "my_secret").unwrap();
let amount = TransactionAmount {
currency: "USD".to_string(),
total: "100.00".to_string()
};
let new_payment = payment::new(
&token.access_token,
"mysite.com/whooyoupaid",
"mysite.com/nooyoufailed",
PaymentMethod::Paypal,
PaymentIntent::Sale,
vec![Transaction { amount }],
).unwrap();
// Have the user approve the payment here, using the webpage in payment.links, for example:
let payer_id = function_that_sends_user_to_webpage(&new_payment);
let finalized_payment = payment::execute(&token, &new_payment.id, &payer_id).unwrap();