Get started with docs
Create payment
$result = pspg_create_payment(
'arca_idbank',
array(
'amount' => '10.00',
'currency' => 'AMD',
'return_url' => home_url( '/callback' ),
'description' => 'Order #1001',
'source' => 'custom',
'source_id' => 1001,
'clientId' => '2', // if you want to bind a card and the bank supports it
)
);
Expected response:
{
"ok": true,
"bank": "arca_idbank",
"bank_ids": {
"primary": "f9baddf9-29bd-4f21-99f8-81fef9c60758",
"orderId": "f9baddf9-29bd-4f21-99f8-81fef9c60758",
"currency_code": "051",
"test_mode": 1,
"is_binding": 0
},
"status": "registered",
"redirect_url": "https://ipaytest.arca.am:8445/payment/merchants/planet/payment_en.html?mdOrder=f9baddf9-29bd-4f21-99f8-81fef9c60758",
"raw": {
"errorCode": 0,
"orderId": "f9baddf9-29bd-4f21-99f8-81fef9c60758",
"formUrl": "https://ipaytest.arca.am:8445/payment/merchants/planet/payment_en.html?mdOrder=f9baddf9-29bd-4f21-99f8-81fef9c60758",
"errorCodeString": "0",
"error": false
},
"summary": {
"action": "create_payment",
"code": 0,
"message": null,
"details": null
},
"pspg_order_id": 454
}
What it means:
ok— payment was created successfullybank— bank idbank_ids.primary— main bank id, save this valuebank_ids.orderId— bank order idbank_ids.currency_code— numeric ISO currency code, for example051 = AMDbank_ids.test_mode— test/live modebank_ids.is_binding— this is not a binding charge, so it is0status = registered— payment was created, user has not completed payment yetredirect_url— redirect the user to this URLraw— raw bank responsesummary— short summarypspg_order_id— internal PSPG row inwp_pspg_orders
Get payment status
Use this after the user returns from the bank or after a callback. pspg_sync_status() is the source of truth for the final payment state.
$result = pspg_sync_status(
'arca_idbank',
array(
'pspg_order_id' => 454,
'orderId' => 'f9baddf9-29bd-4f21-99f8-81fef9c60758',
'currency' => 'AMD',
'params' => $_REQUEST,
)
);
Expected response:
{
"ok": true,
"bank": "arca_idbank",
"bank_ids": {
"primary": "f9baddf9-29bd-4f21-99f8-81fef9c60758",
"orderId": "f9baddf9-29bd-4f21-99f8-81fef9c60758",
"test_mode": 1
},
"bank_status": 2,
"status": "paid",
"raw": {
"errorCode": "0",
"errorMessage": "Success",
"orderNumber": "TEST-L3-454",
"orderStatus": 2,
"actionCode": 0,
"actionCodeDescription": "Request processed successfully",
"amount": 1000,
"currency": "051",
"paymentAmountInfo": {
"paymentState": "DEPOSITED",
"approvedAmount": 1000,
"depositedAmount": 1000,
"refundedAmount": 0
},
"cardAuthInfo": {
"expiration": "202708",
"cardholderName": "ARA MARGARYAN",
"approvalCode": "817644",
"pan": "518180**7963"
},
"error": false
},
"summary": {
"action": "sync_status",
"code": 0,
"message": "Success",
"details": "Request processed successfully"
},
"binding": {
"pan": "518180**7963",
"expiration": "202708"
},
"pspg_order_id": 454
}
What it means:
bank_status— numeric bank statusstatus— normalized PSPG statusstatus = paid— payment completed successfullybinding— card or binding data if returned by the bankpspg_order_id— same PSPG row
Possible status values:
registeredpendingauthorizedpaidfailedrefundedvoidedunknown
Refund payment
$result = pspg_refund_payment(
'arca_idbank',
array(
'pspg_order_id' => 454,
'orderId' => 'f9baddf9-29bd-4f21-99f8-81fef9c60758',
'amount' => '1.00', // optional
'currency' => 'AMD',
)
);
Expected response:
{
"ok": true,
"bank": "arca_idbank",
"bank_ids": {
"primary": "f9baddf9-29bd-4f21-99f8-81fef9c60758",
"orderId": "f9baddf9-29bd-4f21-99f8-81fef9c60758",
"test_mode": 1,
"currency_code": "051"
},
"bank_status": null,
"status": "refunded",
"raw": {
"errorCode": "0",
"errorMessage": "Success",
"error": false
},
"summary": {
"action": "refund_payment",
"code": "0",
"message": "Success",
"details": null
},
"binding": null,
"pspg_order_id": 454
}
What it means:
status = refunded— the bank accepted the refund requestbank_status = null— direct refund response may not return the final numeric bank status- If you need the final bank status after refund, call
pspg_sync_status()
Cancel / Reverse payment
$result = pspg_void_payment(
'arca_idbank',
array(
'pspg_order_id' => 454,
'orderId' => 'f9baddf9-29bd-4f21-99f8-81fef9c60758',
'currency' => 'AMD',
)
);
Possible error response:
{
"ok": false,
"bank": "arca_idbank",
"error": "bank_error",
"message": "Reversal is impossible for current transaction state",
"bank_error_code": "7",
"raw": {
"errorCode": "7",
"errorMessage": "Reversal is impossible for current transaction state",
"error": true
},
"pspg_order_id": 454
}
What it means:
ok = false— operation failedmessage— bank error messagebank_error_code— bank error codevoidusually works only before the payment is final or deposited- For already completed payments, use
refundinstead ofvoid
Bind a card on the initial payment
If you want to charge the same card later, create a normal payment and pass clientId.
$result = pspg_create_payment(
'arca_idbank',
array(
'amount' => '10.00',
'currency' => 'AMD',
'return_url' => home_url( '/callback' ),
'description' => 'Initial payment with binding',
'source' => 'custom',
'source_id' => 1002,
'clientId' => '2'
)
);
clientId is your own internal customer identifier, for example:
- user id
- customer id
- profile id
Then call pspg_sync_status() after the payment succeeds.
$result = pspg_sync_status(
'arca_idbank',
array(
'pspg_order_id' => 456,
'orderId' => '3b2a2c1b-a850-4edd-abf9-bb2a36e1078a',
'currency' => 'AMD',
'params' => $_REQUEST,
)
);
Expected response with binding info:
{
"ok": true,
"bank": "arca_idbank",
"bank_status": 2,
"status": "paid",
"binding": {
"binding_id": "97578600-85f8-4f9a-a0f0-eae2be595287",
"client_id": "2",
"pan": "518180**7963",
"expiration": "202708"
},
"pspg_order_id": 456
}
What it means:
binding.binding_id— token / binding id, save this valuebinding.client_id— client id returned by the bankpan,expiration— masked card data
Charge a saved card
When you already have binding_id and, if needed, clientId, you can perform a saved card payment.
$result = pspg_charge_saved_card(
'arca_idbank',
array(
'amount' => '20.00',
'currency' => 'AMD',
'binding_id' => '97578600-85f8-4f9a-a0f0-eae2be595287',
'clientId' => '2',
'return_url' => home_url( '/callback' ),
'description' => 'Recurring payment',
'source' => 'custom',
'source_id' => 1003,
)
);
Expected response:
{
"ok": true,
"bank": "arca_idbank",
"bank_ids": {
"orderId": "4b7fc2e0-8f3c-43cf-a59b-e88fa8ff5f72",
"test_mode": 1,
"currency_code": "051",
"is_binding": 1,
"primary": "4b7fc2e0-8f3c-43cf-a59b-e88fa8ff5f72"
},
"status": "paid",
"bank_status": 2,
"binding": {
"binding_id": "97578600-85f8-4f9a-a0f0-eae2be595287",
"client_id": "2",
"pan": "518180**7963",
"expiration": "202708"
},
"pspg_order_id": 458
}
What it means:
bank_ids.is_binding = 1— this is a binding paymentpspg_order_id— a new PSPG row for a new recurring chargebinding_id— same saved binding token- You may pass
clientIdorclient_id
Available bank IDs
ameria— Ameriabankineco— Inecobankamio— AMIO Bankarca_acba— ACBA Bank (ArCa)arca_ararat— Araratbank (ArCa)arca_armeconombank— Armeconombank (ArCa)arca_armswiss— Armswissbank (ArCa)arca_ardshin— Ardshinbank (ArCa)arca_byblos— Byblos Bank Armenia (ArCa)arca_converse— Converse Bank (ArCa)arca_evoca— Evocabank (ArCa)arca_fastbank— Fast Bank (ArCa)arca_idbank— IDBank (ArCa)
What to save in your project
Minimum values to store:
$result['pspg_order_id']
$result['bank_ids']['primary']
If you use saved card flow, also store:
$result['binding']['binding_id']
$result['binding']['client_id']
Important
- Always rely on
ok,status,bank_status,bank_ids.primary, andpspg_order_id - Use
rawandsummaryfor debug and logs - If you need the final state after refund or void, call
pspg_sync_status()
