问题
I have a shopping cart that holds an array or my objects. I have all my custom user details serialized with a form and jQuery. I would like to insert the user data I got from my user details form (maybe I use payer or payer_info? Object. Also, I would like to insert my items to the PayPal
CreateOrder: actions.order.create({
I am guessing I do it like this?
"item_list": {
"items": [
{
"name": "hat",
"description": "Brown color hat",
"quantity": "5",
"price": "3",
"tax": "0.01",
"sku": "1",
"currency": "USD"
},
{
"name": "handbag",
"description": "Black color hand bag",
"quantity": "1",
OR maybe in
"data": {
and I can have my own custom objects for the PayPal order class. Could anyone give me an example or more input on how I will do this? In the developer.paypal.com/docs I have been reading pretty much all the different project SDKs for JavaScript / PHP I would like to use my JavasSript to insert the information
This is what I have
$fname = $_POST['txtFirstname'];
$lname = $_POST['txtLastname'];
$email = $_POST['txtEmail'];
var totalPrice = <?php echo $newTotal; ?>
paypal.Buttons({
createOrder: function(data, actions) {
// setup transaction
return actions.order.create({
payer: {
name:
},
purchase_units: [{
amount: {
value: totalPrice
}
}]
});
},
回答1:
It could be done like this:
actions.order.create({
//prefer: 'return=representation',
application_context: {
//Accept URL
//return_url: successOrderUrl,
//Cancel URL
//cancel_url: cancelOrderUrl,
brand_name: "Company Name",
user_action: "PAY_NOW"
},
purchase_units: [{
amount: {
currency_code: 'EUR',
value: net_total,
breakdown: {
item_total: {
currency_code: 'EUR',
value : sub_total
},
tax_total: {
currency_code: 'EUR',
value: vat_amt
}
}
}
}],
payer: {
name: {
given_name: given_name,
surname: surname
},
email_address: email_address
}
});
来源:https://stackoverflow.com/questions/54820720/paypal-shopping-cart-custom-create-order-objects-and-user-details