Page 1 of 1

Add Order Payment Transaction with Rest API

Posted: Mon Nov 10, 2014 9:21 am
by adarshkkumar
Hi,

I have followed the tutorials on creating a payment module and referred the NullPayment Implementation in demo site in order to create a payment module using paypal java rest sdk. We Only use the Rest API so need to add payment and related info through Rest endpoints.
I use add Payment with following structure.
{
"id":"",
"orderId":"6800",
"type":"CREDIT_CARD",
"billingAddress":{},
"amount":"",
"referenceNumber":"",
"gatewayType":"PAY_PAL_GATEWAY"

}

But how will transactions get added to payments added like this? Is it through a workflow or should I manually add the logic for it ? Currently when i try to checkout it gives a Not Enough Payment and fails.

Re: Add Order Payment Transaction with Rest API

Posted: Tue Dec 02, 2014 8:30 pm
by phillipuniverse
You have to specify an amount for the payment. In the example that you gave you left the amount field blank. Broadleaf uses the amount for the payment to determine if the Order has enough payments on the order.

Also, you need to add a PaymentTransaction to that payment that indicates a successful AUTHORIZE or AUTHORIZE_AND_CAPTURE on checkout. You can do this in one go by adding a list of payment transactions for that particular payment. At a minimum, this should look like:

Code: Select all

{
"id":"",
"orderId":"6800",
"type":"CREDIT_CARD",
"billingAddress":{},
"amount":"10.00",
"referenceNumber":"",
"gatewayType":"PAY_PAL_GATEWAY"
"transactions": [{
    "type": "AUTHORIZE_AND_CAPTURE",
    "success": true,
    "currency": "USD"
    "amount":"10.00"
}]
}