简体   繁体   中英

Paypal .Net SDK implementation

Dear StackOverflow Community, We have started to implement the PayPal .Net SDK in our project.

We create a Payment with the following Code:

 var payment = Payment.Create(GetDefaultApiContext(), new Payment
        {
            intent = "sale",
            payer = new Payer
            {
                payment_method = "paypal"
            },
            transactions = new List<Transaction>
            {
                new Transaction
                {
                    description = "Test",
                    invoice_number = "009",
                    amount = new Amount
                    {
                        currency = "EUR",
                        total = "41.00",
                        details = new Details
                        {
                            tax = "0",
                            shipping = "0",
                            subtotal = "40",
                            handling_fee = "1"
                            
                        }
                    },
                    item_list = new ItemList
                    {
                        items = new List<Item>
                        {
                            new Item
                            {
                                name = "Room 12",
                                currency = "EUR",
                                price = "10",
                                quantity = "4",
                            }
                        }
                    }
                }
            },
            redirect_urls = new RedirectUrls
            {
                return_url = "https://google.de/",
                cancel_url = "https://google.de/"
            }
        });

The payment is also created and a corresponding link is generated. If we now pay with our test account, the money is not debited and nothing more happens, the forwarding also works normally. However, no transaction is reported to PayPal.

It would be very nice if someone could help us with this Problem.

Thank you!

After the redirect back to the return_url you provided, you are expected to present an order review page and then when the user confirms the order you must do a payment Execute API call, which will result in the PayPal transaction. If you do not do the Execute API call, there will be no transaction.

Do not worry about money being debited from the payer account, since payer accounts have funding sources with infinite funds in sandbox.


Note also that the v1/payments SDK you are using is deprecated, you should upgrade to the current v2/checkout/orders Checkout-NET-SDK and use it to create two routes on your server, one for 'Create Transaction' and one for 'Capture Transaction', documented here .

The best approval flow to pair with your two new routes is https://developer.paypal.com/demo/checkout/#/pattern/server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM