WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 2eed389

Browse files
authored
Add new PayPal Complete Payments payment gateway & payment methods (#3150)
This PR adds a new PayPal Complete Payments Zuora payment gateway (PayPalCP) and two distinct payment methods which use this gateway: 1. The first step in the rollout of the PayPal/Zuora migration will be to use the new PayPal Complete Payments gateway with the existing SDK and API, passing a BAID (just like with PayPal Express). This is the first new payment method. 2. Then we'll gradually migrate to passing a vault payment token to the gateway, with the token generated by using the new SDK and REST API. In this case the payment gateway used is the same, but slightly different parameters are passed. This is the second new payment method. Initially 2 won't be used, but it makes the migration path clear to add them both now. This PR in and of itself doesn't change anything - nothing will use the new payment methods (and therefore the new gateway) until changes in support-frontend are made.
1 parent c895c77 commit 2eed389

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

modules/zuora/src/orders/paymentMethods.ts

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,27 @@ type PayPal = {
2323
email: string;
2424
};
2525

26+
type PayPalCompletePaymentsWithBAID = {
27+
type: 'PayPalCP';
28+
BAID: string;
29+
email: string;
30+
};
31+
32+
type PayPalCompletePaymentsWithPaymentToken = {
33+
type: 'PayPalCP';
34+
tokens: {
35+
gatewayType: 'PayPalCP';
36+
tokenId: string;
37+
};
38+
email: string;
39+
};
40+
2641
export type PaymentMethod =
2742
| CreditCardReferenceTransaction
2843
| DirectDebit
29-
| PayPal;
44+
| PayPal
45+
| PayPalCompletePaymentsWithPaymentToken
46+
| PayPalCompletePaymentsWithBAID;
3047

3148
//Gateway names need to match to those set in Zuora
3249
//See: https://apisandbox.zuora.com/apps/NewGatewaySetting.do?method=list
@@ -37,15 +54,20 @@ type StripePaymentGateway =
3754

3855
type PayPalPaymentGateway = 'PayPal Express';
3956

57+
type PayPalCompletePaymentsPaymentGateway = 'PayPal Complete Payments';
58+
4059
type GoCardlessPaymentGateway =
4160
| 'GoCardless'
4261
| 'GoCardless - Observer - Tortoise Media';
4362

63+
type PaymentGatewayMap = {
64+
CreditCardReferenceTransaction: StripePaymentGateway;
65+
Bacs: GoCardlessPaymentGateway;
66+
PayPalNativeEC: PayPalPaymentGateway;
67+
PayPalCP: PayPalCompletePaymentsPaymentGateway;
68+
};
69+
4470
export type PaymentGateway<T extends PaymentMethod> =
45-
T extends CreditCardReferenceTransaction
46-
? StripePaymentGateway
47-
: T extends DirectDebit
48-
? GoCardlessPaymentGateway
49-
: T extends PayPal
50-
? PayPalPaymentGateway
51-
: never;
71+
T['type'] extends keyof PaymentGatewayMap
72+
? PaymentGatewayMap[T['type']]
73+
: never;

0 commit comments

Comments
 (0)