Configure InStore to create only a minimal commercetools Payment resource and delegate its population to your payment processor.
Process delegated payments
- InStore-managed payments (default): the InStore API Server creates and populates the Payment resource, including its transactions, for you.
- Delegated payments (described in this topic): InStore creates a minimal Payment resource with
amountPlanned. It passes the ID to your payment processor. Your payment processor populates the Payment resource, including its transactions. It setspaymentStatus.interfaceCodeto"Success".
Use delegation when you want your payment processor to populate Payment and Transaction Custom Fields to match those used in your other checkout integrations. It also makes the tender flow more resilient to connection errors between the client, the InStore APIs, and the payment processor.
Supported payment processor types
Delegation is available for the following payment processor types:
BankCardGiftCard(Stored Value)
integrationConfiguration.delegatePaymentCreation to true when you create the payment processor. If you omit the field, it defaults to false and existing processors keep the default creation behavior.The field name and its location in the payload differ by processor type. Use the exact form shown for each type below.
Delegated flow
delegatePaymentCreation is true, the payment flow changes as follows:-
InStore creates a minimal Payment resource that contains only the
amountPlannedfield.- For
BankCard, the route iscollect_credit_payment. - For
GiftCard, the route isstoredvaluecard_process.
- For
-
InStore passes the ID of the minimal Payment resource in the payment request to your payment processor:
- For
BankCard, the field ispayload.paymentId. - For
GiftCard, the field ispayload.payment_id.
For details on the request payloads, see the payment extensions reference. - For
-
Your payment processor populates the Payment resource in commercetools, including its transactions for the full amount.
-
Your payment processor sets
paymentStatus.interfaceCodeto the literal string"Success"and adds successful transactions whose amounts total the Payment resourceamountPlanned.centAmount.
Return the response to InStore
payload object. The field name and its location in the response differ by processor type.BankCard response
BankCard, follow the format described in the Credit payment extension topic. InStore expects paymentId inside data:{
"result": "Success",
"data": {
"paymentId": "234672673467236742"
}
}
GiftCard response
GiftCard, follow the format described in the GiftCard payment extension topic. InStore expects payment_id at the top level:{
"result": "Success",
"payment_id": "234672673467236742"
}
Attach the payment to the cart
BankCard and GiftCard delegated flows, InStore only validates that the Payment ID exists. InStore does not automatically link the Payment resource to the cart.
You must attach the Payment resource to the cart using the addPayment update action on one of the following endpoints.POST /{projectKey}/carts/{id}
or
POST /{projectKey}/carts/key={key}