Advanced payment cycles

On this page, you can explore advanced payment scenarios you might want or need to use, such as understanding the custom fields available and the power to define expiration time to your Intents.

Custom Fields

MoneyHash offers you a way to store any metadata you want when creating the intent. You need to start at the creation of the intent using the Create Intent endpoint:

POST
/api/v1.1/payments/intent/

To send this data, you need to add the following properties to the payload of the intent:

PropertyTypeDescription
amountNumberThe amount to charge in the payment process.
amount_currencyStringThe currency of the amount is represented by a string of alphabetic codes from ISO 4217 Currency codes.
operationStringThe type of the current intent. It can be one of purchase, authorize, or capture.
webhook_urlStringA URL that the MoneyHash server will send a POST request to you when needed.
custom_fieldsObjectObject with key-value pairs of information you wish to save. As metadata, the keys and values will be set by you.
{
    "amount": 50,
    "amount_currency": "USD",
    "operation": "purchase",
    "success_message": "Friendly Success Message",
    "fail_message": "Friendly Fail Message",
    "webhook_url": "https://webhook.site/cd48c9e4-f942-479c-92ae-3be15b8e29cc",
    "custom_fields": {
        "order_number": 11222,
        "customer_notes": "Leave at the back door.",
        "online_order": true
    }
}

The custom fields will be saved as part of the intent, and they will also be sent back to you in the webhook event so you can take advantage of them in your app's context. It will also appear on the intent details page inside the dashboard.

Set expiration time to the intent

MoneyHash allows you to set an expiration time for each intent, blocking the customer from taking action after the set time expires. You need to start at the creation of the intent using the Create Intent endpoint:

POST
/api/v1.1/payments/intent/

Now, you need to add the following properties to the payload of the intent:

PropertyTypeDescription
amountNumberThe amount to charge in the payment process.
amount_currencyStringThe currency of the amount is represented by a string of alphabetic codes from ISO 4217 Currency codes.
operationStringThe type of the current intent. It can be one of purchase, authorize, or capture.
webhook_urlStringA URL that the MoneyHash server will send a POST request to you when needed.
expires_after_secondsNumberThe time amount in seconds to be set for the expiration of the intent.
{
  "amount": 50,
  "amount_currency": "USD",
  "operation": "purchase",
  "customer": "xxxx-xxxx-xxxx-xxxx",
  "expires_after_seconds": 100
}

The example above will make the created intent expire after 100 seconds of its creation.

Custom messages

MoneyHash allows you to customize the message presented to the customer after a successful or failed payment. You need to start at the creation of the intent using the Create Intent endpoint:

POST
/api/v1.1/payments/intent/

Now, you need to add the following properties to the payload of the intent:

PropertyTypeDescription
amountNumberThe amount to charge in the payment process.
amount_currencyStringThe currency of the amount is represented by a string of alphabetic codes from ISO 4217 Currency codes.
operationStringThe type of the current intent. It can be one of purchase, authorize, or capture.
webhook_urlStringA URL that the MoneyHash server will send a POST request to you when needed.
success_messageStringA string with the message for the successful transaction scenario.
fail_messageStringA string with the message for the failed transaction scenario.
{
	"amount": 50,
  "amount_currency": "USD",
  "operation": "purchase",
  "success_message": "Friendly Success Message",
  "fail_message": "Friendly Fail Message",
  "webhook_url": "https://webhook.site/b8954509-f628-4805-a4b4-58a0fb2be958"
}

Custom forms

MoneyHash offers you a way to create a dynamic form to get input from the user before payment. You need to start at the creation of the intent using the Create Intent endpoint:

POST
/api/v1.1/payments/intent/

Now, you need to add the following properties to the payload of the intent:

PropertyTypeDescription
amountNumberThe amount to charge in the payment process.
amount_currencyStringThe currency of the amount is represented by a string of alphabetic codes from ISO 4217 Currency codes.
operationStringThe type of the current intent. It can be one of purchase, authorize, or capture.
webhook_urlStringA URL that the MoneyHash server will send a POST request to you when needed.
custom_form_definitionObjectAn object with the definitions of the custom form you are creating.
custom_form_definition.form_titleStringThe title of the form to be shown to the customer.
custom_form_definition.fieldsArray of objectsAn array with all the fields to be shown.
custom_form_definition.field.nameStringThe name of the field.
custom_form_definition.field.labelStringThe label of the field.
custom_form_definition.field.typeEnumThe type of the input field. Accepts only one of these values: - ChoiceField - IntegerField - CharField.
custom_form_definition.field.requiredBooleanWhether this input field is required or not.
custom_form_definition.field.choicesArray of StringsList of choices to be populated in the choice field. Required only if the field.type === ChoiceField.
{
  "amount": 50,
  "amount_currency": "USD",
  "operation": "purchase",
  "webhook_url": "https://webhook.site/b8954509-f628-4805-a4b4-58a0fb2be958",
  "custom_form_definition": {
    "form_title": "title",
    "fields": [
      {
        "name": "name 1",
        "label": "label",
        "type": "CharField",
        "required": true
      },
      {
        "name": "name 2",
        "label": "label",
        "type": "IntegerField",
        "required": true
      },
      {
        "name": "name 3",
        "label": "label",
        "type": "ChoiceField",
        "choices": [
          "choice1",
          "choice1"
        ],
        "required": true
      }
    ]
  }
}

Close intent

You may need to close a UNPROCESSED intent manually. To do it, you need to request the Close Intent endpoint:

POST
/api/v1.1/payments/intent/{INTENT_ID}/close/

Doing this will change the intent status to CLOSED, and the customer cannot take new actions inside the intent.