Online Payment
The following documentation describes how to implement online payment via API using the PSP provided by Resamania on behalf of the club.
Resamania currently allows the use of four different PSPs:
- Payline
- Stripe
- XplorPay / Snap
- GlobalPayment
Macro Process and Prerequisites
The process for using promo codes follows these steps:
- Create a sale (see the dedicated documentation)
- Create a payable object
- Redirect the user to the payment form
- Handle success or failure
- Retrieve the payment status
Create a Payable Object
POST {clientToken}/payable_objects
PayableObjects are payment requests. By specifying which entities (sale) and what amount you want to collect through an online payment, you receive in return a representation of the payableObject that allows you to redirect the user to the online payment form.
You must specify validUrl and cancelUrl: - validUrl is the URL to which the user is redirected in case of success or error - cancelUrl is the URL to which the user is redirected if they cancel the transaction
Warning
To know whether the payment was accepted or not, you must make sure to retrieve the payment status.
Note
You may request only part of the sale amount for online payment. For example, if the member wants to pay the remaining amount at the club.
{
"contactId":"/demoapi/contacts/2972926",
"amount":1500,
"currency":"EUR",
"clubId":"/demoapi/clubs/1398",
"clubCode":"CFF",
"checkout":"/demoapi/checkouts/1361",
"payableObjects":{
"sales":[
"/demoapi/sales/3558464"
]
},
"useAvailableAmount":false,
"validUrl":"YOUR_COMEBACK_URL",
"cancelUrl":"THE_CANCEL_URL"
}<OpenApiOperationToggle hide domain='accounting' operationId='postPayableObjectCollection'/>
Redirect the User
The redirection process depends on the PSP used.
In the Case of Payline
Redirection is straightforward: simply use the redirectURL from the PayableObject received in the response.
In the Case of Stripe
The Stripe case is a bit special because we use the elements provided by Stripe.
A demo GitHub repository details how to implement this:
https://github.com/stadline/resamania2-partners-examples/tree/master/stripe/react
Handle Success or Failure
If the user cancels their transaction, they are redirected to your cancelUrl.
If the transaction is validated or fails, they are redirected to your validUrl.
It is then up to you to retrieve the payment status (see below).
Warning
No information is sent back to these pages (no reference, no IDs) to help identify the user or their order. You must include these parameters yourself in yourvalidUrlandcancelUrl.
If you used the same URL for success and failure, follow the next section to retrieve the payment status and display the appropriate information to your user.
Retrieve the Payment Status
Use the endpoint PUT /{clientToken}/payable_objects/{id}/check to retrieve the payment status.
This endpoint checks whether Resamania already knows the status of the payment, and if not, it directly queries the PSP.
In return, you receive the updated PayableObject.
Use its state property to determine its status.
You may also use the logs property to get additional details.
State Description
created Just created, not yet used pending Waiting for information from the PSP requested Payment requested and pending canceled Payment request canceled validated Payment received refused Payment refused