Detailed Guide to Integrate 2C2P Payment Gateway to Accept GCash Payments

1. Introduction


As a one-stop payment service provider, 2C2P provides merchants with a variety of payment methods, including the popular Philippine e-wallet GCash. This guide will detail how to use 2C2P's PGW SDK to integrate GCash payment so that merchants can accept e-wallet payments from Philippine users.


2. Preparation


Before starting the integration, make sure you have registered a 2C2P account and obtained the necessary API keys and merchant IDs. At the same time, you need to understand GCash's payment process and related restrictions in the Philippines.


3. Integration steps


1. Generate a payment token

First, you need to generate a payment token, which is a necessary step to initiate a payment request.


Request parameter example:

json copy code{ "merchantID": "your merchant ID", "invoiceNo": "1595219400", "description": "goods or services description", "amount": 10.0, "currencyCode": "PHP", // Note: when using GCash, it should be specified as PHP "nonceStr": "a random string", "paymentChannel": ["DPAY"] }

merchantID: your 2C2P merchant ID.


invoiceNo: order number, must be unique.


description: description of goods or services.


amount: payment amount.


currencyCode: currency code, GCash should use PHP.

Detailed Guide to Integrate 2C2P Payment Gateway to Accept GCash Payments


nonceStr: a random string to prevent replay attacks.


paymentChannel: payment channel, for GCash, use "DPAY" and specify "EWALLET" and "GCASH".


response: the payment token ID will be returned for subsequent steps.

2. Receive payment token response

Process the payment token ID returned from the 2C2P server and save it in your system for later use.


3. Prepare e-wallet payment request

Use the payment token ID obtained in the previous step and the payment parameters of GCash to build a payment request.


Payment parameter example:

java copy code PaymentCode paymentCode = new PaymentCode("GCASH");PaymentRequest paymentRequest = new DigitalPaymentBuilder(paymentCode).setName("user name").setEmail("user email").setAccountNo("user GCash account, optional").build();

PaymentCode: Specifies that the payment method is GCASH.


setName, setEmail: Basic information of the user, which may be used for payment verification.


setAccountNo: In some cases, the user may be required to provide his GCash account, but it is usually not required.


4. Prepare transaction request

Merge the payment token and payment request into a transaction request and submit it to the 2C2P server.


Request parameters:

Build a transaction request object by combining the payment token and payment request parameters.


5. Receive transaction request response

Process the transaction response returned by the 2C2P server. Depending on the response code, you may need to redirect the user to the GCash app or web page for payment authorization.


Response processing example:

java

Copy code


PGWSDK.getInstance().proceedTransaction(transactionResultRequest, new APIResponseCallback<TransactionResultResponse>() {


@Override


public void onResponse(TransactionResultResponse response) {


if (need to redirect) {


String redirectUrl = response.getData(); // Open WebView or redirect to GCash app


} else {


// Process payment results or errors


}


}


@Override


public void onFailure(Throwable error) {


// Process errors


}


});


6. Initiate payment query

After the payment is completed, you may need to query the payment details and status. Use the payment query API to get the latest information.


Query parameters:

Provide the order number or payment ID as the query parameter.


Response processing:

Parse the query response to get the payment status and details.


IV. Summary


With the above steps, you can successfully integrate GCash payment into your system to accept e-wallet payments from Philippine users. Make sure to test all payment processes to ensure the stability and security of the system. If you encounter any problems, please refer to the official documentation of 2C2P or contact technical support for help.



猜你喜欢

发表评论

发表评论:

推荐标签