Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@RobertWaiteREPAY
Last active November 10, 2020 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertWaiteREPAY/43d2be53154032a90d206dd27dbb74d8 to your computer and use it in GitHub Desktop.
Save RobertWaiteREPAY/43d2be53154032a90d206dd27dbb74d8 to your computer and use it in GitHub Desktop.
PSBlog005
"Create A payment for invoice $ReferenceNbr"
$body = @"
{
`"Type`": {`"value`": `"Payment`"},
`"CustomerID`": {`"value`": `"$CustomerNbr`"},
`"PaymentMethod`": {`"value`": `"$PaymentMethod`"},
`"PaymentAmount`": {`"value`": $UnitPrice},
`"DocumentsToApply`": [{`"ReferenceNbr`": {`"value`": `"$ReferenceNbr`"}}]
}
"@
$HashArguments = @{
Uri = "$AcumaticaEndPoint/entity/default/18.200.001/Payment"
Method = 'PUT'
Headers = $headers
Body = $body
WebSession = $WebSession
}
$response = Invoke-RestMethod @HashArguments
$PaymentAsPSObject = $response | ConvertTo-Json | ConvertFrom-Json
$PaymentEntityID = $PaymentAsPSObject.id
"Capturing CC Payment for Invoice $ReferenceNbr on EntityID $PaymentEntityID"
$body = @"
{
`"entity`":
{
`"id`": `"$PaymentEntityID`"
}
}
"@
$HashArguments = @{
Uri = "$AcumaticaEndPoint/entity/default/18.200.001/Payment/CaptureCreditCardPayment"
Method = 'POST'
Headers = $headers
Body = $body
WebSession = $WebSession
}
$response = Invoke-RestMethod -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment