PayPal REST API: how to do an immediate payment and without asking for shipping address

自古美人都是妖i 提交于 2019-12-05 05:41:45

Unfortunately, the REST API is still a long ways behind the Classic API with features it provides. These features you mentioned are things I've seen come up quite a bit, and to my knowledge they are not yet available with the REST services.

I personally have stuck with Classic as they provide everything and I really see no advantage to using REST myself. If you happen to be working with PHP (which I always do) you may be interested in my class library for PayPal. It makes all of the Classic API calls very quick and easy for you, and it's available on Packagist so you can use with Composer easily.

While delving through the REST API I came across this

I believe this means you don't have to go about creating any "Profiles" as such, and can just pass them along with the payment call...

Further explanation as requested :)

Below is an example of passing PayPal experience parameters along with a particular payment call using the Client-side JS method for Express checkout.

        payment: function(data, actions) {
        return actions.payment.create({
            payment: {
                transactions: [
                    {
                        amount: { total: '1.00', currency: 'USD' }
                    }
                ]
            },

            experience: {
                input_fields: {
                    no_shipping: 1
                }
            }
        });
    },

Hope that makes enough sense to you guys! :)

The REST API now supports no-shipping with the Payment Experience APIs.

You need to create a web experience profile and supply no_shipping as an input field. Then use the profile ID when creating the payment.

The profile ID doesn't need to be recreated every time.

jakewilliamson

appreciate that this post hasn't had any activity for a while but...

i hit on the exact same problem and used this post as a start point for my own question:

paypal api: take immediate payment without a shipping address

it's taken a bit of trial and error but i you can create a one off web profile with 'no_shipping' set to 1, store the id that it creates and then pass that in with future payments that don't require a shipping address.

still haven't figured out how to get rid of the 'You're almost done. You will confirm your payment on xxx.' but my payment process is a far better place than it was!

hope this helps someone out there as this no shipping issue is one that a lot of people appear to be hitting with the paypal api...

Stephen Symonds

I tried using the experience section of the API and apart from still not being able to force a locale code have been able to disable shipping and go straight to billing:

payment: {
    transactions: [{
        invoice_number: document.getElementById("ReqTxt").value,
        amount: {
            total:  document.getElementById("InvoiceAmt").innerText,
            currency: document.getElementById("Currency").innerText 
        }
    }]
},
experience: {
    input_fields: {
        no_shipping: 1
    },
    flow_config: {
        landing_page_type:'billing'
    }
}

you can also see this page. It is possible to set the user action in the flow_config section too

For 'Pay Now' instead of 'Continue' on Paypal I use a special param in approval url:

$approvalUrl = $payment->getApprovalLink().'&useraction=commit';

Result:

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=TOKEN&useraction=commit
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!