My Service Definition is not working for connection to Stripe

Hi, This is probably a easy question for one in the know. My service returns a

“message”: “Could not find a service for charges”,
“code”: 404,
“trace”: [
“0 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(205): DreamFactory\Core\Models\Service::DreamFactory\Core\Models\{closure}()”,

Now my service is called Stripe, but the api within Stripe is called charges. So is it failing to find the Stripe service or mine within Dreamfactory? Here is the service definition so far.

{
“resourcePath”: “/charges”,
“produces”: [
“application/json”,
“application/xml”
],
“consumes”: [
“application/json”,
“application/xml”
],
“apis”: [
{
“path”: “/charges”,
“description”: “Make a Charge”,
“operations”: [
{
“nickname”: “Create A Charge”,
“method”: “POST”,
“summary”: “Create A Charge”,
“notes”: “Create A Charge”,
“event_name”: “Create A Charge”,
“parameters”: [
{
“name”: “description”,
“description”: “Description”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “source”,
“description”: “Source”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “currency”,
“description”: “Currency”,
“type”: “string”,
“paramType”: “body”,
“required”: true
},
{
“name”: “amount”,
“description”: “Amount in cents”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”,
“required”: true
}
]
}
]
}
],
“models”: {},
“authorizations”: {}
}

Also is it right that once a service definition has been saved for the first time after using the Editor tab, the only way to edit it is in JSON. In my instance all the parameters to be sent in the body vanish from the Editor when you expand the API, there is no edit function, not even an add button to add more parameters.

Thanks in advance

Hi @charliefinale,

I new to, but i think your “resourcePath” must be “/stripe” and in apis your path must be relative to the service, so change “path”: “/charges” to “path”: “/stripe/charges”.

Thank you I believe you are right on this…Anyway I now have an error 500 code.

“error”: {
“context”: null,
“message”: “The HTTP status code “6” is not valid.”,
“code”: 500

Any clues on that?

sorry, no :sweat_smile:

But, can u post here you script, service definition and request url? maybe we can figure out or at least try to reproduce the problem.

Thanks, Stripe is a good credit card processor and I am sure it would be of great help to the community.

First I took the above advice and named the service stripe

Then I used the Stripe URL. And the I added a Basic Auth parameter (note I did not user a VERB here)

Then

Then I did this…note how one can no longer edit params. …one has to go to the JSON.

Stripe give several code examples with test keys here https://stripe.com/docs/api/curl#create_charge

And finally here is the jason that is supposed to do what the stripe docs say. Note the Rotten Tomatos example in the DF blogs uses query not body I but I tried both to no avail. The “source” is a code that is also found in its test form on the Stripe link above but it is effectively a customer number.

{
“resourcePath”: “/stripe”,
“produces”: [
“application/json”
],
“consumes”: [
“application/json”
],
“apis”: [
{
“path”: “/stripe/charges”,
“description”: “Make a Charge”,
“operations”: [
{
“nickname”: “Create A Charge”,
“method”: “POST”,
“summary”: “Create A Charge”,
“notes”: “Create A Charge”,
“event_name”: “Create A Charge”,
“parameters”: [
{
“name”: “description”,
“description”: “Description”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “source”,
“description”: “Source”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “currency”,
“description”: “Currency”,
“type”: “string”,
“paramType”: “body”,
“required”: true
},
{
“name”: “amount”,
“description”: “Amount in cents”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”,
“required”: true
}
]
}
]
}
],
“models”: {},
“authorizations”: {}
}

1 Like

OK I have pretty much got Stripe up and running and when I get a moment I will describe exactly how to do it to other community users who want to use stripe (a credit card processing system).

hi charliefinale
could you please describe us how you make your stripe web service?
thanks

Sorry to be so slow to reply but here is the json file you need to add to the service definition. However there was a nasty bug in v 2.0.2 at least (hopefully fixed now) where basic authentication failed if you put it in the headers. To get round that you need to put it in the base url not the header of the service definition config like this where this key should be replaced with the key issued byStripe.

https://sk_live_1n3a6HxxMF5R7Rmyxx:@api.stripe.com/v1/

And the json…just copy and paste it into the json editor. And then it will appear nicely in the API docs. Make sure you name your service stripe so it tallies with “resourcePath”: “/stripe”,

Here is the json…

{
“resourcePath”: “/stripe”,
“produces”: [
“application/json”
],
“consumes”: [
“application/json”
],
“apis”: [
{
“path”: “/stripe/charges”,
“operations”: [
{
“nickname”: “createCharge”,
“method”: “POST”,
“parameters”: [
{
“name”: “currency”,
“type”: “string”,
“paramType”: “query”,
“required”: true
},
{
“name”: “amount”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “query”,
“required”: true
},
{
“name”: “source”,
“type”: “string”,
“paramType”: “query”
},
{
“name”: “customer”,
“type”: “string”,
“paramType”: “query”
}
]
},
{
“nickname”: “listAllCharges”,
“method”: “GET”,
“parameters”: []
}
]
},
{
“path”: “/stripe/tokens”,
“operations”: [
{
“nickname”: “createCardToken”,
“method”: “POST”,
“parameters”: [
{
“name”: “source”,
“type”: “string”,
“paramType”: “query”
},
{
“name”: “card”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “customer”,
“type”: “string”,
“paramType”: “body”
}
]
}
]
},
{
“path”: “/stripe/refunds”,
“operations”: [
{
“nickname”: “listRefunds”,
“method”: “GET”,
“parameters”: [
{
“name”: “charge”,
“description”: “Only return refunds for the charge specified by this charge ID.”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “ending_before”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “limit”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “starting_after”,
“type”: “string”,
“paramType”: “body”
}
]
}
]
},
{
“path”: “/stripe/refunds/{REFUND_ID}”,
“operations”: [
{
“nickname”: “retrieveRefund”,
“method”: “GET”,
“parameters”: [
{
“name”: “REFUND_ID”,
“type”: “string”,
“required”: true
}
]
}
]
},
{
“path”: “/stripe/charges/{CHARGE_ID}/refunds”,
“operations”: [
{
“nickname”: “createRefund”,
“method”: “POST”,
“parameters”: [
{
“name”: “CHARGE_ID”,
“type”: “string”,
“paramType”: “path”,
“required”: true,
“description”: “The identifier of the charge to refund.”
},
{
“name”: “amount”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “metadata”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “reason”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “refund_application_fee”,
“type”: “boolean”,
“paramType”: “body”
},
{
“name”: “reverse_transfer”,
“type”: “boolean”,
“paramType”: “body”
}
]
}
]
},
{
“path”: “/stripe/events”,
“operations”: [
{
“nickname”: “listAllEvents”,
“method”: “GET”,
“summary”: “List events, going back up to 30 days.”,
“parameters”: [
{
“name”: “created”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “ending_before”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “limit”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “starting_after”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “type”,
“type”: “string”,
“paramType”: “body”
}
]
}
]
},
{
“path”: “/stripe/events/{EVENT_ID}”,
“operations”: [
{
“nickname”: “retrieveEvent”,
“method”: “GET”,
“summary”: “Retrieves the details of an event.”,
“parameters”: [
{
“name”: “EVENT_ID”,
“required”: true,
“type”: “string”,
“paramType”: “path”
}
]
}
]
},
{
“path”: “/stripe/disputes”,
“operations”: [
{
“nickname”: “retrieveDisputes”,
“method”: “GET”,
“summary”: “Returns a list of your disputes.”,
“parameters”: [
{
“name”: “created”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “ending_before”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “limit”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “starting_after”,
“type”: “string”,
“paramType”: “body”
}
]
}
]
},
{
“path”: “/stripe/disputes/{DISPUTE_ID}/close”,
“operations”: [
{
“nickname”: “closeDispute”,
“method”: “POST”,
“summary”: “Closing the dispute for a charge indicates that you do not have any evidence to submit.”,
“parameters”: [
{
“name”: “DISPUTE_ID”,
“type”: “string”,
“paramType”: “path”,
“required”: true
}
]
}
]
},
{
“path”: “/stripe/disputes/{DISPUTE_ID}”,
“operations”: [
{
“nickname”: “updateDispute”,
“method”: “POST”,
“parameters”: [
{
“name”: “DISPUTE_ID”,
“required”: true,
“type”: “string”,
“paramType”: “path”
},
{
“name”: “evidence”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “metadata”,
“type”: “string”,
“paramType”: “body”
}
]
},
{
“nickname”: “retrieveDispute”,
“method”: “GET”,
“summary”: “Retrieves the dispute with the given ID.”,
“parameters”: [
{
“name”: “DISPUTE_ID”,
“required”: true,
“type”: “string”,
“paramType”: “path”
}
]
}
]
},
{
“path”: “/stripe/balance/history/{TRANSACTION_ID}”,
“operations”: [
{
“nickname”: “retrieveBalance”,
“method”: “GET”,
“parameters”: [
{
“name”: “TRANSACTION_ID”,
“type”: “string”,
“paramType”: “path”
}
],
“summary”: “Retrieves the balance transaction with the given ID.”
}
]
},
{
“path”: “/stripe/balance/history”,
“operations”: [
{
“nickname”: “listAllBalanceHistory”,
“method”: “GET”,
“parameters”: [
{
“name”: “available_on”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “created”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “currency”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “ending_before”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “limit”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “starting_after”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “transfer”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “source”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “type”,
“type”: “string”,
“paramType”: “body”
}
],
“summary”: “Returns a list of transactions that have contributed to the Stripe account balance.”
}
],
“description”: “”
},
{
“path”: “/stripe/balance”,
“operations”: [
{
“nickname”: “retrieveBalance”,
“method”: “GET”,
“summary”: “Retrieves the current account balance, based on the authentication that was used to make the request.”
}
]
},
{
“path”: “/stripe/customers/{CUSTOMER_ID}”,
“operations”: [
{
“nickname”: “retrieveCustomer”,
“method”: “GET”,
“summary”: “Retrieves the details of an existing customer.”,
“parameters”: [
{
“name”: “CUSTOMER_ID”,
“type”: “string”,
“paramType”: “path”
}
]
},
{
“nickname”: “updateCustomer”,
“method”: “POST”,
“summary”: “Updates the specified customer by setting the values of the parameters passed.”,
“parameters”: [
{
“name”: “CUSTOMER_ID”,
“type”: “string”,
“paramType”: “path”
},
{
“name”: “account_balance”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “coupon”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “default_source”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “description”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “email”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “metadata”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “shipping”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “source”,
“type”: “string”,
“paramType”: “body”
}
]
},
{
“nickname”: “deleteCustomer”,
“method”: “DELETE”,
“summary”: “Permanently deletes a customer. It cannot be undone.”,
“parameters”: [
{
“name”: “CUSTOMER_ID”,
“type”: “string”,
“paramType”: “path”
}
]
}
]
},
{
“path”: “/stripe/charges/{CHARGE_ID}/capture”,
“description”: “”,
“operations”: [
{
“nickname”: “captureCharge”,
“method”: “POST”,
“summary”: “Capture the payment of an existing, uncaptured, charge.”,
“parameters”: [
{
“name”: “statement_descriptor”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “receipt_email”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “amount”,
“description”: “The amount to capture, which must be less than or equal to the original amount.”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “CHARGE_ID”,
“type”: “string”,
“paramType”: “path”,
“required”: true,
“description”: “e.g. ch_17RB2VGgsatq5Hxy9cECC5PO”
}
]
}
]
},
{
“path”: “/stripe/charges/{CHARGE_ID}”,
“description”: “”,
“operations”: [
{
“nickname”: “retrieveCharge”,
“method”: “GET”,
“summary”: “Retrieves the details of a charge that has previously been created.”,
“parameters”: [
{
“name”: “CHARGE_ID”,
“type”: “string”,
“paramType”: “path”
}
]
},
{
“nickname”: “updateCharge”,
“method”: “POST”,
“summary”: “Updates the specified charge by setting the values of the parameters passed.”,
“parameters”: [
{
“name”: “CHARGE_ID”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “path”,
“required”: true
},
{
“name”: “shipping”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “description”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “fraud_details”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “metadata”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “receipt_email”,
“type”: “string”,
“paramType”: “body”
}
]
}
]
},
{
“path”: “/stripe/customers”,
“description”: “”,
“operations”: [
{
“nickname”: “retrieveAllCustomers”,
“method”: “GET”,
“summary”: “Returns a list of your customers.”,
“parameters”: [
{
“name”: “ending_before”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “limit”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “starting_after”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “created”,
“type”: “string”,
“paramType”: “body”
}
]
},
{
“nickname”: “createCustomer”,
“method”: “POST”,
“parameters”: [
{
“name”: “account_balance”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “coupon”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “email”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “metadata”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “plan”,
“type”: “string”,
“paramType”: “body”
},
{
“name”: “quantity”,
“type”: “integer”,
“format”: “int32”,
“paramType”: “body”
},
{
“name”: “shipping”,
“allowMultiple”: false,
“paramType”: “body”,
“type”: “shipping”
},
{
“name”: “tax_percent”,
“type”: “number”,
“paramType”: “body”
},
{
“name”: “trial_end”,
“type”: “string”,
“format”: “date-time”,
“paramType”: “body”
},
{
“name”: “source”,
“type”: “source”,
“paramType”: “body”
},
{
“name”: “description”,
“type”: “string”,
“paramType”: “body”
}
],
“summary”: “Creates a new customer object.”
}
]
}
],
“models”: {
“address”: {
“id”: “address”,
“subTypes”: [],
“properties”: {
“city”: {
“type”: “string”,
“description”: “Address line 2 (Apartment/Suite/Unit/Building)”
},
“country”: {
“type”: “string”,
“description”: “2-letter country code”
},
“line1”: {
“type”: “string”,
“description”: “Address line 1 (Street address/PO Box/Company name)”
},
“line2”: {
“type”: “string”,
“description”: “Address line 2 (Apartment/Suite/Unit/Building)”
},
“postal_code”: {
“type”: “string”,
“description”: “Zip/Postal Code”
},
“state”: {
“type”: “string”,
“description”: “State/Province/County”
}
}
},
“shipping”: {
“id”: “shipping”,
“properties”: {
“name”: {
“type”: “string”,
“description”: “Customer name.”
},
“phone”: {
“type”: “string”,
“description”: “Customer phone (including extension).”
},
“address”: {
“type”: “address”
}
},
“discriminator”: “name”,
“subTypes”: []
},
“source”: {
“id”: “source”,
“properties”: {
“object”: {
“type”: “string”,
“description”: “The type of payment source. Should be ‘card’.”
},
“exp_month”: {
“type”: “integer”,
“description”: “Two digit number representing the card’s expiration month.”,
“format”: “int32”
},
“exp_year”: {
“type”: “integer”,
“description”: “Two or four digit number representing the card’s expiration year.”,
“format”: “int32”
},
“number”: {
“type”: “string”,
“description”: “The card number, as a string without any separators.”
},
“address_city”: {
“type”: “string”,
“description”: “”
},
“address_country”: {
“type”: “string”,
“description”: “”
},
“address_line1”: {
“type”: “string”,
“description”: “”
},
“address_line2”: {
“type”: “string”,
“description”: “”
},
“address_zip”: {
“type”: “string”,
“description”: “”
},
“currency”: {
“type”: “string”,
“description”: “”
},
“cvc”: {
“type”: “string”,
“description”: “”
},
“default_for_currency”: {
“type”: “boolean”,
“description”: “”
},
“metadata”: {
“type”: “string”,
“description”: “”
},
“name”: {
“type”: “string”,
“description”: “Cardholder’s full name.”
}
},
“subTypes”: []
},
“card”: {
“id”: “card”,
“subTypes”: [],
“properties”: {
“exp_month”: {
“type”: “integer”,
“description”: “Two digit number representing the card’s expiration month.”,
“format”: “int32”
},
“exp_year”: {
“type”: “integer”,
“description”: “Two digit number representing the card’s expiration year.”,
“format”: “int32”
},
“address_city”: {
“type”: “string”,
“description”: “”
},
“address_country”: {
“type”: “string”,
“description”: “”
},
“address_line1”: {
“type”: “string”,
“description”: “”
},
“address_line2”: {
“type”: “string”,
“description”: “”
},
“address_state”: {
“type”: “string”,
“description”: “”
},
“address_zip”: {
“type”: “string”,
“description”: “”
},
“currency”: {
“type”: “string”,
“description”: “”
},
“cvc”: {
“type”: “string”,
“description”: “”
},
“name”: {
“type”: “string”,
“description”: “”
},
“number”: {
“type”: “string”,
“description”: “Card number as string with no seperators.”
}
}
}
},
“authorizations”: {}
}

1 Like