Payment Methods

Manage your customer's payment methods

Add a customer's payment method

addPaymentMethod.gql
mutation {
    addPaymentMethod(
        customer: "TWVyY2hhbnRDdXN0b21lci05ODFmYzVjMy1jNjYwLTQyMzAtYTgzNi0xM2EyOWZlMjRiOWY=",
        p2pPaymentMethodType: "UDJQUGF5bWVudE1ldGhvZFR5cGVUeXBlLTg0ZjU4YWJjLThkZTItNDljYS04ZTE2LTQ0ZjYzMjYxNTBmMg==",
        fields: [
            {identifier: "name", value: "Jane Doe"},
            {identifier: "phone_number", value: "0246977890"}
        ]
    ) {
        id
        value
        fields {
            identifier
            value
        }
    }
}

Request

  • customer: The ID of the customer you want to add a payment method for

  • p2pPaymentMethodType: The ID of the type of payment method you're adding for the customer. You can get a list of the available payment method types using the p2pPaymentMethodTypes query.

  • fields: The customer filled in fields of the type of payment method you're adding for the customer.

How to fill in fields

This section assumes that you've displayed the list of available payment method types to your customer, and they've chosen to add an "MTN Mobile Money" payment method.

Your app should render a number of text inputs corresponding to the fields available on the payment method type. When the users enter the right text, you should add it to the fields array you'll provide when calling addPaymentMethod.

For example, if the user types Test User into the name input, and 0247890890 into the phone_number input, your fields array would look like this:

[
    { "identifier": "name", value: "Test User" },
    { "identifier": "phone_number", value: "0247890890" }
]

Get a customer's payment methods

paymentMethods.gql
query {
    node(id: "TWVyY2hhbnRDdXN0b21lci05ODFmYzVjMy1jNjYwLTQyMzAtYTgzNi0xM2EyOWZlMjRiOWY=") {
        ... on MerchantCustomer {
            p2pPaymentMethods {
                id
                value
            }
        }
    }
}
  • id: The ID of the customer

Last updated