Skip to content

Commit

Permalink
Fix refund issue on payement lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperstrongBE committed Nov 27, 2024
1 parent fbce992 commit 50e988d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { JsonRpc } from '@proton/js';
import {Tables} from '../interfaces/xprcheckout'
import { toEOSIOSha256 } from 'xprcheckout/utils/sha256';

export type PaymentStatus = 'pending'|'paid'|'refunded'

export async function verifyPaymentStatus(paymentKey: string, endpoints: string[]):Promise<PaymentStatus> {

const rpc = new JsonRpc(endpoints);

console.log(paymentKey,'look for payment key')
return await rpc.get_table_rows({
json: true,
reverse:true,
code: 'xprcheckout',
table: 'payments',
scope: 'xprcheckout',
index_position: 2,
key_type: 'sha256',
limit:1,
upper_bound:paymentKey
upper_bound:toEOSIOSha256(paymentKey),
lower_bound:toEOSIOSha256(paymentKey),
}).then((res) => {
console.log('found payment',res.rows[0])
if (!res.rows) return 'pending'
const rows = res.rows as Tables<'PaymentsTable'>[];
if (!rows[0]) return 'pending'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export async function getStoreBalance(store:string,isTestnet:boolean) {
)

try {

const balanceQuey = await rpc.get_table_rows({
code: 'wookey',
scope: store,
Expand Down
2 changes: 1 addition & 1 deletion includes/api/order-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function handle_convert_order ($request){
$existingOrder->update_meta_data('_paid_tokens',$settlement->payment['settlement']);
$existingOrder->update_meta_data('_buyer_account',$settlement->payment['buyer']);
$txId = $existingOrder->get_meta('_tx_id');
if (isset($params['txId']) && empty($txId) ) {
if (isset($params['txId']) && is_null($txId) ) {
$existingOrder->update_meta_data('_tx_id',$params['txId']);
}

Expand Down

0 comments on commit 50e988d

Please sign in to comment.