-
Notifications
You must be signed in to change notification settings - Fork 85
Payment Methods
Bogdan Petrea edited this page Nov 16, 2016
·
4 revisions
For resource definition check out Resources page.
- List all customer's payment methods
- Retrieve a customer's payment method
- Create a payment method
- Transition a payment method
GET /customers/<customer_id>/payment_methods/
Available filters: ---
[
{
"url": "http://127.0.0.1:8000/customers/1/payment_methods/1/",
"transactions": null,
"customer": "http://127.0.0.1:8000/customers/1/",
"payment_processor": "http://127.0.0.1:8000/payment_processors/Manual/",
"added_at": "2016-11-09T12:36:41.008129Z",
"verified_at": null,
"state": "uninitialized"
},
{
"url": "http://127.0.0.1:8000/customers/1/payment_methods/2/",
"transactions": "http://127.0.0.1:8000/customers/1/payment_methods/2/transactions/",
"customer": "http://127.0.0.1:8000/customers/1/",
"payment_processor": "http://127.0.0.1:8000/payment_processors/PayPal/",
"added_at": "2016-12-17T15:11:03.008129Z",
"verified_at": "2016-12-17T15:11:03.008129Z",
"state": "enabled"
}
]
GET /customers/<customer_id>/payment_methods/<payment_method_id>/
{
"url": "http://127.0.0.1:8000/customers/1/payment_methods/2/",
"transactions": "http://127.0.0.1:8000/customers/1/payment_methods/2/transactions/",
"customer": "http://127.0.0.1:8000/customers/1/",
"payment_processor": "http://127.0.0.1:8000/payment_processors/PayPal/",
"added_at": "2016-12-17T15:11:03.008129Z",
"verified_at": "2016-12-17T15:11:03.008129Z",
"state": "enabled"
}
POST /customers/<customer_id>/payment_methods/
Payload:
{
"payment_processor": "http://127.0.0.1:8000/payment_processors/PayPal/",
"state": "unverified",
"additional_data": {
"reference": "xoiy6c1b"
}
}
Response:
HTTP 201 Created
{
"url": "http://127.0.0.1:8000/customers/1/payment_methods/2/",
"transactions": "http://127.0.0.1:8000/customers/1/payment_methods/2/transactions/",
"customer": "http://127.0.0.1:8000/customers/1/",
"payment_processor": "http://127.0.0.1:8000/payment_processors/PayPal/",
"added_at": "2016-12-17T15:11:03.008129Z",
"verified_at": null,
"state": "unverified"
}
The additional_data field can be only specified for payments with uninitialized or unverified states, when transitioning to a unverified or a enabled state. The additional_data field will be passed to the Payment Processor's initialize_unverified or initialize_enabled methods.
PATCH /customers/<customer_id>/payment_methods/<payment_method_id>/
Payload:
{
"state": "enabled",
"additional_data": {
"reference": "xoiy6c1b"
}
}
Response:
HTTP 200 OK
{
"url": "http://127.0.0.1:8000/customers/1/payment_methods/2/",
"transactions": "http://127.0.0.1:8000/customers/1/payment_methods/2/transactions/",
"customer": "http://127.0.0.1:8000/customers/1/",
"payment_processor": "http://127.0.0.1:8000/payment_processors/PayPal/",
"added_at": "2016-12-17T15:11:03.008129Z",
"verified_at": null,
"state": "enabled"
}
The additional_data field can be only specified for payments with uninitialized or unverified states, when transitioning to a unverified or a enabled state. The additional_data field will be passed to the Payment Processor's initialize_unverified or initialize_enabled methods.