Skip to content

Commit 16c7d8f

Browse files
committed
Add SetTransactionContext function
1 parent 0b04cae commit 16c7d8f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

stc.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package paypal
2+
3+
import (
4+
"context"
5+
"fmt"
6+
)
7+
8+
// SetTransactionContext
9+
// PayPal partners and merchants can Set transaction context to send additional data about a customer to PayPal before the customer transaction is processed.
10+
// PayPal uses this data to complete a pre-transaction risk management evaluation
11+
// Endpoint: PUT <endpoint>/v1/risk/transaction-contexts/<merchant_id>/<tracking_id>
12+
func (c *Client) SetTransactionContext(ctx context.Context, merchantID, orderID string, tcPayload interface{}) error {
13+
14+
if merchantID == "" || orderID == "" {
15+
return fmt.Errorf("paypal: merchantID or orderID is empty")
16+
}
17+
18+
url := fmt.Sprintf("%s%s%s", c.APIBase, "/v1/risk/transaction-contexts/", merchantID+"/"+orderID)
19+
20+
req, err := c.NewRequest(ctx, "PUT", url, tcPayload)
21+
22+
if err != nil {
23+
return err
24+
}
25+
26+
if err = c.SendWithAuth(req, nil); err != nil {
27+
return err
28+
}
29+
30+
return nil
31+
}

0 commit comments

Comments
 (0)