public static Payment CreatePayment(string baseUrl, string intent) { ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; // ### Api Context // Pass in a `APIContext` object to authenticate // the call and to send a unique request id // (that ensures idempotency). The SDK generates // a request id if you do not pass one explicitly. var apiContext = PayPalConfiguration.GetAPIContext(); // Payment Resource var payment = new Payment() { intent = intent, // `sale` or `authorize` payer = new Payer() { payment_method = "paypal", payer_info = new PayerInfo { billing_address = new Address { line1 = "1 Main St", line2 = "SAN JOSE, CA 95131", city = "SAN JOSE", state = "CA", postal_code = "95131", country_code = "US" }, first_name = "ravi", last_name = "roy" } }, transactions = GetTransactionsList(), redirect_urls = GetReturnUrls(baseUrl, intent) }; // Create a payment using a valid APIContext var createdPayment = payment.Create(apiContext); return(createdPayment); }
public static Payment ExecutePayment(string paymentId, string payerId) { // ### Api Context // Pass in a `APIContext` object to authenticate // the call and to send a unique request id // (that ensures idempotency). The SDK generates // a request id if you do not pass one explicitly. var apiContext = PayPalConfiguration.GetAPIContext(); var paymentExecution = new PaymentExecution() { payer_id = payerId }; var payment = new Payment() { id = paymentId }; // Execute the payment. var executedPayment = payment.Execute(apiContext, paymentExecution); return(executedPayment); }