Paypal api: immediately pay for shipping without shipping address

pulled my hair for hours on this ...

I can not find a method of immediate payment via paypal api without specifying a delivery address. I sell tickets that are delivered by email, no delivery required.

there is information indicating that you need to create a "web experience profile". however, I can’t find out how to transfer “WebProfile ()” to the payment, and two, this is not what I want to do, because then the user must return the host website to allow the payment to be accepted, adding an unnecessary step to my design .

One thing I discovered is that if you provide a delivery address, the user will not be able to change it, once they get to paypal, they must return to the host website to change the address. so at the moment I'm using the company’s mailing address, but that’s not ideal ...

I just want to pay by PayPal without a shipping address, return to my website and accept the payment!

Is it even possible ?! Pretty sure it was / with express payment?

for a bonus point, if someone can also tell me how to delete "You are almost ready. You will confirm your payment in a test store-tester. message (since I take the payment the moment the user returns to my site) that was would amazin;)

+4
1

PayPal . PayPal.NET SDK, PayPal, , .

-, experience_profile_id .

, , :

1: -. , , PayPal, .

var apiContext = new APIContext(); // APIContext with config info & credentials

// Create the web experience profile
var profile = new WebProfile
{
    name = "My web experience profile",
    presentation = new Presentation
    {
        brand_name = "My brand name",
        locale_code = "US",
        logo_image = "https://www.somesite.com/my_logo.png"
    },
    input_fields = new InputFields
    {
        no_shipping = 1
    }
};

var createdProfile = profile.Create(apiContext);

2: .

// Create the payment
var payment = new Payment
{
    intent = "sale",
    experience_profile_id = createdProfile.id,
    payer = new Payer
    {
        payment_method = "paypal"
    },
    transactions = new List<Transaction>
    {
        new Transaction
        {
            description = "Ticket information.",
            item_list = new ItemList
            {
                items = new List<Item>
                {
                    new Item
                    {
                        name = "Concert ticket",
                        currency = "USD",
                        price = "20.00",
                        quantity = "2",
                        sku = "ticket_sku"
                    }
                }
            },
            amount = new Amount
            {
                currency = "USD",
                total = "45.00",
                details = new Details
                {
                    tax = "5.00",
                    subtotal = "40.00"
                }
            }
        }
    },
    redirect_urls = new RedirectUrls
    {
        return_url = "http://www.somesite.com/order.aspx?return=true",
        cancel_url = "http://www.somesite.com/order.aspx?cancel=true"
    }
};

var createdPayment = payment.Create(apiContext);

3: PayPal, approval_url HATEOAS, .

// Redirect buyer to PayPal to approve the payment...
var approvalUrl = createdPayment.GetApprovalUrl();

4: , .

var payerId = Request.Params["PayerID"];
var paymentId = Request.Params["paymentId"];
var paymentToExecute = new Payment { id = paymentId };
var executedPayment = paymentToExecute.Execute(apiContext, new PaymentExecution { payer_id = payerId });
+12

Source: https://habr.com/ru/post/1546462/


All Articles