问题
I'm using paypal's REST API for digital transaction on my website. I have it all setup and working and have been able to successfully accept payments from a few users and give them their digital product. However, as of yet PayPal sees the transactions as if they were for physical items. I didn't find anything in the REST documentation regarding marking a transaction as digital. An example of one of my requests for the payment looks like this:
{
"intent": "sale",
"redirect_urls": {
"return_url": "http:\/\/www.googulator.com\/goPro?finishPurchase=true&googleid=123456789",
"cancel_url": "http:\/\/www.googulator.com\/goPro"
},
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "5.00",
"currency": "USD"
},
"description": "PWYW Lifetime Googulator Pro",
"item_list": {
"items": [
{
"quantity": "1",
"name": "Lifetime Googulator Pro",
"price": "5.00",
"currency": "USD"
}
]
}
}
]
}
So my question is, are digital transactions properly supported in the REST API, or do I have to resort to using PayPal's classic APIs?
回答1:
Digital Transactions are not properly or FULLY supported in REST API. please continue to use the PayPal's CLASSIC API's . Stay tuned.
回答2:
You can at least disable shipping by creating an Experience Profile, https://developer.paypal.com/docs/api/payment-experience/
I used an application called Postman to send a POST request to PayPal on https://api.sandbox.paypal.com/v1/payment-experience/web-profiles
With this JSON data:
{
"name": "AppName",
"presentation": {
"brand_name": "AppName Paypal",
"locale_code": "US"
},
"input_fields": {
"no_shipping": 1,
"address_override": 1
},
"flow_config": {
"landing_page_type": "login"
}
}
Please note that I used no_shipping 1, which disables shipping. I also sent the Authorization Bearer token with this POST request.
If the request is successful, then you'll get the id of the newly created experience profile. The id is used when creating an express checkout payment.
"experience_profile_id":"experience_profile_id",
回答3:
I know it's too late but I'm answering in case someone else finds this question.
This is how you to using the C# SDK.
Create a profile:
string createProfile(APIContext apiContext) {
var profile = new WebProfile()
{
name = Guid.NewGuid().ToString(),
input_fields = new InputFields()
{
no_shipping = 1
},
temporary = true
};
return profile.Create(apiContext).id;
}
Then you set the ID returned in this function in your payment:
var profileCreated = createProfile(apiContext);
Payment paymentParms = new Payment {
intent = "sale",
payer = new Payer
{
payment_method = "paypal"
},
redirect_urls = new RedirectUrls
{
return_url = WebConfig.WebSite.BaseUrl + "Paypal/Success",
cancel_url = WebConfig.WebSite.BaseUrl + "Paypal/Cancel",
},
experience_profile_id = profileCreated
};
来源:https://stackoverflow.com/questions/19495839/selling-digital-goods-via-rest-api