Loading...
Loading...
Apply when designing, or implementing a Payment Connector in VTEX IO. Covers PPF implementation in VTEX IO, use of secure proxy, manifest and other PPP routes exposure and clients definitions. Use for any implementation of a Payment Connector hosted in VTEX IO.
npx skill4agent add vtexdocs/ai-skills payment-provider-framework@vtex/payment-providerPaymentProviderPaymentProviderServicenode/index.tspaymentProviderconfiguration.jsoncustomFieldsthis.retry(request)SecureExternalClientsecureProxypayment-provider-protocolpaymentIdpayment-idempotencyundefinedcallbackUrlpayment-async-flowpayment-pci-securitynode@vtex/payment-provider1.xpackage.json@vtex/apidevDependencies6.x6.x@vtex/apinode_modulesyarn.locknodeyarn install -fpaymentProvidermanifest.json"paymentProvider": "1.x"nodeconfiguration.jsonpaymentMethods/manifestPaymentProviderPaymentProviderService/manifest/payments/settlements/refunds/cancellations/inboundroutesclients/manifestconfiguration.jsonimplementsOAuthimplementsSplitusesProviderHeadersNameuseAntifraudusesBankInvoiceEnglishNameusesSecureProxyrequiresDocumentacceptSplitPartialRefundusesAutoSettleOptionsnameserviceUrlthis.retry(request)SecureExternalClientsecureProxy: secureProxyUrlContent-Typeapplication/jsonapplication/x-www-form-urlencodedmasterbillingOptionspaymentProviderconfiguration.jsonpaymentProvidermanifest.jsonpaymentProvider/configuration.jsonnamepaymentMethods"MyConnector"manifest.jsonpaymentProviderconfiguration.json{
"name": "PartnerAcmeCard",
"paymentMethods": [
{ "name": "Visa", "allowsSplit": "onCapture" },
{ "name": "BankInvoice", "allowsSplit": "onAuthorize" }
]
}{
"name": "MyConnector",
"paymentMethods": []
}PaymentProviderServicePaymentProviderPaymentProvider@vtex/payment-providernode/index.tsPaymentProviderServiceimport { PaymentProviderService } from "@vtex/payment-provider";
import { YourPaymentConnector } from "./connector";
export default new PaymentProviderService({
connector: YourPaymentConnector,
});// Ad-hoc router only — no PaymentProviderService / PaymentProvider base
export default someCustomRouterWithoutPPPPackage;this.retry(request)this.retry(request)this.retry// Inside a PaymentProvider subclass method, when the protocol requires retry:
return this.retry(request);// Re-implementing gateway retry with setTimeout/fetch instead of this.retry
await fetch(callbackUrl, { method: "POST", body: JSON.stringify(payload) });usesSecureProxySecureExternalClientsecureProxysecureProxyUrlapplication/jsonapplication/x-www-form-urlencodedusesSecureProxyserviceUrlsecureProxyimport { SecureExternalClient, CardAuthorization } from "@vtex/payment-provider";
import type { InstanceOptions, IOContext, RequestConfig } from "@vtex/api";
export class MyPCICertifiedClient extends SecureExternalClient {
constructor(protected context: IOContext, options?: InstanceOptions) {
super("https://pci-certified.example.com", context, options);
}
public authorize = (cardRequest: CardAuthorization) =>
this.http.post(
"authorize",
{
holder: cardRequest.holderToken,
number: cardRequest.numberToken,
expiration: cardRequest.expiration,
csc: cardRequest.cscToken,
},
{
headers: { Authorization: "Bearer ..." },
secureProxy: cardRequest.secureProxyUrl,
} as RequestConfig
);
}// Direct outbound call with raw card fields and no secureProxy
await http.post("https://acquirer.example/pay", { pan, cvv, expiry });/
├── manifest.json
├── paymentProvider/
│ └── configuration.json
├── node/
│ ├── package.json
│ ├── index.ts # exports PaymentProviderService
│ ├── connector.ts # class extends PaymentProvider
│ └── clients/
│ └── pciClient.ts # extends SecureExternalClient when neededyarn add @vtex/payment-providermanifest.json{
"builders": {
"node": "6.x",
"paymentProvider": "1.x"
}
}PaymentProviderimport { PaymentProvider } from "@vtex/payment-provider";
export class YourPaymentConnector extends PaymentProvider {
// One method per PPP route; return typed responses
}/manifestx-provider-apphandlerheaders{
"memory": 256,
"ttl": 10,
"timeout": 10,
"minReplicas": 2,
"maxReplicas": 3,
"routes": {
"manifest": {
"path": "/_v/api/my-connector/manifest",
"handler": "vtex.payment-gateway@1.x/providerManifest",
"headers": {
"x-provider-app": "$appVendor.$appName@$appVersion"
},
"public": true
}
}
}nameserviceUrlimplementsOAuthimplementsSplitusesProviderHeadersNameuseAntifraudusesBankInvoiceEnglishNameusesSecureProxyrequiresDocumentacceptSplitPartialRefundusesAutoSettleOptionscustomFieldsconfiguration.jsontypetextpasswordappKeyappTokenselectoptionshttps://{account}.myvtex.com/admin/affiliations/connector/Vtex.PaymentGateway.Connectors.PaymentProvider.PaymentProviderConnector_{connector-name}/{connector-name}${vendor}-${appName}-${appMajor}vtex-payment-provider-example-v1vendor.app@0.1.0-betamastermasterpaymentProviderpaymentMethods/manifest@vtex/api@vtex/payment-providernodethis.retry(request)secureProxyContent-Type/manifestx-provider-appPaymentProviderPaymentProviderServicemanifest.jsonpaymentProvider/configuration.jsonhandlerx-provider-app@vtex/payment-providerpayment-provider-protocolthis.retry(request)SecureExternalClientsecureProxy: secureProxyUrlpayment-provider-protocolpayment-idempotencypaymentIdrequestIdpayment-async-flowundefinedcallbackUrlpayment-pci-security