Skip to content

Commit

Permalink
fix(types): add types for payment_source with order creation (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjopa authored Jul 19, 2023
1 parent 1ea50d2 commit f27b895
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions types/apis/orders.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ export type OrderApplicationContext = {
stored_payment_source?: Record<string, unknown>;
};

export type OrderPaymentSource = {
// support any key until all the payment_source options are typed
[key: string]: unknown;
paypal?: {
experience_context?: {
user_action?: "CONTINUE" | "PAY_NOW";
return_url?: string;
cancel_url?: string;
};
};
};

export type LinkDescription = {
href: string;
rel: string;
Expand All @@ -233,6 +245,7 @@ export type CreateOrderRequestBody = {
purchase_units: PurchaseUnit[];
payer?: Payer;
application_context?: OrderApplicationContext;
payment_source?: OrderPaymentSource;
};

export type UpdateOrderOperation =
Expand Down
21 changes: 21 additions & 0 deletions types/tests/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,27 @@ createOrder({
],
});

// paypal payment_source
createOrder({
intent: "CAPTURE",
purchase_units: [
{
amount: {
value: "88.44",
},
},
],
payment_source: {
paypal: {
experience_context: {
user_action: "CONTINUE",
return_url: "https://www.example.com/capture-checkout",
cancel_url: "https://www.example.com/cancel-checkout",
},
},
},
});

updateOrder({
orderID: "42P22220TW111111R",
requestBody: [
Expand Down

0 comments on commit f27b895

Please sign in to comment.