JavaScript + Flask + Paypal SDK - Remove shipping address
eldereng
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Dec-26-2019
04:57 PM
Hello,
Is there some form of removing the fields of the shipping address (see figure - red fields)?
RQ={
"intent": "CAPTURE",
'payer': {
"name": {
"given_name": "firstName",
"surname": "lastName",
},
"address": {
"address_line_1": "address",
"country_code": 'BR',
},
'email_address': 'xxxx',
},
"purchase_units": [
{
"amount": {
"currency_code": "BRL",
"value": "35.01"},
}],
# Method 1 = > not Work
"application_context" : {
"shipping_preference": "NO_SHIPPING",
},
# Method 2 = > not Work
"input_fields": {
"no_shipping": 1,
},
# Method 3 = > not Work
"experience":{
"input_fields": {
"no_shipping": 1,
}
},
}
Codes:
<!DOCTYPE html>
<head>
<!-- Add meta tags for mobile and IE -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>
<body>
<!-- Set up a container element for the button -->
<div id="paypal-button-container"></div>
<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=ID_FROM_PayPal¤cy=BRL&intent=capture&disable-card=hiper,jcb,discover"></script>
<script>
paypal.Buttons({
locale: 'pt_BR',
style: {
layout: 'vertical',
color: 'silver',
shape: 'pill',
label: 'pay',
size: "responsive",
tagline : false,
},
createOrder: function(data, actions) {
return fetch('http://127.0.0.1:8040/createorder', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({a: 1, b: 'Textual content'}),
}).then(response => {
return response.json();
}).then((data) => {
return data.orderID;
});
},
onApprove: function(data, actions) {
//...........
},
}).render('#paypal-button-container');
</script>
</body>
.route('/createorder',methods = ['GET', 'POST'])
def createorder():
data={"orderID":""}
try:
request = OrdersCreateRequest()
request.prefer('return=representation')
RQ={
"intent": "CAPTURE",
'payer': {
"name": {
"given_name": "firstName",
"surname": "lastName",
},
"address": {
"address_line_1": "address",
"country_code": 'BR',
},
'email_address': 'xxxxx',
},
"purchase_units": [{
"amount": {
"currency_code": "BRL",
"value": "35.01"},
}],
}
request.request_body(RQ)
response = client.execute(request)
if response.result.status=="CREATED" and response.status_code in [200,201]:
data["orderID"]=response.result.id
return jsonify(data), 200
except: pass
return jsonify(data), 401
Labels:
- Labels:
-
Payments REST APIs
-
Payouts Rest APIs
0 REPLIES 0
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Express Checkout with Bigcommerce in PayPal Payments Standard
- How do I update shipping in the popup when using onShippingAddressChange() in REST APIs
- User is asked for shipping address when creating a credit card order in REST APIs
- Show all billing address fields when hiding shipping address fields in PayPal Payments Standard
- PAYER_ACTION_REQUIRED returned for Capture intent when calling v2 checkout orders in Sandbox Environment