DroneDeploy
Search…
Payments

Payments.charge

Overview

This call allows your app to ask the user for a one time payment. Users must have a paid account to run paid apps. Payments will processed at the end of the month. When you request a payment, the user will see a request.
Parameters
1
const amount = Number;
2
const paymentFor = String;
3
dronedeployApi.Payments.charge(amount, paymentFor);
Copied!

Example Call

1
dronedeployApi.Payments.charge(4.00, 'Testing Payments')
2
.then(
3
function(success){ console.log('paymentId:', success) },
4
function(error){ console.log(error) }
5
)
Copied!
Note: If your app is not published the returned paymentId is fake and is not saved to our database. Additionally, having a paid account is not enforced while in development.
Here is a screenshot of what you would see if your app is not published.

Example Response

Success Response
If the payment is successful you will receive the payment id.
1
...then(function(paymentId){ console.log(paymentId) })
2
// 298348de72987ac
Copied!
Error Responses
If the user clicks cancel on the payment request.
1
.then(
2
function(){},
3
function(error){ console.log(error) },
4
)
5
// Error('User declined payment request.')
Copied!
If the user does not have a paid account.
1
.then(
2
function(){},
3
function(error){ console.log(error) },
4
)
5
// Error('User does not have a paid account.')
Copied!
If the request fails (I.E. the user is offline).
1
.then(
2
function(){},
3
function(error){ console.log(error) },
4
)
5
// Error('Error Submitting Payment')
Copied!

Payment FAQ

How to validate or cancel a payment?

1 - From the account that authored the plugin get your API key here
2 - Run GET against this endpoint with your payment_id, /v1/plugin_payments/<payment_id>
1
curl "https://public-api.dronedeploy.com/v1/plugin_payments/5817d4b9361143b45cbb072b?api_key=f78b0a0d66274fd5a8684c49deb9d83d"
Copied!
Example Response
1
{
2
"user_id": "57c5fc90dd32274105595f92",
3
"description": "Paid for something",
4
"date_creation": 1234567890100,
5
"date_paid": null,
6
"amount": 1000,
7
"plugin_id": "5817d4b6361143b45cbb072a",
8
"id": "5817d4b9361143b45cbb072b"
9
}
Copied!
3 - To cancel a payment run PUT against /v1/plugin_payments/<payment_id> with {"status": "cancelled"} as the body.
1
curl -X PUT -H "Content-Type: application/json" -d '{"status":"cancelled"}' "https://public-api.dronedeploy.com/v1/plugin_payments/589e239dc66a510001bd330b?api_key=65452af2874547428a90d008a8ed75dc"
Copied!
Last modified 2yr ago