Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

paypal api: take immediate payment without a shipping address

been pulling my hair out for hours on this one...

i can't find a way to take an immediate payment via the paypal api without specifying a shipping address. i'm selling tickets that are delivered via email, no shipping is required.

there is info out there specifying you have to create a 'web experience profile'. however, one i can't find out how to pass the 'WebProfile()' to the payment and two, it's not what i want to do because the user then has to return the host website to authorise taking the payment adding an unnecessary step to my checkout.

one thing i have found is that if you specify the shipping address, the user can't change it once they get to paypal, they have to return to the host website to change the address. so for the moment, i'm using the postal address of the company but it's not ideal...

i just wanna take a payment in paypal without a shipping address, return to my website and take the payment!

is this even possible?! pretty sure it was/is with payment express?

for a bonus point, if someone can also tell me how to remove the 'You're almost done. You will confirm your payment on test facilitator's Test Store.' message (as i'm taking the payment the moment the user returns to my website) that would be amazin ;)

like image 526
jakewilliamson Avatar asked Mar 09 '15 20:03

jakewilliamson


People also ask

Do you need a shipping address for PayPal?

When you pay for an order, PayPal asks for the shipping address where you want the merchant to send your order. Although your home address is the default, you can add alternative addresses for yourself or for gifts sent to other people.

Why does PayPal ask for shipping address?

Although the vast majority of unconfirmed addresses are not fraudulent, PayPal offers confirmed addresses as an additional layer of fraud protection. Confirmed addresses help guard against stolen credit cards and identity theft and decrease your chances of receiving a chargeback.

Can I have a different billing and shipping address on PayPal?

While Paypal orders can be shipped to an address that is different from the billing address, the address you'd like to use must already be saved in your Paypal account before purchase.

What does the PayPal API allow developers to do?

The PayPal Developer Platform is a global payments platform open to Developers. Our Developer's Tools offer you the ability to build Applications that interact with PayPal. Our goal is to encourage innovation, creativity and greater use of PayPal Services.


1 Answers

Payments with PayPal do not require a shipping address to be completed. I'd recommend taking a look at the PayPal .NET SDK samples, which includes a Payment with PayPal sample that, when run, shows you the flow of creating, authorizing, and executing the payment.

Concerning the Web Experience Profile, when you make the payment you can optionally set an experience_profile_id with the ID of a previously-created profile.

Here's the steps you'll want to follow to get all this working:

Step 1: Create a new web experience profile. The ID returned from this call can be re-used with every PayPal payment, so you should only need to do this once.

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);

Step 2: Create the payment.

// 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);

Step 3: Redirect the buyer to PayPal using the approval_url HATEOAS link included with the created payment.

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

Step 4: Once the buyer approves the payment and is redirected back to your site, execute the payment.

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 });
like image 111
Jason Z Avatar answered Nov 09 '22 22:11

Jason Z