Gr4vy PayPal Integration

Gr4vy PayPal Integration

Direct Mode implementation guide.


Overview

Gr4vy supports PayPal in two ways:

MethodWhen to use
RedirectFull-page redirect to PayPal login — see Gr4vy redirect guide
Direct ModeSmart Payment Buttons on your checkout; Gr4vy orchestrates the PayPal order — this document

Who does what in Direct Mode:

ActorRole
ShopperClicks PayPal, approves in the wallet modal
Browser (PayPal JS SDK)Renders buttons; createOrder / onApprove / onCancel
Merchant backendPOST /transactions, session exchange, completion handshake, OMS
Gr4vyCreates PayPal context, session, completion URL, transaction status
PayPalWallet UI and authorization

Your Radial account team configures the PayPal payment service and communicates required credentials.


How Direct Mode works

Until the shopper clicks the PayPal button, no Gr4vy transaction exists. That avoids abandoned buyer_approval_pending transactions when shoppers pick another payment method.

Integration steps

  1. Page load — Load the PayPal SDK with a bootstrap client-id so the button can render before the first click. See Frontend SDK.
  2. First click (createOrder) — Merchant backend calls POST /transactions, then POST /transactions/{id}/session. Return session_data.orderId from createOrder (Promise.resolve(orderId)). Do not call PayPal Create Order REST or actions.order.create().
  3. Shopper approves — PayPal modal completes; SDK fires onApprove with the Gr4vy transaction id your backend stored from step 2.
  4. Complete payment — Merchant backend performs GET default_completion_url (Gr4vy auth headers), then GET /transactions/{id} for terminal status. Treat 2xx, 204, and common 3xx redirects as successful handshake.
  5. Route the shopper — Thank-you (Pay Now) or back to checkout (Continue) per your flow. See Shopper outcomes.

Terms: Session exchange = POST /transactions/{id}/session. Completion handshake = GET default_completion_url after approve.

Shopper outcomes (Pay Now vs Continue)

PostureTypical SDK / connector signalsWhen to call Gr4vy completeWhere the shopper goes after success
Pay Nowuser_action=PAY_NOW, often commit=trueIn onApprove (after backend complete succeeds)Thank-you / confirmation
Continueuser_action=CONTINUE, commit=falseWhen merchant accepts the order (may be after checkout review)Checkout first, then thank-you
OutcomeGr4vy handling
Success (Pay Now)onApprove → backend complete → route to thank-you. payment_method.redirect_url is the return target for the completion handshake (shopper often stays in the modal).
Success (Continue)After approve, hold completion until checkout is finished; redirect_url may point at checkout or a return handler.
CancelImplement SDK onCancel → return shopper to checkout (cart preserved). Cancel URL is merchant-controlled in SDK callbacks.

For Radial PayPal Processing equivalents, see Appendix.


Backend API reference

Step 1 — POST /transactions

Creates a Gr4vy transaction and PayPal checkout context via the connector.

FieldRequiredRole
amountYesInteger minor units (e.g. 2500 = $25.00)
currencyYesISO 4217
countryYesISO 3166-1 alpha-2
intentYesauthorize or capturemust match PayPal SDK intent
integration_clientYes"web"
payment_method.methodYes"paypal"
payment_method.redirect_urlYesHTTPS return URL for completion handshake
payment_service_idOftenGr4vy UUID for active PayPal payment service
{
  "amount": 2500,
  "currency": "USD",
  "country": "US",
  "intent": "authorize",
  "integration_client": "web",
  "payment_service_id": "<gr4vy-paypal-payment-service-uuid>",
  "payment_method": {
    "method": "paypal",
    "currency": "USD",
    "country": "US",
    "redirect_url": "https://merchant.example/order/confirmation"
  }
}

Typical response (HTTP 201): id, status: buyer_approval_pending, session_token.

Shipping and connection_options.paypal-paypal fields are configured here — see PayPal Direct Mode — Shipping.

Step 2 — POST /transactions/{id}/session

Endpoint: POST {GR4VY_API_BASE}/transactions/{transaction_id}/session?token={session_token}

FieldUse
session_data.orderIdPayPal SDK createOrder return value
session_data.clientIdMust match bootstrap SDK client-id
session_data.intent / currencyPayPal SDK query params
default_completion_urlBackend GET target after buyer approves

After complete — capture, void, sync

OperationEndpoint / action
Capture (delayed ship)POST /transactions/{id}/capture
Capture at createintent: capture on transaction create
Void / cancelGr4vy void or cancel APIs
Stale statusPOST /transactions/{id}/sync, then poll GET /transactions/{id}

See Gr4vy PayPal Direct Mode docs for connector-specific behavior.


Frontend SDK

Both Direct Mode and Radial use paypal.Buttons({ createOrder, onApprove, onCancel, onError }). The wallet opens in a modal; your backend contract differs.

CallbackGr4vy Direct Mode
createOrderBackend → POST /transactions + session; return session_data.orderId
onApproveBackend → GET default_completion_url + GET /transactions/{id}; then route shopper
onCancelRoute to checkout; preserve cart
onErrorLog and surface error

Client ID (state once): Load the SDK early with a bootstrap client-id. After session exchange, session_data.clientId must match that bootstrap id — or reload the SDK with Gr4vy’s value. Mismatch causes PayPal to reject the handoff. Gr4vy ties the id to the connector PayPal app; do not mint a separate browser-side order context.

https://www.paypal.com/sdk/js
  ?client-id={session_data.clientId}
  &currency={session_data.currency}
  &intent={authorize|capture}
  &commit=false
  &components=buttons

Button layout, Venmo, and Pay Later patterns: PayPal Button Options.


When you need PayPal REST

QuestionAnswer
Is Gr4vy GET /transactions/{id} enough after a successful payment?Yes — status, amount, PayPal order id, auth id, payer id, email, shipping.
Need PayPal client secret to finalize Direct Mode?No — completion uses Gr4vy auth + GET default_completion_url + GET /transactions/{id}.
When is client secret required?Merchant backend calling PayPal REST directly — fraud enrichment before complete, void fallback, order PATCH, shipping callbacks.

For field mapping, timing around onApprove, and OAuth details, see PayPal Direct Mode — Post-authorization data.

For pre-Gr4vy fraud (PayPal GET before Gr4vy complete), see Pre-Gr4vy fraud — PayPal timing.


Appendix: Gr4vy Direct Mode vs Radial PayPal Processing

For teams migrating from Radial PayPal Processing (SetExpress / GetExpress / DoExpress / DoAuthorize).

At-a-glance comparison

DimensionGr4vy Direct ModeRadial PayPal Processing
OrchestrationGr4vy RESTRadial XML APIs
Who creates PayPal orderGr4vy connectorRadial via SetExpress
createOrder returnsession_data.orderIdEC-Token only
onApproveBackend complete → thank-you or checkoutRedirect → GetExpress → DoExpress → DoAuthorize
SDK intentauthorize or capture (match Gr4vy)intent=order mandatory
SDK commitcommit=false mandatorycommit=false mandatory
Client IDsession_data.clientId from Gr4vy sessionRadial-provided test/production id
Auth at checkoutGr4vy transaction statusDoAuthorize ResponseCode
Capture / settlementGr4vy capture APIPaymentSettlement + Confirm Funds
VoidGr4vy void / cancelPaymentAuthCancel tender PY

SDK callback comparison

CallbackGr4vy Direct ModeRadial PayPal Processing
createOrderGr4vy POST /transactions + session → orderIdSetExpress → EC-Token
onApproveBackend complete → route shopperactions.redirect(returnUrl) → auth chain
onCancelRoute to checkoutactions.redirect(cancelUrl)

OMS and lifecycle

ConcernGr4vy Direct ModeRadial PayPal Processing
Delayed ship / auth expiryGr4vy capture or re-authConfirm Funds before settlement
Partial / multi-shipGr4vy partial captureMultiple PaymentSettlement debits
RefundGr4vy refund APIPaymentSettlement credit
OMS automationMerchant implements Gr4vy APIsROM automates confirm funds/settlement

Error handling

ScenarioGr4vy Direct ModeRadial PayPal Processing
Buyer cancelsSDK onCancelRedirect to cancel URL
Auth failureNon-terminal Gr4vy statusDoAuthorize failure → PaymentAuthCancel PY
TimeoutRetry completion GET / syncRetry DoAuthorize (~3 max)
Settlement duplicateGr4vy idempotencyNever resubmit after ACK

Migration mapping

Radial stepGr4vy Direct Mode equivalent
SetExpress (EC-Token)POST /transactions + POST …/session
GetExpress + DoExpressGr4vy connector + session exchange
DoAuthorizeApprove + GET default_completion_url + GET /transactions/{id}
Confirm FundsGr4vy status / re-auth before capture
PaymentSettlement debitPOST /transactions/{id}/capture
PaymentSettlement creditGr4vy refund
PaymentAuthCancel PYGr4vy void / cancel

Treat this table as a planning aid, not a drop-in replacement spec.

Return and cancel URLs (Radial reference)

Shopper outcomeGr4vy Direct ModeRadial PayPal Processing
Success (Pay Now)redirect_url + onApprove completeSetExpress return URL + onApprove redirect → DoAuthorize
CancelSDK onCancel → checkoutonCancel → cancel URL
ContinueComplete when order ready; checkout returnDoAuthorize when merchant ready