kn9ts / project-mulla

Talk to MPESA API via a REST API. Bringing the MPESA G2 API to the 21st century. --
http://kn9ts.github.io/project-mulla/
GNU Lesser General Public License v3.0
301 stars 117 forks source link

Endpoint and USSD Push #58

Closed NateNjuguna closed 8 years ago

NateNjuguna commented 8 years ago

Great work Gene. I deployed mulla and tested successfully. However a curl request will succeed (200) but no USSD push is invoked as specified by the g2 specification and my endpoint as specifed in the app.yaml file is not respected as well. It seems to work but it actually doesn't. Yaml file

env_variables:
   PAYBILL_NUMBER: 'XXXXXX'
   PASSKEY: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
   MERCHANT_ENDPOINT: 'https://my-domain/pay/test/callback'

RAW CURL:

$ curl -i -X POST \
>   --url https://my-domain/api/v1/payment/request \
>   --data 'phoneNumber=2547xxxxxxxx' \
>   --data 'totalAmount=10.00' \
>   --data 'clientName="Foo Bar"' \
>   --data 'clientLocation=Lorem Ipsum' \

RESPONSE:

{   
    "response": {
        "return_code":"00",
        "status_code":200,
        "message":"Transaction carried successfully",
        "trx_id":"9deff9552f55547c8d541c04c9efc9dd",
        "cust_msg":"to complete this transaction, enter your pin on your handset. if you don't have a pin, press 0 and follow the instructions.",
        "description":"success",
        "reference_id":"37e5f9c3-5c87-4615-855b-f6392e2c2d5c",
        "merchant_transaction_id":"44ebfd80-6667-11e6-be4e-5d93dc3b794e",
        "amount_in_double_float":"10.00",
        "client_phone_number":"2547xxxxxxxx",
        "extra_payload": {
            "clientName":"\"Foo Bar\"",
            "clientLocation":"Lorem Ipsum"
        },
        "time_stamp":"20160820024720",
        "callback_url":"http://my-domain/api/v1/payment/success"
    }
}

As you can see, not even the https protocol I access mulla from is respected in the callback.

urandu commented 8 years ago

Hi You have to confirm the transaction by sending a get request to mulla in order for the ussd push to occur. send GET to https://my-domain/api/v1/payment/confirm/{trx_id}

{trx_id} is the one returned from initial request

kn9ts commented 8 years ago

@NateNjuguna as @urandu has stated. There are 3 steps involved. Initialising the payment request. Then actually requesting it to be transacted. And lastly waiting for Safaricom to respond to your callback endpoint.

Please refer to the documentation steps: http://kn9ts.github.io/project-mulla/docs/payment-request.html