# How to call One-time and Guest Donations APIs source: https://developer.mastercard.com/donations/tutorial/donation-api-details/onetimeapi/index.md ### Send donations quickly {#send-donations-quickly} * The `/donations/payments` endpoint allows donors to make a one-time donation to a selected charity for a specified amount with a new card or an existing payment card-on-file. * The '/guest-payments' endpoint allows cardholders to enter their payment card details to donate to a charity or cause of their choice without storing their payment card details in the Mastercard Donate Service. The previously used '/donations/payments/guests' endpoint is deprecated. ## POST /payments {#post-payments} ## Prerequisites {#prerequisites} Before executing the test cases, acquaint yourself with the endpoint use case and parameters: * [Make a One-time Donation Using a New Card](https://developer.mastercard.com/donations/documentation/use-cases/make-donations/one-time-donations/index.md) * [Parameters to Make One-time Donations](https://developer.mastercard.com/donations/documentation/parameters/manage-onetime-guest-dn-param/onetime/index.md) ## Test Cases {#test-cases} 1. To make a one-time donation with a registered card, send a POST request. 2. To create a POST request, fill out the details as shown in the request. ```py POST https://sandbox.api.mastercard.com/payments ``` 3. Provide the `cardId` parameter when making a one-time donation from a registered card. ### Request body without authPayerResponse Object {#request-body-without-authpayerresponse-object} ```JSON { "donorId": "1cdb7f98-c43e-4978-9702-3047d3204042", "cardId": "", "card": { "cvc": "667" }, "donation": { "charityId": "b3eef2a3-2a76-4d71-9292-a251931b71e9", "amount": 10, "donationType": "ONE-TIME" } } ``` ### Request body with authPayerResponse Object for MPGS {#request-body-with-authpayerresponse-object-for-mpgs} ```JSON { "donorId": "1cdb7f98-c43e-4978-9702-3047d3204042", "cardId": "", "card": { "cvc": "667" }, "donation": { "charityId": "b3eef2a3-2a76-4d71-9292-a251931b71e9", "amount": 10, "donationType": "ONE-TIME" }, "pspVersion": "57", "source" : "Widget" "authPayerResponse": { "authentication": { "3ds": { "acsEci": "02", "authenticationToken": "keds+7YFi1EUAREAAAAvNUe6Hre=", "transactionId": "9f343e5d-fc28-4818-88d4-17a35fb7dea9" }, "3ds2": { "transactionStatus": "Y", "protocolVersion": "2.2.2" } } } } ``` ### Request body with authPayerResponse Object for STRIPE {#request-body-with-authpayerresponse-object-for-stripe} ```JSON { "donorId": "1cdb7f98-c43e-4978-9702-3047d3204042", "cardId": "", "card": { "cvc": "667" }, "donation": { "charityId": "b3eef2a3-2a76-4d71-9292-a251931b71e9", "amount": 10, "donationType": "ONE-TIME" }, "pspVersion": "57", "source" : "Widget" "authPayerResponse": { "authentication": { "3ds": { "version": "1.0.2", "acsEci": "05", "authenticationToken": "H0JMekBi8OrE7p5C6gGxwI54PQs=", "transactionId": "d+NEBKSpEMauwleRhdrDY06qj4A=" } } } } ``` 4. A successful request returns the `HTTP 200 Success` status code and a JSON response body that includes a unique transaction identifier. ```JSON { "transactionId": "85948548594", "transactionStatus": "SUCCESS", "transactionMessage": "Transaction APPROVED" } ``` 1. To make a one-time donation with a new card, send a POST request. 2. To create a POST request, fill out the details as shown in the request. ```py POST https://sandbox.api.mastercard.com/payments ``` 3. Provide the `primaryAccountParameter` and the card details when making a one-time donation from a new card. ### Request body without authPayerResponse Object {#request-body-without-authpayerresponse-object} ```JSON { "donorId": "53a59da7-70a4-414a-89d1-fc3a64f2591d", "card": { "primaryAccountNumber" : "71930787711008431", "cvc" : "100", "expiryInfo" : { "month" : "01", "year" : "2040" } }, "donation": { "charityId": "b8f5ac7d-baae-4569-9346-6181bfe1564a", "amount": 100, "donationType": "ONE-TIME" } } ``` ### Request body with authPayerResponse Object for MPGS {#request-body-with-authpayerresponse-object-for-mpgs} ```JSON { "donorId": "53a59da7-70a4-414a-89d1-fc3a64f2591d", "card": { "primaryAccountNumber" : "71930787711008431", "cvc" : "100", "expiryInfo" : { "month" : "01", "year" : "2040" } }, "donation": { "charityId": "b8f5ac7d-baae-4569-9346-6181bfe1564a", "amount": 100, "donationType": "ONE-TIME" }, "authPayerResponse": { "authentication": { "3ds": { "acsEci": "02", "authenticationToken": "keds+7YFi1EUAREAAAAvNUe6Hre=", "transactionId": "9f343e5d-fc28-4818-88d4-17a35fb7dea9" }, "3ds2": { "transactionStatus": "Y", "protocolVersion": "2.2.2" } } } } ``` ### Request body with authPayerResponse Object for STRIPE {#request-body-with-authpayerresponse-object-for-stripe} ```JSON { "donorId": "53a59da7-70a4-414a-89d1-fc3a64f2591d", "card": { "primaryAccountNumber" : "71930787711008431", "cvc" : "100", "expiryInfo" : { "month" : "01", "year" : "2040" } }, "donation": { "charityId": "b8f5ac7d-baae-4569-9346-6181bfe1564a", "amount": 100, "donationType": "ONE-TIME" }, "authPayerResponse": { "authentication": { "3ds": { "version": "1.0.2", "acsEci": "05", "authenticationToken": "H0JMekBi8OrE7p5C6gGxwI54PQs=", "transactionId": "d+NEBKSpEMauwleRhdrDY06qj4A=" } } } } ``` 4. A successful request returns the `HTTP 200 Success` status code and a JSON response body that includes a unique transaction identifier. Note: The service does not store the new card used to make a one-time donation. Hence, no `cardId` is returned in the response. ```JSON { "transactionId": "OTbB0kCkRxC7tu1itsIN8U", "transactionStatus": "SUCCESS", "transactionMessage": "Transaction APPROVED" } ``` This section discusses a failed scenario and the error message expected. If the card is not supported by the issuer, the service is not able to process the one-time donation. The request then terminates with the `400 Bad Request` error. ```JSON { "transactionId": "OTbB0kCkRxC7tu1itsIN8Q", "transactionStatus": "FAILURE", "transactionMessage": "Transaction declined", "reasonCode": "INSUFFICIENT_FUNDS", "reasonMessage": "The card has insufficient funds to complete the purchase. Please use a different card." } ``` ## POST /guest-payments {#post-guest-payments} *Deprecated:* `/payments/guests` ## Prerequisites {#prerequisites} Before executing the test cases, acquaint yourself with the endpoint use case and parameters: * [Make a Guest Donation](https://developer.mastercard.com/donations/documentation/use-cases/make-donations/guest-donation/index.md) * [Parameters to Make Guest Donations](https://developer.mastercard.com/donations/documentation/parameters/manage-onetime-guest-dn-param/guest/index.md) ## Test Cases {#test-cases} 1. To make a one-time donation with a new card, send a POST request. 2. To create a POST request, fill out the details as shown in the request. ```py # DEPRECATED POST https://sandbox.api.mastercard.com/payments/guests # NEW POST https://sandbox.api.mastercard.com/guest-payments ``` 3. Provide the `charityId`, `donationType` as 'ONE-TIME', user details, and the card details when making a guest donation since neither the donor or the card are registered with the Mastercard Donate Service. ### Request body without authPayerResponse Object {#request-body-without-authpayerresponse-object} ```json { "donation": { "charityId": "b3eef2a3-2a76-4d71-9292-a251931b71e9", "amount": 10, "donationType": "ONE-TIME" }, "user": { "firstName": "lee", "lastName": "cardholder", "email": "lee45@yopmail.com" }, "card": { "primaryAccountNumber" : "2223000000000007", "cvc" : "000", "expiryInfo" : { "month" : "01", "year" : "2039" } } } ``` ### Request body with authPayerResponse Object for MPGS {#request-body-with-authpayerresponse-object-for-mpgs} ```json { "donation": { "charityId": "b3eef2a3-2a76-4d71-9292-a251931b71e9", "amount": 10, "donationType": "ONE-TIME" }, "user": { "firstName": "lee", "lastName": "cardholder", "email": "lee45@yopmail.com" }, "card": { "primaryAccountNumber" : "2223000000000007", "cvc" : "000", "expiryInfo" : { "month" : "01", "year" : "2039" } }, "authPayerResponse": { "authentication": { "3ds": { "acsEci": "02", "authenticationToken": "keds+7YFi1EUAREAAAAvNUe6Hre=", "transactionId": "9f343e5d-fc28-4818-88d4-17a35fb7dea9" }, "3ds2": { "transactionStatus": "Y", "protocolVersion": "2.2.2" } } } } ``` ### Request body with authPayerResponse Object for STRIPE {#request-body-with-authpayerresponse-object-for-stripe} ```json { "donation": { "charityId": "b3eef2a3-2a76-4d71-9292-a251931b71e9", "amount": 10, "donationType": "ONE-TIME" }, "user": { "firstName": "lee", "lastName": "cardholder", "email": "lee45@yopmail.com" }, "card": { "primaryAccountNumber" : "2223000000000007", "cvc" : "000", "expiryInfo" : { "month" : "01", "year" : "2039" } }, "authPayerResponse": { "authentication": { "3ds": { "version": "1.0.2", "acsEci": "05", "authenticationToken": "H0JMekBi8OrE7p5C6gGxwI54PQs=", "transactionId": "d+NEBKSpEMauwleRhdrDY06qj4A=" } } } } ``` 4. A successful request returns the `HTTP 200 Success` status code and a JSON response body that includes a unique transaction identifier. ```json { "transactionId": "OTBVMrlAQa6Ecl7PlKSDyw", "transactionStatus": "SUCCESS", "transactionMessage": "Transaction APPROVED" } ``` This section discusses a failed scenario and the error message expected. If the card does not have sufficient funds, the transaction is declined and the request terminates with the `400 Bad Request` error. ```JSON { "transactionId": "OTbB0kCkRxC7tu1itsIN8Q", "transactionStatus": "FAILURE", "transactionMessage": "Transaction declined", "reasonCode": "INSUFFICIENT_FUNDS", "reasonMessage": "The card has insufficient funds to complete the purchase. Please use a different card." } ```