Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payments API support #154

Open
Secreto31126 opened this issue May 20, 2023 · 0 comments
Open

Payments API support #154

Secreto31126 opened this issue May 20, 2023 · 0 comments
Labels
help wanted Extra attention is needed wontfix This will not be worked on

Comments

@Secreto31126
Copy link
Owner

TL;DR

It won't be supported yet

The main issue

Two weeks ago, WhatsApp announced the Payments API support for Cloud API. However, there's one limitation in order to use it: both the bussiness and the client must reside in Signapore.

The main focus of this library is improving the API documentation and throwing errors before sending the requests, and in most cases that's achieved by manually testing the API before release. Unfortunately, this is not possible with the new features due to the regional limitation.

That's why we have concluded that payments (and address messages) will not be officially supported until a global release (or at least until we are able to test it). We want to deliver high quality code, and without testing it we can't assure it will reach our standars.

So... What should I do if I want to use them?

This decision doesn't mean you need to get a different library to get the job done. whatsapp-api-js was designed with great flexibility in mind to cover this exact type of scenarios, so it's still possible to send payments messages by manually creating the object. As a matter of facts, this new message type is an extension of Interactive, so the next block of code will work:

// The action object was copy pasted from the Payments API documentation
const payment_message = new Interactive(
    {
        // Interactive requires this string to be equal to the type of action, in this case "review_and_pay"
        get _type() {
            return "review_and_pay";
        },
        "name": "review_and_pay",
        "parameters": {
            "reference_id": "reference-id-value",
            "type": "digital-goods",
            "payment_type": "p2m-lite:stripe",
            "payment_configuration": "unique-payment-config-id",
            "currency": "SGD",
            "total_amount": {
                "value": 21000,
                "offset": 100
            },
            "order": {
                "status": "pending",
                "catalog_id": "the-catalog_id",
                "expiration": {
                    "timestamp": "utc_timestamp_in_seconds",
                    "description": "expiration-explanation"
                },
                "items": [{
                    "retailer_id": "1234567",
                    "name": "Product name, for example bread",
                    "amount": {
                        "value": 10000,
                        "offset": 100
                    },
                    "quantity": 5,
                    "sale_amount": {
                        "value": 10000,
                        "offset": 100
                    }
                }],
                "subtotal": {
                    "value": 10000,
                    "offset": 100
                },
                "shipping": {
                    "value": 10000,
                    "offset": 100,
                    "description": "optional_text"
                },
                "discount": {
                    "value": 10000,
                    "offset": 100,
                    "description": "optional_text",
                    "discount_program_name": "optional_text"
                },
                "tax": {
                    "value": 10000,
                    "offset": 100,
                    "description": "optional_text"
                },
            }
        }
    },
    new Body("Hey, you should definitely buy this!")
);

Whatsapp.sendMessage(payment_message).then(console.log);

A similar code can be used to notify the order status (step 4 in the official documentation), and to send Address Messages (also an Interactive extension).

When will the library support it?

There's no ETA for the global release, hence no ETA for an update. There might be a branch with the bare bones of the code, but it won't be merged and published until tested.

I live in Signapore, can I help?

Sure! PR are welcome, so feel free to fork the repo and help the library get the missing features. Remember to follow the CONTRIBUTING.md rules, as this would count as a big update.


That's all to be said. We hope you can understand this decision wasn't taken lightly, and lets hope WhatsApp extends the feature to more countries soon!

(Will take this opportunity to say thanks to everyone who has submited an issue, PR, or starred the repo, I really appreciate it 😄)

@Secreto31126 Secreto31126 added help wanted Extra attention is needed wontfix This will not be worked on labels May 20, 2023
@Secreto31126 Secreto31126 pinned this issue May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant